سؤال

وكيفية توليد fusion::vector من mpl::vector؟ كيفية توليد mpl::vector من fusion::vector؟

BOOST_MPL_ASSERT((is_same<
                  fusion::vector<int, char>,
                  generate_fusion_vector<mpl::vector<int, char> >::type >));

BOOST_MPL_ASSERT((is_same<
                  mpl::vector<int, char>,
                  generate_mpl_vector<fusion::vector<int, char> >::type >));

وأحتاج generate_fusion_vector وgenerate_mpl_vector metafunctions. أستطيع أن أكتب metafunctions بلدي، ولكن أظن أنها موجودة بالفعل.

وكان لي تجربة لتوليد fusion::map بمساعدة result_of::as_map قبل، ولكن في دفعة الحالي (الجذع، 1.39 أيضا) مثل هذا الخطأ يحدث:

D:\Libraries\boost_trunk\boost/fusion/sequence/intrinsic/size.hpp(56) : error C2903: 'apply' : symbol is neither a class template nor a function template
        D:\Libraries\boost_trunk\boost/fusion/container/vector/convert.hpp(23) : see reference to class template instantiation 'boost::fusion::result_of::size' being compiled
        with
        [
            Sequence=boost::mpl::vector
        ]
        temp.cpp(71) : see reference to class template instantiation 'boost::fusion::result_of::as_vector' being compiled

وأنا لا أفهم ما الذي يجري؟

هل كانت مفيدة؟

المحلول

وكما يقبل الانصهار أنواع MPL كوسائط إلى الوظائف التي يمكن أن تحاول هذه:

BOOST_MPL_ASSERT((is_same<
fusion::vector<int, char>,
fusion::result_of::as_vector<mpl::vector<int, char> >::type >));

وتحرير:

وأعتقد أن السبب في هذا لا يعمل بالنسبة لك هو أن لديك لتشمل بعض الملفات رأس لتمكين التوافق MPL في الانصهار.

#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/include/mpl.hpp>

نصائح أخرى

وأنا لا أعرف ما إذا كنت لا تزال تفعل شار، الباحث لكنني واجهت نفس الخطأ وكان مشكلتي أنني حاولت أن تجعل ناقل طول 11، ولكن كان FUSION_MAX_VECTOR_SIZE 10.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top