Boost logo

Boost Users :

From: Martin Ecker (martin.ecker_at_[hidden])
Date: 2007-09-28 02:09:13


Hello,

I'm running into a problem when using boost::result_of with gcc 3.4.2
and 4.2.1 (with MingW).

The following program compiles fine with Visual C++ 8.0, but not with gcc:

-------------------------------
#include <boost/utility/result_of.hpp>

struct test_function1
{
     template <typename SignatureT>
     struct result;

     template <typename T>
     struct result<test_function1 (T)>
     {
         typedef T type;
     };

     template <typename T>
     T operator () (T t) const
     {
         return t;
     }
};

template <typename ArgT>
struct test_function2
{
     template <typename SignatureT>
     struct result;

     template <typename T>
     struct result<test_function2 (T)>
     {
         typedef T type;
     };

     template <typename T>
     T operator () (T t) const
     {
         return t;
     }
};

int main(int argc, char *argv[])
{
     typedef boost::result_of<
         test_function1(int)>::type result_type;
     typedef boost::result_of<
         test_function2<float>(int)>::type result_type;
     return 0;
}
-------------------------------

The error message I get is for the second typedef using test_function2:

E:/Projects/Third Party/boost/boost/utility/result_of.hpp: In
instantiation of
`boost::detail::result_of_nested_result<test_function2<float>,
test_function2<float> ()(int)>':

E:/Projects/Third Party/boost/boost/utility/result_of.hpp:75:
instantiated from
`boost::detail::result_of_impl<test_function2<float>,
test_function2<float> ()(int), false>'
E:/Projects/Third
Party/boost/boost/utility/detail/result_of_iterate.hpp:24:
instantiated from `boost::result_of<test_function2<float> ()(int)>'
main.cpp:43: instantiated from here
E:/Projects/Third Party/boost/boost/utility/result_of.hpp:68: error:
invalid use of undefined type `struct
test_function2<float>::result<test_function2<float> ()(int)>'

I get the same error if I simply wrap test_function1 in another
template class as nested struct and then use it instead of test_function2.

Am I attempting to do something fundamentally wrong here, or is it a
bug in gcc?

Thanks,
Martin


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