Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2007-09-15 10:46:14


On 9/15/07, Tobias Schwinger <tschwinger_at_[hidden]> wrote:
>
> In this case it's sufficient to replace the above code with
>
> typedef std::string result_type;
>

Sorry but still does not compile:

bash-3.1$ g++ -Iboost_dir -o test main.cpp
boost_dir/boost/utility/result_of.hpp: In instantiation of
'boost::detail::result_of_nested_result<make_string, make_string
()(const int&, const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)>':
boost_dir/boost/utility/result_of.hpp:34: instantiated from
'boost::detail::result_of_impl<make_string, make_string ()(const int&,
const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&), false>'
boost_dir/boost/utility/result_of.hpp:27: instantiated from
'boost::result_of<make_string ()(const int&, const
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>&)>'
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp:41:
instantiated from
'boost::fusion::detail::fold_apply<boost::fusion::vector_iterator<const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>, 0>, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, make_string>'
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp:202:
instantiated from
'boost::fusion::detail::result_of_unrolled_fold<boost::fusion::vector_iterator<const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>, 0>, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, make_string, 2>'
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp:227:
instantiated from 'boost::fusion::detail::choose_fold<const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, make_string, true>'
boost_dir/boost/fusion/algorithm/iteration/fold.hpp:29: instantiated
from 'boost::fusion::result_of::fold<const boost::fusion::vector<int,
int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_>, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, make_string>'
main2.cpp:27: instantiated from here
boost_dir/boost/utility/result_of.hpp:68: error: wrong number of
template arguments (1, should be 2)
main2.cpp:12: error: provided for 'template<class T, class State>
struct make_string::result'
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp: In
instantiation of
'boost::fusion::detail::fold_apply<boost::fusion::vector_iterator<const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>, 0>, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, make_string>':
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp:202:
instantiated from
'boost::fusion::detail::result_of_unrolled_fold<boost::fusion::vector_iterator<const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>, 0>, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, make_string, 2>'
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp:227:
instantiated from 'boost::fusion::detail::choose_fold<const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, make_string, true>'
boost_dir/boost/fusion/algorithm/iteration/fold.hpp:29: instantiated
from 'boost::fusion::result_of::fold<const boost::fusion::vector<int,
int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_>, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, make_string>'
main2.cpp:27: instantiated from here
boost_dir/boost/fusion/algorithm/iteration/detail/fold.hpp:41: error:
no type named 'type' in 'struct boost::result_of<make_string ()(const
int&, const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)>'
main2.cpp: In function 'int main(int, char**)':
main2.cpp:27: error: no matching function for call to 'fold(const
boost::fusion::vector<int, int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_>&, std::string, make_string)'
bash-3.1$

The test now is:

struct make_string
{
   template<typename T, typename State>
   struct result
   {
       typedef std::string result_type;
   };

   template<typename T>
   std::string operator()(const T& t, const std::string& str) const
   {
       return str + boost::lexical_cast<std::string>(t);
   }
};

int main(int argc, char* argv[]) {
       const vector<int,int> vec(1,2);
       assert(fold(vec,std::string(""), make_string()) == "12");
       return 0;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk