Boost logo

Boost Users :

Subject: Re: [Boost-users] [type_traits] will the future has_operator_left_shift be able to test if a type is serializable to a stream ?
From: Mathieu Champlon (mathieu.champlon_at_[hidden])
Date: 2011-02-02 05:14:43


On 02/02/2011 08:23, Frédéric Bron wrote:
> Could it be a problem of line ending (windows/linux)? Could you try
> with that version:
> http://www.boostpro.com/vault/index.php?action=downloadfile&filename=type_traits-dos.tar.bz2&directory=Extension&
>

I just tried and it gives the same error.

Actually it seems MSVC doesn't like "not", "or" and "and" : replacing
them with "!", "||" and "&&" makes the error (and the warning) go away.

However next, the following code :
     BOOST_STATIC_ASSERT(( boost::has_operator_left_shift< int, int
>::value ));

Yields the rather non-informative error :
..... the code ..... : error C4430: missing type specifier - int
assumed. Note: C++ does not support default-int
(yes that's the only line in the error trace...)

And :
     BOOST_STATIC_ASSERT(( boost::has_operator_left_shift< std::ostream,
int >::value ));

Adds a warning on top of the same error :

boost/type_traits/detail/has_binary_operator.hpp(106) : warning C4913:
user defined binary operator ',' exists but no overload could convert
all operands, default built-in binary operator ',' used
         boost/type_traits/detail/has_binary_operator.hpp(142) : see
reference to class template instantiation
'boost::detail::has_operator_left_shift_impl::has_operator_left_shift_impl<LHS,RHS,RET>'
being compiled
         with
         [
             LHS=std::ostream,
             RHS=int,
             RET=void
         ]
         ..... the code ..... : see reference to class template
instantiation 'boost::has_operator_left_shift<LHS,RHS>' being compiled
         with
         [
             LHS=std::ostream,
             RHS=int
         ]
..... the code ..... : error C4430: missing type specifier - int
assumed. Note: C++ does not support default-int

I will try and have another look later today, do you have any idea where
the problem might be ?

>> However it doesn't work with a pointer type, for instance this fails :
>> BOOST_STATIC_ASSERT(( boost::has_operator_left_shift< std::ostream, void*::value ));
> Can you say what you mean by it doesn't work? Do you mean compile
> error or returns the wrong value?
>

Sorry, I meant the assertion fails.

Another case which doesn't compile however is :

     struct convertible_ambiguous
     {
         operator int() const;
         operator float() const;
     };
     BOOST_STATIC_ASSERT(( boost::has_operator_left_shift< std::ostream,
convertible_ambiguous >::value ));

Thanks !
MAT.


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