Hello, The example at the bottom of: http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/... does not compile; I am using MinGw 3.4.2. #include <iostream> #include <boost/fusion/sequence.hpp> #include <boost/fusion/algorithm.hpp> using namespace boost::fusion; struct square { template <typename T> struct result { typedef int type; }; template <typename T> int operator()(T x) const { return x * x; } }; typedef vector<int, short, double> vector_type; int main (int argc, char ** argv) { vector_type vec(2, 5, 3.3); transform_view<vector_type, square> transform(vec, square()); std::cout << transform << std::endl; // return 0; } More specifically it is the line std::cout << transform << std::endl; that seems to create the problem. I was also wondering why operator() of square return int and not T. Thanks
John Christopher wrote:
Hello, The example at the bottom of: http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/... does not compile; I am using MinGw 3.4.2.
[snip]
More specifically it is the line std::cout << transform << std::endl;
Works fine for me. See attached.
that seems to create the problem. I was also wondering why operator() of square return int and not T.
Yes, it should be T. Noted. Thanks for spotting that. It's corrected in the cpp file I just sent. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include <iostream> #include <boost/fusion/sequence.hpp> #include <boost/fusion/algorithm.hpp> struct square { template <typename T> struct result { typedef T type; }; template <typename T> T operator()(T x) const { return x * x; } }; int main() { using namespace boost::fusion; typedef vector<int, short, double> vector_type; vector_type vec(2, 5, 3.3); transform_view<vector_type, square> transform(vec, square()); std::cout << transform << std::endl; return 0; }
Joel de Guzman wrote:
John Christopher wrote:
Hello, The example at the bottom of: http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/...
does not compile; I am using MinGw 3.4.2.
[snip]
More specifically it is the line std::cout << transform << std::endl;
Works fine for me. See attached.
that seems to create the problem. I was also wondering why operator() of square return int and not T.
Yes, it should be T. Noted. Thanks for spotting that. It's corrected in the cpp file I just sent.
Oh and BTW, I tried it on VC7.1, VC8.0 and g++3.4. Cheers, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Joel, That's right, I changed int to T twice in the square class (int struct result and in operator ()) and it now works fine. Thanks "Joel de Guzman" <joel@boost-consulting.com> wrote in message news:e36k1g$2u0$2@sea.gmane.org...
Joel de Guzman wrote:
John Christopher wrote:
Hello, The example at the bottom of: http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/...
does not compile; I am using MinGw 3.4.2.
[snip]
More specifically it is the line std::cout << transform << std::endl;
Works fine for me. See attached.
that seems to create the problem. I was also wondering why operator() of square return int and not T.
Yes, it should be T. Noted. Thanks for spotting that. It's corrected in the cpp file I just sent.
Oh and BTW, I tried it on VC7.1, VC8.0 and g++3.4.
Cheers, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
participants (2)
-
Joel de Guzman
-
John Christopher