那么有没有什么办法可以绕过这个限制,让fooDerivedA和DerivedB类的方法可以有我想要的签名呢?
class SuperA{
}
class SuperB{
}
interface InterfaceA{
}
interface InterfaceB<T>{
<P extends T & InterfaceA> void foo(P param);
//error:type parameter cannot be followed by other bounds
}
class DerivedA extends SuperA implements InterfaceB<SuperA>{
@Override
<P extends SuperA & InterfaceA> void foo(P param){
//P should be some type extends SuperA and implements InterfaceA.
}
}
class DerivedB extends SuperB implements InterfaceB<SuperB>{
@Override
<P extends SuperB & InterfaceA> void foo(P param){
//P should be some type extends SuperB …Run Code Online (Sandbox Code Playgroud) 现在我有了一个自己的库,我想在另一个CMake c ++项目中使用它。它像这样存在于我的计算机中。
${MY_LIB_PATH}\include
${MY_LIB_PATH}\lib\x86\debug\lib-files
${MY_LIB_PATH}\lib\x86\release\lib-files
${MY_LIB_PATH}\lib\x64\debug\lib-files
${MY_LIB_PATH}\lib\x64\release\lib-files
Run Code Online (Sandbox Code Playgroud)
使CMake find_package知道这些的基本配置文件是什么样的?我希望它会非常简单,因为它没有太多信息可提供。但是此页面只会伤到我的头。
抱歉,我决定复制源代码,所以我真的不知道应该接受哪个答案。
假设我有一个模板:
template<typename T>
struct Outer {
template<typename T1>
struct Inner {
};
};
Run Code Online (Sandbox Code Playgroud)
我想要一个别名模板Alias:
template<typename T>
using Alias = Outer<T>::template Inner; // this won't work
using IntOuter = Alias<int>;
Run Code Online (Sandbox Code Playgroud)
因此IntOuter<double>与Outer<int>::template Inner<double>。您如何定义Alias?还是可能吗?
编辑:
我希望能够SomeOuter即时创建模板foo:
template<template<typename> class>
struct Foo {
};
Run Code Online (Sandbox Code Playgroud)
Foo<Alias<int>> 与...相同 Foo<Outer<int>::template Inner>
或做这样的事情:
template<typename T>
using SomeFoo = Foo<Alias<T>>;
Run Code Online (Sandbox Code Playgroud) 基本上我想要的是:
class MyClass{
public:
MyClass() = default;
// what should I do?
}
MyClass mc; // compile time error;
auto pmc = new MyClass; //OK
delete pmc; //OK too
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过隐藏构造函数(现在不能在类外部新建)或隐藏析构函数(现在不能在类外删除)或隐藏两者来使其成为堆.如果我不想引入一些新的命名函数并且只想要好的旧的和删除怎么办?是否有可能(即使是黑客攻击)?
is_trivially_copy_*和之间有什么区别is_trivially_move_*?我可以使用memcpy来移动构造/赋值is_trivially_move_*类型吗?