小编h4t*_*tch的帖子

当模板化函数调用以特定方式链接时,代码将无法使用G ++ 4.7.3进行编译

请注意,我可以简单地绕过这个问题,我只是好奇为什么会发生这种情况.

我试图在另一个模板化函数的返回值上调用模板化函数,所有函数都在模板化函数中.我用模板化对象作为模板参数调用模板化函数.模板化对象使用外部模板参数定义.

#include <string>

class Class
{
public:
    static Class& define( std::string name ) {
        return *new Class();
    }

    template<typename C, typename... Args>
    Class& constructor() {
        // .. Add the constructor...
        return *this;   
    }
};


template<typename T>
class iVector {
    T x; T y;
    iVector() : x( 0 ), y( 0 ) {}
    iVector( T x, T y ) : x( x ), y( y ) {}
};


typedef iVector<int> Vector;


Class& registerVector( std::string name ) {
    // This works …
Run Code Online (Sandbox Code Playgroud)

c++ templates g++

2
推荐指数
1
解决办法
68
查看次数

标签 统计

c++ ×1

g++ ×1

templates ×1