0
boost::geometryライブラリの使用方法を学習しています。コードをより一般的にするために型特性が導入されているチュートリアルに従っています。例えば、以下のdistance
機能が特色を使用することにより、遺伝的とみなされている:私はコードをコンパイルするときなぜtraits :: accessをコンパイルできないのですか(C++)?
struct mypoint
{
double x, y;
};
template <typename P1, typename P2>
double distance(P1 const& a, P2 const& b)
{
double dx = get<0>(a) - get<0>(b);
double dy = get<1>(a) - get<1>(b);
return std::sqrt(dx * dx + dy * dy);
}
template <typename P1, typename P2>
double distance(P1 const& a, P2 const& b)
{
double dx = get<0>(a) - get<0>(b);
double dy = get<1>(a) - get<1>(b);
return std::sqrt(dx * dx + dy * dy);
}
namespace traits
{
template <>
struct access<mypoint, 0>
{
static double get(mypoint const& p)
{
return p.x;
}
};
template <>
struct access<mypoint, 1>
{
static double get(mypoint const& p)
{
return p.y;
}
};
}
ただし、次のコンパイルエラーが起こる:
Error 3 error C2913: explicit specialization; 'traits::access' is not a specialization of a class template
任意のアイデア?ありがとう。
用語は、「一般的な」「遺伝的」ではありません:) –