このコードを使用して、ボックスのポイント ( g
) の方向で最も遠いd
typedef vector_t point_t;を見つけます。
std::vector<point_t> corners = g.getAllCorners();
coordinate_type last_val = 0;
std::vector<point_t>::const_iterator it = corners.begin();
point_t last_max = *it;
do
{
coordinate_type new_val = dot_product( *it, d );
if( new_val > last_val )
{
last_val = new_val;
last_max = *it;
}
}
while( it != corners.end() );
return last_max;
また、名前空間に!=
あるクラスの演算子のテンプレート オペレーター オーバーロードもあります。vector_t
point
namespace point
{
template
<
typename lhs_vector3d_impl,
typename rhs_vector3d_impl
>
bool operator!=( const typename lhs_vector3d_impl& lhs, const typename rhs_vector3d_impl& rhs )
{
return binary_operator_not_equal<lhs_vector3d_impl, rhs_vector3d_impl>::apply( lhs, rhs );
}
};
ほとんどの場合、オーバーロードは正常に機能しますが、イテレータ (つまりit != corners.end()
) を使用すると、その場合にこの関数を意図していなかったため、機能しなくなります。テンプレートパラメーターの解決がうまくいかないためだと言えますが、理由はわかりません:
lhs_vector3d_impl=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<legend::geometry::point::Carray_Vector3d<int32_t>>>>,
rhs_vector3d_impl=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<legend::geometry::point::Carray_Vector3d<int32_t>>>>
間違った関数が呼び出されることは理解していますが、その理由はわかりません…</p>
したがって、基本的に私の質問は、std 名前空間の演算子ではなく関数でイテレータの比較が解決される方法と、この関数が使用されないようにするにはどうすればよいかということです。
注1:私はテンプレートから始めているので、知らないうちに非常に間違ったことをしている可能性があります。もしそうなら、親切に教えてください.
注 2: このコードは主に学術目的で使用されるため、ほとんどの作業を手動で行いたいと考えています。
注 3: Visual Studio 2012 C++ コンパイラを使用