j'ai un problème étrange avec des modèles et des espaces de noms ...problème espace de noms modèle étrange
je le code suivant qui compile bien ..
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;
};
Toutefois, en raison d'une collision d'espace de noms lorsque insérer ce code dans un autre projet que je dois avoir ... (Remarquez comment j'ai dû enlever l'aide de namespace boost::multi_index
et spécifier manuellement si nécessaire
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;
};
ce qui me donne t Il suit l'erreur de 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
Désolé pour les longs messages d'erreur, je ne considère les nettoyer, mais je pensais que je ferais mieux de les laisser intactes au cas où j'enlevé quelque chose de crucial.
J'ai essayé ...
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;
et il vient de faire g ++ même garance :(
Toutes les idées?
Quelle version de g ++ utilisez-vous? Exemple parfaitement compilable avec VC++ 2005 BTW. –
VC8 est assez laxiste en ce qui concerne les noms dépendants, vous n'avez pas toujours à préfixer avec 'typename' et' template' où la norme vous obligerait à le faire. –
C'est un gcc raisonnablement ancien 4.1.2. – ScaryAardvark