http://stackoverflow.com/questions/7774188/explicit-specialization-after-instantiation
http://blog.csdn.net/xcysuccess3/article/details/8684813
typedef vector<int> Vec;
typedef vector<Vec> VecOfVec;
template<typename Vec>
Vec DoSomething(const Vec &v);
template<>
VecOfVec DoSomething<VecOfVec>(const VecOfVec &v)
{
VecOfVec r;
for(auto i = v.begin(); i != v.end(); i++)
r.push_back(DoSomething(*i));
return r;
}
template<>
Vec DoSomething<Vec>(const Vec &v) specialization of …… after instantiation
{
return v; // for the sake of the example
}
VC2012编译正常,安卓NDK r10d编译出错“specialization of …… after instantiation”
解决方法:
1、把DoSomething特化放在出现调用之前
template<>
Vec DoSomething<Vec>(const Vec &v)
{
return v; // for the sake of the example
}
template<>
VecOfVec DoSomething<VecOfVec>(const VecOfVec &v)
{
VecOfVec r;
for(auto i
2、在头文件中声明特化(专用化)函数原型,以分号结尾:
template<>Vec DoSomething<Vec>(const Vec &v);