Boost logo

Boost Users :

From: Joel FALCOU (joel.falcou_at_[hidden])
Date: 2008-05-01 09:09:54


Hi all,

I'm currently using large parts of booos::mpl and boost::fusion in a
large project. Alas, I keep triggering some unwanted ADL betwenn some of
my code and mpl code.

Here is a simplified but significant code that showcases the problem :

#include <iostream>
#include <boost/mpl/vector.hpp>

using namespace std;

namespace bar
{
   namespace foo
   {
     template<class T, class LST> struct some_class
     {
       int size() const { return sizeof(T); }
     };

     template<class T,class LST> static inline
     int size( const some_class<T,LST>& src )
     {
       return src.size();
     }
   }

   using foo::some_class;
   using foo::size;
}

using namespace bar;

int main()
{
   some_class<int,int> f;
   cout << size(f) << endl;

   some_class<int, boost::mpl::vector<int> > g;
   cout << size(g) << endl;
}

This doesn't compile and outputs the following error (using mingw 4.1) :

In function 'int main()':
> error: 'template<class Sequence> struct boost::mpl::size' is not a
function
> error: conflict with 'template<class T, class LST> int
bar::foo::size(const bar::foo::some_class<T, LST>&)'
> error: in call to 'size'

What can I do to prevent this ADL while not forcing the client code to
explicitely write bar::size(g) ?

Thanks in advance

-- 
Joel FALCOU
Research Engineer @ Institut d'Electronique Fondamentale
Université PARIS SUD XI
France

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net