【发布时间】:2015-11-29 08:42:16
【问题描述】:
我尝试让 NCORR 库在 VS2015 C++ 上运行。该库最初是在 Linux 上编写的。
作为库的一部分,代码类似于
#include <chrono>
template<typename T_container>
struct container_traits {
typedef typename T_container::container nonconst_container;
};
template <typename T_container>
class base_region {
public:
typedef typename container_traits<T_container>::nonconst_container nonconst_container;
template<typename T_container2>
typename std::enable_if<std::is_same<typename container_traits<T_container2>::nonconst_container, typename nonconst_container>::value, base_region&>::type operator=(const base_region<T_container2>&);
};
template <typename T_container>
template <typename T_container2>
typename std::enable_if<std::is_same<typename container_traits<T_container2>::nonconst_container, typename base_region<T_container>::nonconst_container>::value, base_region<T_container>&>::type base_region<T_container>::operator=(const base_region<T_container2>& reg) {
return *this;
}
int main()
{
return 0;
}
当我尝试在 VS2015 win32 控制台应用程序上编译代码时,我得到了
C2244 'base_region<T_container>::operator =': unable to match function definition to an existing declaration ConsoleApplication5
我认为问题在于声明中的 typename nonconst_container 与定义中的 typename base_region<T_container>::nonconst_container。
你知道哪里出了问题,我怎样才能让代码正常工作?
【问题讨论】:
-
好的,我会向微软报告。你能想到任何解决方法吗?
标签: c++ visual-studio templates visual-studio-2015