[fusion]push_back<list<>,int> > fails compilation
The code in the 1st attachment fails to compile as shown in 2nd attachment. If that's intended, the what's the justification for not allowing appending to an empty sequence? If that's not intended, then should I file a bug report? Based on: <fusion.doc>/html/fusion/algorithm/transformation/functions/push_back.html it seems push_back should work on a 'Forward Sequence' and based on: <fusion.doc>/html/fusion/container/list.html list is a 'Forward Sequence'. And based on the following quote from the Synopsis of the list.html:
The variadic class interface accepts 0 to FUSION_MAX_LIST_SIZE elements
an empty list type, i.e. list<>, is a list, the attached code should compile. -regards Larry ###-*- mode: compilation; default-directory: "~/prog_dev/boost-svn/ro/trunk/libs/fusion/sandbox/" -*- Compilation started at Fri Jul 16 02:08:38 make HOW=gcc4_5n run install -d `dirname /home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/gcc4_5n/boost-svn/ro/trunk/libs/fusion/sandbox/list_push_back.o` /home/evansl/download/gcc/4.5-20100624/install/bin/g++ -c -Wall -ftemplate-depth-300 -O0 -g3 -fno-inline -std=gnu++0x -I/home/evansl/prog_dev/boost-svn/ro/trunk -DTEMPLATE_DEPTH=300 list_push_back.cpp -MMD -o /home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/gcc4_5n/boost-svn/ro/trunk/libs/fusion/sandbox/list_push_back.o list_push_back.cpp: In function 'void boost::fusion::sandbox::run()': list_push_back.cpp:25:45: error: no matching function for call to 'boost::fusion::joint_view<boost::fusion::list<>, const boost::fusion::single_view<int> >::joint_view(boost::fusion::result_of::push_back<const boost::fusion::list<>, int>::type)' /home/evansl/prog_dev/boost-svn/ro/trunk/boost/fusion/view/joint_view/joint_view.hpp:55:9: note: candidates are: boost::fusion::joint_view<Sequence1, Sequence2>::joint_view(Sequence1&, Sequence2&) [with Sequence1 = boost::fusion::list<>, Sequence2 = const boost::fusion::single_view<int>] /home/evansl/prog_dev/boost-svn/ro/trunk/boost/fusion/view/joint_view/joint_view.hpp:34:5: note: boost::fusion::joint_view<boost::fusion::list<>, const boost::fusion::single_view<int> >::joint_view(const boost::fusion::joint_view<boost::fusion::list<>, const boost::fusion::single_view<int> >&) make: *** [/home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/gcc4_5n/boost-svn/ro/trunk/libs/fusion/sandbox/list_push_back.o] Error 1 Compilation exited abnormally with code 2 at Fri Jul 16 02:08:40
Larry Evans schrieb:
The code in the 1st attachment fails to compile as shown in 2nd attachment. If that's intended, the what's the justification for not allowing appending to an empty sequence? If that's not intended, then should I file a bug report?
Based on:
<fusion.doc>/html/fusion/algorithm/transformation/functions/push_back.html
it seems push_back should work on a 'Forward Sequence' and based on:
<fusion.doc>/html/fusion/container/list.html
list is a 'Forward Sequence'. And based on the following quote from the Synopsis of the list.html:
The variadic class interface accepts 0 to FUSION_MAX_LIST_SIZE elements
an empty list type, i.e. list<>, is a list, the attached code should compile.
The problem boils down to fusion::push_back having a const-qualified sequence argument, whereas fusion::result_of::push_back passes its sequence argument right through to the fusion::joint_view . The documentation is misleading in this regard as the declaration of fusion::push_back in algorithm.qbk does not pass the const to fusion::result_of::push_back either. The actual code does so of course. typedef result_of::push_back<list_t0,int>::type denotes to fusion::joint_view<list_t0, fusion::single_view<int> const> whereas decltype(fusion::push_back(list_v0,1)) denotes to fusion::joint_view<list_t0 const, fusion::single_view<int> const> See https://svn.boost.org/trac/boost/ticket/3358 for more information. To fix your code, const-qualify the sequence argument of the fusion::result_of::push_back instantiation. BTW. the upcoming C++11 port of fusion fixes this by overloading all functions with both, const- and non-const qualified arguments. -Christopher
participants (2)
-
Christopher Schmidt
-
Larry Evans