나는 템플릿과 네임 스페이스와 이상한 문제 ...이상한 템플릿 네임 스페이스 문제
있어 I가 잘 컴파일 다음 코드 .. 때문에 네임 스페이스 충돌하는 경우에 그러나
using namespace boost::multi_index;
template < typename OT, typename KT, KT (OT::* KM)() const, typename KC, typename CMP >
class OrderBook
{
public:
OrderBook() {}
~OrderBook() {}
typedef multi_index_container<
OT,
indexed_by<
ordered_unique<
const_mem_fun< OT, KT, KM >,
KC
>,
ordered_unique<
identity<OT>,
CMP
>
>
> Container;
typedef typename Container::template nth_index<0>::type index_0;
typedef typename Container::template nth_index<1>::type index_1;
typedef typename index_0::const_iterator const_iterator_0;
typedef typename index_1::const_iterator const_iterator_1;
const_iterator_0 begin0() const { return _container.get<0>().begin(); }
const_iterator_0 end0() const { return _container.get<0>().end(); }
public:
Container _container;
};
, 내가 가지고있는 다른 프로젝트에이 코드를 삽입 ... (내가
template < typename OT, typename KT, KT (OT::* KM)() const, typename KC, typename CMP >
class OrderBook
{
public:
OrderBook() {}
~OrderBook() {}
typedef boost::multi_index::multi_index_container<
OT,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::const_mem_fun< OT, KT, KM >,
KC
>,
boost::multi_index::ordered_unique<
boost::multi_index::identity<OT>,
CMP
>
>
> Container;
typedef typename Container::template nth_index<0>::type index_0;
typedef typename Container::template nth_index<1>::type index_1;
typedef typename index_0::const_iterator const_iterator_0;
typedef typename index_1::const_iterator const_iterator_1;
const_iterator_0 begin0() const { return _container.get<0>().begin(); }
const_iterator_0 end0() const { return _container.get<0>().end(); }
public:
Container _container;
};
을 필요한 곳에 나에게 t을 제공합니다 어느를 지정 수동으로 사용 namespace boost::multi_index
를 제거하고 했어 방법에 주목 그는 g ++에서 오류를 따라 갔다.
In member function 'typename boost::multi_index::multi_index_container<OT, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::const_mem_fun<OT, KT, KM>, KC, mpl_::na>, boost::multi_index::ordered_unique<boost::multi_index::identity<Value>, CMP, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<_CharT> >::nth_index<0>::type::const_iterator OrderBook<OT, KT, KM, KC, CMP>::begin0() const':
error: expected primary-expression before ')' token
In member function 'typename boost::multi_index::multi_index_container<OT, boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::const_mem_fun<OT, KT, KM>, KC, mpl_::na>, boost::multi_index::ordered_unique<boost::multi_index::identity<Value>, CMP, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<_CharT> >::nth_index<0>::type::const_iterator OrderBook<OT, KT, KM, KC, CMP>::end0() const':
error: expected primary-expression before ')' token
죄송합니다. 오랫동안 오류 메시지가 표시되었지만 정리를 고려해 보았습니다. 그러나 중요한 항목을 제거한 경우에 대비하여 그대로 두는 것이 좋습니다.
나는이 시도
...typedef typename Container::template boost::multi_index::nth_index<0>::type index_0;
typedef typename Container::template boost::multi_index::nth_index<1>::type index_1;
그리고 방금 만든 g ++도 꼭두서니 :(
어떤 아이디어?
어떤 g ++ 버전을 사용하고 있습니까? VC++ 2005 BTW와 완벽하게 호환되는 예제. –
VC8은 의존적 인 이름에 대해서는 꽤 느리다. 표준에서 요구하는 곳에'typename'과'template'을 항상 붙일 필요는 없다. –
합리적으로 오래된 gcc 4.1.2입니다. – ScaryAardvark