
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