我正在嘗試在標題中描述的事情。 template <class T>
void foo(const Foo* f) // this is general case template
{
}
// this should work only if T has static variable named _Foo with type const Foo*
template <class
當我聲明一個類靜態方法時,是否可以使用decltype(或以任何其他類似的樣式)引用當前類?例如, class
AAA
{
static AAA const make();
};
我想使這樣的事情。 class
AAA
{
static decltype(*this) const make(); // Not working because there's no
這是我的理解decltype用於查詢對象/變量等的類型。 從目前的維基百科上的例子,如下列: int i;
decltype(i) x3; // type is int
我認爲我可以做這樣的事情: class A
{
public:
int a, b;
};
template<typename T>
struct IsClass
{
enum { Yes =