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

  • Home
  • SEARCH
  • 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 7707113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:16:43+00:00 2026-06-01T00:16:43+00:00

I have a recursive data type like this: template<typename T> struct SomeType { std::map<T,

  • 0

I have a recursive data type like this:

template<typename T>
struct SomeType {
    std::map<T, SomeType<T>> mapping;
};

SomeType<int> foo;

This works fine, but replacing std::map with std::unordered_map results in a compile error due to an incomplete type. Am I (or gcc) making an error somewhere? or is this just part of the standard?

I would also like to have the internal container determined by a template parameter (like std::stack and std::queue), but I can’t figure out a way to do it since that would require SomeType to already be defined.

Incomplete example:

template<typename T, typename C = std::map<T, SomeType<[???]>>>
struct SomeType {
    C mapping;
};

SomeType<int, [???]> foo;

I know this can be done with runtime indirection, but that’s not what I’m looking for.

  • 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-01T00:16:44+00:00Added an answer on June 1, 2026 at 12:16 am

    Your class is incomplete anywhere before the final } of its definition. So the mapping member is using incomplete type SomeType in its type’s template arguments.

    The standard does not allow this, and it is pure luck that it works with some STL containers.

    Your second questions falls under the same answer — it is illegal to do that in the first place.

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

Sidebar

Related Questions

Imagine I have a recursive algebraic data type like this (Haskell syntax): data Expr
I have a data-structure (in plist) that looks something like this: What i have
I have this recursive method which deletes empty folders: private void DeleteEmpty(DirectoryInfo directory) {
i have this recursive code <ul> <% sql=SELECT * FROM cats ORDER BY orderid
I have a recursive immutable data structure in ocaml which can be simplified to
This question is more a semantic-algorithmic-data-structure question than a F# syntactically question. I have
I have a nested, mutual recursive data structure , and want to associate computational
I have a single table with a self reference InReplyTo with some data like
I have a large sequence of data-maps and each map needs to be classified
I have a template class btree and have defined a struct Node in 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.