From 88e7b625f37617a52e0dcb6a76fe8a7ed30fb296 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Wed, 17 Apr 2002 02:25:46 +0000 Subject: [PATCH] for_each changes [SVN r13513] --- include/boost/python/class.hpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index 61ba75a1..c6bf00a7 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -195,8 +195,7 @@ class class_ : public objects::class_base ids[0] = converter::undecorated_type_id(); // Write the rest of the elements into succeeding positions. - class_id* p = ids + 1; - mpl::fold::execute(&p); + mpl::for_each(detail::write_type_id(ids + 1)); } BOOST_STATIC_CONSTANT( @@ -238,25 +237,21 @@ inline class_::class_(char const* name) namespace detail { - // This is an mpl BinaryMetaFunction object with a runtime behavior, - // which is to write the id of the type which is passed as its 2nd - // compile-time argument into the iterator pointed to by its runtime - // argument + // A function object that on each invocation writes the id of + // the type 'T' into the iterator passed to it in the constructor struct write_type_id { - // The first argument is Ignored because mpl::for_each is still - // currently an accumulate (reduce) implementation. - template struct apply - { - // also an artifact of accumulate-based for_each - typedef void type; + write_type_id(converter::undecorated_type_id_t* iter) + : m_iter(iter) + {} - // Here's the runtime behavior - static void execute(converter::undecorated_type_id_t** p) - { - *(*p)++ = converter::undecorated_type_id(); - } + template void operator()(boost::mpl::identity) + { + *m_iter++ = converter::undecorated_type_id(); }; + + private: + converter::undecorated_type_id_t* m_iter; };