[Boost-users] problem with enable_if_c and gcc4

8 views
Skip to first unread message

Lewis Hyatt

unread,
Oct 13, 2009, 5:42:27 PM10/13/09
to boost...@lists.boost.org
Hello Everyone-

The following code compiles fine with g++ 4.1.2 but does not compile with 4.4.1,
I get an error message saying the prototype does not match any declared in the
class. This happens both with Boost 1.40.0 and 1.33.1, on Debian (x86 64-bit).
Does anyone know what's up with this, is there some workaround? Thanks very much.

#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_same.hpp>

template<typename T>
struct A {
struct B {};
template<typename U>
typename boost::enable_if_c<
boost::is_base_of<B, U>::value &&
!boost::is_same<B,U>::value>
::type f(U&);
};

template<typename T>
template<typename U>
typename boost::enable_if_c<
boost::is_base_of<typename A<T>::B, U>::value &&
!boost::is_same<typename A<T>::B, U>::value>
::type A<T>::f(U&) {}

int main() {
}

t.cpp:20: error: prototype for 'typename
boost::enable_if_c<(boost::is_base_of::value && (! boost::is_same::value)),
void>::type A<T>::f(U&)' does not match any in class 'A<T>'
t.cpp:12: error: candidate is: template<class T> template<class U> typename
boost::enable_if_c<(boost::is_base_of::value && (! boost::is_same::value)),
void>::type A::f(U&)

-Lewis


_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Lewis Hyatt

unread,
Oct 14, 2009, 12:16:02 AM10/14/09
to boost...@lists.boost.org
Lewis Hyatt <lhyatt <at> gmail.com> writes:

>
> Hello Everyone-
>
> The following code compiles fine with g++ 4.1.2 but does not compile with
4.4.1,
> I get an error message saying the prototype does not match any declared in the
> class. This happens both with Boost 1.40.0 and 1.33.1, on Debian (x86 64-bit).
> Does anyone know what's up with this, is there some workaround?
> Thanks very much.

FYI it seems that replacing with the equivalent solution using enable_if instead
of enable_if_c works.

Reply all
Reply to author
Forward
0 new messages