Boost logo

Boost Users :

From: Pavel Antokolsky aka Zigmar (zigmar_at_[hidden])
Date: 2007-01-24 12:52:48


Hello!
I'm trying to use function_traits but it fails to compile. It seems
like the add_pointer is somehow related to the error, as using the
helper struct directly (and thus avoiding add_pointer on supplied
type) compiles ok. I'm using boost 1.30.2 with g++ 3.2.2 on linux.

The minimal example is:
#include <boost/type_traits/function_traits.hpp>

int foo() {}

template<typename T>
void bar(T f) {
        typedef typename boost::function_traits<T>::result_type X; //fails to compile
        typedef typename boost::detail::function_traits_helper<T>::result_type Y; //OK
        
}

int main(int argc, char** argv) {
        bar(foo);
}

The compiler output is:
$ g++ func_traits.cpp
func_traits.cpp: In instantiation of `boost::function_traits<int (*)()>':
func_traits.cpp:7: instantiated from `void bar(T) [with T = int (*)()]'
func_traits.cpp:13: instantiated from here
func_traits.cpp:7: base class `boost::detail::function_traits_helper<int
   (**)()>' has incomplete type
func_traits.cpp: In function `void bar(T) [with T = int (*)()]':
func_traits.cpp:13: instantiated from here
func_traits.cpp:7: no type named `result_type' in `struct
   boost::function_traits<int (*)()>'

Is I'm using function_traits wrong or there is something wrong with
the implementation?

And another small thing that looks a bit strange to me: for some
reason boost/type_traits.hpp does not link
boost/type_traits/function_traits.hpp, but it never mentioned in
documentation.

-- 
Best regards,
Zigmar

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