|
Boost Users : |
From: Tim Robertson (timr_at_[hidden])
Date: 2006-09-05 19:45:31
Hi,
Can anyone explain why the following won't compile (using g++ 3.3.2
under Linux):
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
using namespace std;
struct Foo
{
Foo() {}
template <typename T>
Foo(T const & src,
typename boost::enable_if<
boost::is_convertible<T,Foo>, void >::type * dummy = 0)
{
int i = 1; // filler.
}
template <typename T>
Foo(T const & src,
typename boost::disable_if<
boost::is_convertible<T,Foo>, void >::type * dummy = 0)
{
int i = 2; // ditto.
}
};
int main()
{
Foo f;
Foo f2(f);
return 0;
};
When I attempt to compile this code with g++ 3.3.2, I get the following
error messages:
/boost/boost/type_traits/is_convertible.hpp: In instantiation of
`boost::disable_if<boost::is_convertible<Foo, Foo>, void>':
/boost/boost/type_traits/is_convertible.hpp:128: instantiated from
`boost::detail::is_convertible_basic_impl<Foo&, Foo>'
/boost/boost/type_traits/is_convertible.hpp:228: instantiated from
`boost::detail::is_convertible_impl<Foo, Foo>'
test.cpp:36: instantiated from
`boost::detail::is_convertible_impl_dispatch<Foo, Foo>'
test.cpp:36: instantiated from `boost::is_convertible<Foo, Foo>'
test.cpp:36: instantiated from
`boost::enable_if<boost::is_convertible<Foo, Foo>, void>'
test.cpp:36: instantiated from here
/boost/boost/type_traits/is_convertible.hpp:128: error: `value'
is not a member of type `boost::is_convertible<Foo, Foo>'
/boost/boost/type_traits/is_convertible.hpp: In instantiation of
`boost::detail::is_convertible_basic_impl<Foo&, Foo>':
/boost/boost/type_traits/is_convertible.hpp:228: instantiated from
`boost::detail::is_convertible_impl<Foo, Foo>'
test.cpp:36: instantiated from
`boost::detail::is_convertible_impl_dispatch<Foo, Foo>'
test.cpp:36: instantiated from `boost::is_convertible<Foo, Foo>'
test.cpp:36: instantiated from
`boost::enable_if<boost::is_convertible<Foo, Foo>, void>'
test.cpp:36: instantiated from here
/boost/boost/type_traits/is_convertible.hpp:128: error:
initializing argument 1 of `static yes_type
boost::detail::checker<T>::_m_check(T, int) [with T = Foo]'
If I use boost::is_same<> in place of boost::is_convertible<>,
everything is fine. Is there something that I'm missing, or is this a bug?
Thanks in advance,
Tim
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