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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:29:28+00:00 2026-05-13T05:29:28+00:00

Often I face the problem of mapping the parameter space of one API onto

  • 0

Often I face the problem of mapping the parameter space of one API onto the parameter space of another one. Often I see this solved by nested nested nested … switch statements.

And I was wondering if there would happen to be a library or a technique that allows you to ‘declare’ the mapping instead of ‘program’ it.

A trivial example would consist of merging the values of two enumerates into one:

namespace sourceAPI {
  struct A { typedef e { A1, A2, A3 } };
  struct B { typedef e { B1, B2 } };
}

namespace targetAPI {
  struct AB { typedef e { A1B1, A1B2, A2B1, A2B2, A3B1, A3B2 } };
}

In which the mapping is often done like

switch( a ){
  case( A::A1 ): switch( b ) {
     case( B::B1 ): return A1B1;
     case( B::B2 ): return A1B2;
     ....
}

And this mapping still needs a ‘reverse’ switch, too.

But I would rather like something ‘dense’ like

declare( source( A::A1, B::B1 ), target( AB::A1B1 ) );
declare( source( A::A1, B::B2 ), target( AB::A1B2 ) );
....

Has anyone seen such a technique or framework or library?

  • 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-13T05:29:28+00:00Added an answer on May 13, 2026 at 5:29 am

    You can use Boost.Bimap, which provides a bidirectional mapping between two types.

    It has a bit of runtime overhead (generally, roughly the same amount of overhead you would get by using a pair of std::maps for this purpose, which isn’t a whole lot).

    It does allow you to define mappings about as densely as your example, though; generally you just add pairs to the map, one pair at a time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading another question on Stack Overflow ( Zen of Python ), and
Often when creating a new web app and configuring MySQL, certain fields will need
Often when I install .exe files made from python files I get an installation
Often I add helper functions to my PHP that return complex HTML. For example,
Often I find myself having a expression where a division by int is a
Often, I will have an array holding a set of values each of which
Often a user will misuse a Rich Internet Application, and attempt to use the
Often while coding view templates in html, my habit of adding some helpful comments
I've recently became interested in proper OOP design in web applications. I think I
I am using fckEditor as text editor. When i upload images thru it the

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.