Boost logo

Boost :

Subject: Re: [boost] [mpl] [type_traits] [enable_if] Overloading Problem with GCC 3.3.3
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2009-12-08 15:24:17


On Tue, 8 Dec 2009, Stewart, Robert wrote:

> Can anyone figure out why GCC 3.3.3 doesn't like the following member function overloads? VC7/8/9 and GCC 4.1.2 have no problems with this code.
>
> #include <boost/mpl/and.hpp>
> #include <boost/mpl/not.hpp>
> #include <boost/type_traits/is_const.hpp>
> #include <boost/type_traits/is_convertible.hpp>
> #include <boost/utility/enable_if.hpp>
>
> struct Bar
> {
> };
>
> template <class T>
> struct Baz
> {
> };
>
> struct Foo
> {
> template <class T>
> typename boost::enable_if
> <
> boost::mpl::and_
> <
> boost::is_convertible<T,Bar>
> , boost::mpl::not_<boost::is_const<T> >
> >
> >::type
> set(Baz<T> const & _value);
>
> template <class T>
> typename boost::enable_if
> <
> boost::mpl::and_
> <
> boost::is_convertible<T,Bar>
> , boost::is_const<T>
> >
> >::type
> set(Baz<T> const &);
> };
>
> GCC 3.3.3's error message is:
>
> error: `template<class T> typename
> boost::enable_if<boost::mpl::and_<boost::is_convertible<T, Bar>,
> boost::is_const<T>, mpl_::bool_<true>, mpl_::bool_<true>, mpl_::bool_<true>
> >, void>::type Foo::set(const Baz<T>&)' and `template<class T> typename
> boost::enable_if<boost::mpl::and_<boost::is_convertible<T, Bar>,
> boost::mpl::not_<boost::is_const<T> >, mpl_::bool_<true>, mpl_::bool_<true>,
> mpl_::bool_<true> >, void>::type Foo::set(const Baz<T>&)' cannot be
> overloaded

The functions are too similar for GCC 3.3. Please look at Section 3.4 of
http://www.boost.org/doc/libs/1_41_0/libs/utility/enable_if.html for more
information and workarounds.

-- Jeremiah Willcock


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk