Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8468039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:49:11+00:00 2026-06-10T15:49:11+00:00

I’m looking for a way to create a Boost.Fusion sequence wrapper that is itself

  • 0

I’m looking for a way to create a Boost.Fusion sequence wrapper that is itself a Fusion sequence and forwards all ‘calls’ to its wrapped sequence. Something in the lines of

template< typename Sequence >
struct sequence_wrapper
{
    explicit sequence_wrapper( Sequence const& s ) : seq( s ){}

    Sequence seq;
};

where sequence_wrapper< Sequence > is a Fusion sequence as well, and works just as Sequence would. The reason I need this is that I have several functions that operate on Fusion sequences (where all elements satisfy some special requirements), and I would like to add some syntax sugar for which I need a custom type to add overloaded operators to. I do not need the result of operations on a sequence_wrapper to return a sequence_wrapper as well, only the syntax sugar related calls would return a (manually) wrapped sequence. For instance, appending elements to a sequence using the comma operator (somewhat of a Boost.Assign for Fusion sequences):

template< typename Sequence, typename T >
sequence_wrapper<
    typename boost::fusion::result_of::push_back<
        Sequence const&
      , T
    >::type
> operator ,( Sequence const& seq, T const& v )
{
    return
        sequence_wrapper<
            typename boost::fusion::result_of::push_back<
                Sequence const&
              , T
            >::type
        >( boost::fusion::push_back( seq, v ) )
        ;
}

What would be the best way to achieve this (if it is indeed supported by the library)? I’m particularly trying to avoid creating a Fusion sequence from scratch, as I would like to use whatever sequence is returned by Fusion operations. Would inheritance + specialization of tag_of to return the tag of the wrapped sequence just work? Or will I need to define a tag of my own and implement all required functions to just forward the call?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:49:13+00:00Added an answer on June 10, 2026 at 3:49 pm

    This is what I ended up doing:

    template<
        typename Derived
      , typename Sequence
      , typename TraversalTag = 
            typename boost::fusion::traits::category_of< Sequence >::type
      , typename IsView =
            typename boost::fusion::traits::is_view< Sequence >::type
    >
    class fusion_sequence_wrapper
      : public boost::fusion::sequence_facade< Derived, TraversalTag, IsView >
    {
        typedef Sequence base_sequence_type;
    
    public:
        explicit fusion_sequence_wrapper( base_sequence_type const& sequence )
          : _seq( sequence )
        {}
    
        base_sequence_type const& base() const
        {
            return _seq;
        }
        base_sequence_type& base()
        {
            return _seq;
        }
    
    public:
        template< typename Seq >
        struct begin
        {
            typedef
                typename boost::fusion::result_of::begin<
                    typename boost::mpl::if_<
                        boost::is_const< Seq >
                      , base_sequence_type const
                      , base_sequence_type
                    >::type
                >::type type;
    
            static type call( Seq& s ){ return boost::fusion::begin( s._seq ); }
        };
    
        template< typename Seq >
        struct end
        {
            typedef
                typename boost::fusion::result_of::end<
                    typename boost::mpl::if_<
                        boost::is_const< Seq >
                      , base_sequence_type const
                      , base_sequence_type
                    >::type
                >::type type;
    
            static type call( Seq& s ){ return boost::fusion::end( s._seq ); }
        };
    
        template< typename Seq >
        struct size
        {
            typedef
                typename boost::fusion::result_of::size<
                    typename boost::mpl::if_<
                        boost::is_const< Seq >
                      , base_sequence_type const
                      , base_sequence_type
                    >::type
                >::type type;
    
            static type call( Seq& s ){ return boost::fusion::size( s._seq ); }
        };
    
        template< typename Seq >
        struct empty
        {
            typedef
                typename boost::fusion::result_of::empty<
                    typename boost::mpl::if_<
                        boost::is_const< Seq >
                      , base_sequence_type const
                      , base_sequence_type
                    >::type
                >::type type;
    
            static type call( Seq& s ){ return boost::fusion::empty( s._seq ); }
        };
    
        template< typename Seq, typename N >
        struct at
        {
            typedef
                typename boost::fusion::result_of::at<
                    typename boost::mpl::if_<
                        boost::is_const< Seq >
                      , base_sequence_type const
                      , base_sequence_type
                    >::type
                  , N
                >::type type;
    
            static type call( Seq& s ){ return boost::fusion::at( s._seq ); }
        };
    
        template< typename Seq, typename N >
        struct value_at
        {
            typedef
                typename boost::fusion::result_of::value_at<
                    typename boost::mpl::if_<
                        boost::is_const< Seq >
                      , base_sequence_type const
                      , base_sequence_type
                    >::type
                  , N
                >::type type;
        };
    
    private:
        base_sequence_type _seq;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.