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 688215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:12:25+00:00 2026-05-14T02:12:25+00:00

I need to create a map, from integers to sets of tuples, the tuples

  • 0

I need to create a map, from integers to sets of tuples, the tuples in a single set have the same size. The problem is that the size of a tuple and its parameter types can be determined at runtime, not compile time. I am imagining something like:

std::map<int, std::set<boost::tuple> >

but not exctly sure how to exactly do this, bossibly using pointers.

The purpose of this is to create temporary relations (tables), each with a unique identifier (key), maybe you have another approach.

  • 1 1 Answer
  • 1 View
  • 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-05-14T02:12:26+00:00Added an answer on May 14, 2026 at 2:12 am

    The purpose of boost::tuple is to mix arbitrary types. If, as you say,

    I am only inserting integers

    then you should use map< int, set< vector< int > > >. (If I were you, I’d throw some typedefs at that.)

    To answer the original question, though, boost::tuple doesn’t allow arbitrary types at runtime. boost::any does. However, any does not support comparison so there’s a little more work if you want to use it in a set.

    typedef vector< boost::any > tuple;
    struct compare_tuple { bool operator()( tuple const &l, tuple const &r ) const {
        assert ( l.size() == r.size() );
    
        for ( tuple::iterator lit = l.begin(), rit = r.begin();
              lit != l.end(); ++ lit, ++ rit ) {
            assert ( lit->type() == rit->type() );
    
            if ( lit->type() == typeid( foo ) ) { // find the type and perform "<"
                return boost::any_cast<foo>(*lit) < boost::any_cast<foo>(*rit);
            } else if ( lit->type() == typeid( bar ) ) {
                return boost::any_cast<bar>(*lit) < boost::any_cast<bar>(*rit);
            } /* etc; you will need to enumerate all the types you can insert */
        }
    } };
    
    typedef std::map< int, std::set< tuple, compare_tuple > > main_map;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple classes that I need to map into 1 class: This is
I need to create windows service that would: download some files from uri (google.com,
I need to create windows service that would: download some files from uri (google.com,
I need to create a map/array for auto complete from a JSON response and
I have 1 class that I need t map into multiple classes, for eg.
I need to create a map that can contain as its value any basic
I have been using Java's ConcurrentMap for a map that can be used from
I need to create an array of arrays. I have been using array_map(null,$a,$b,$c) to
In data processing, I frequently need to create a lookup data structure to map
I need to create a historical timeline starting from 1600's to the present day.

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.