Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-24 16:55:52

Andy Little wrote:
> "Tobias Schwinger" wrote
>>How does the declaration of your operator- look like?
> Here's operator +. (All operators fail in a similar way )
> [...code]

Your operator- (in the code of your initial post) is not the problem it must be
the context it's used in.

I got a copy of your lib and comented the workaround and operator- and added

    template<typename T0,typename T1> T0 operator-(T0 const &, T1 const &);

and it didn't change anything.

>>Does it instantiate templates that use sizeof- or conditional tricks (as
> The pqs::meta::binary_operation result_type scheme in the operator+ definition
> above uses SFINAE quite heavily though. I shall try reducing it to a minimal
> example.

SFINAE (at least SFINAE alone) is not the problem, either. I wrote this little
test which compiles fine (it would have been too easy, I guess) ;-(.

   namespace user_namespace
     // some class template
     template<typename T> struct t1 { };
     // traits to detect its specializations
     template<typename T> struct is_t1
     { static bool const value = false; };
     template<typename T> struct is_t1<t1<T> >
     { static const bool value = true; };

     // another class template
     template<typename T> struct t2 { };
     // traits to detect its specializations
     template<typename T> struct is_t2
     { static bool const value = false; };
     template<typename T> struct is_t2<t2<T> >
     { static const bool value = true; };

     // tool to create a sfinae condition if the first argument is false
     template<bool, typename T> struct enable_if { typedef T type; };
     template<typename T> struct enable_if<false,T> { };

     // function templates

     template<typename T>
     typename enable_if<is_t1<T>::value, T >::type outer(t1<T> const & v);

     template<typename T>
     typename enable_if<is_t2<T>::value, T >::type outer(t1<T> const & v);

     template<typename T> t1<T> inner(t1<T> const & v);

   void func()
     user_namespace::t1< user_namespace::t1<int> > x;
     user_namespace::t1< user_namespace::t2<int> > y;

     // 'inner' is found by ADL

> Boost.Typeof use in the implementation (for operations on built-in types) is
> optional though I havent tried turning it off yet

BOOST_TYPEOF_TPL in particular messes up ADL for the expression passed to it (the
thread I linked to). Guessing from VC8's extremely strange behaviour in that case
TYPEOF_TPL might act as some sort of "bug attractant"... I'd definitely give it a

Hope it helps,


Boost list run by bdawes at, gregod at, cpdaniel at, john at