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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:16:36+00:00 2026-06-11T09:16:36+00:00

I have a class which looks something like this. I’d prefer to have the

  • 0

I have a class which looks something like this. I’d prefer to have the typedef of ParentMember in the Parent class and rename it Member. How might this be possible? The only way I can see is to have std::vector as a public member instead of using inheritance.

typedef std::pair<std::string, boost::any> ParentMember;
class Parent: public std::vector<ParentMember>
{
public:
    template <typename T>
    std::vector<T>& getMember(std::string& s)
    {
        MemberFinder finder(s);
        std::vector<ParentMember>::iterator member = std::find_if(begin(), end(), finder);
        boost::any& container = member->second;
        return boost::any_cast<std::vector<T>&>(container);
    }
private:
    class Finder
    {
      ...
    };
};
  • 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-11T09:16:37+00:00Added an answer on June 11, 2026 at 9:16 am

    The only way I can see is to have std::vector as a public member instead of using inheritance.

    Yeah… that’s The Correct Way™.

    Now let’s assume the class in question is not std::vector but something else, which would make this a legitimate question.

    One solution is to use the non-typedef version for the base class and then typedef it

    class Parent
      : public std::vector<std::pair<std::string, boost::any>>
    {
    public:
      typedef std::pair<std::string, boost::any> Member;
      // ...
    };
    

    In case of std::vector as a base class, it even exposes the type as a nested value_type typedef, which would allow you to make sure the two are never different:

    typedef value_type Member; // value_type inherited from std::vector
    

    If your Parent class is a template itself, you would need

    typedef typename Parent::value_type Member;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function which looks something like this, it returns a noncopyable class
Suppose I have an autolocker class which looks something like this: template <T> class
I have a base class which looks something like this: class Base { public:
I have an object which looks something like this class MyObject { string Name;
I have a struts2 action class which looks something like this: //import relevant packages
I have a model, Rating , which looks something like this: class Rating(models.Model): upvotes
I have a class which looks something like this: public class Test { private
I have a class which looks something like this: class MyClass { public: //
I have a RentalProperty class which looks something like this: class RentalProperty { Money
Suppose I have a function which looks like this: template <class In, class In2>

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.