Boost logo

Boost Users :

From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2007-12-19 03:19:57


I've encountered fusion's behavior that
seems to be a bug.

#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>

#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/iterator/next.hpp>

struct s { int m; };
BOOST_FUSION_ADAPT_STRUCT(s, (int, m))

int main()
{
  using namespace boost::fusion;
  using boost::is_same;

  typedef result_of::begin<s>::type b;
  typedef result_of::end<s>::type e;
  // this fails
  BOOST_MPL_ASSERT((is_same<result_of::next<b>::type, e>));
}

Here is a patch against trunk:

Index: end_impl.hpp
===================================================================
--- end_impl.hpp (revision 42137)
+++ end_impl.hpp (working copy)
@@ -8,6 +8,7 @@
 #if !defined(BOOST_FUSION_END_IMPL_24122005_1755)
 #define BOOST_FUSION_END_IMPL_24122005_1755
 
+#include <boost/fusion/adapted/struct/extension.hpp>
 #include <boost/fusion/adapted/struct/struct_iterator.hpp>
 
 namespace boost { namespace fusion
@@ -25,7 +26,7 @@
             template <typename Sequence>
             struct apply
             {
- typedef struct_iterator<Sequence, 2> type;
+ typedef struct_iterator<Sequence,
struct_size<Sequence>::value> type;
 
                 static type
                 call(Sequence& v)

Regards,
Roman Perepelitsa.


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