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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:37:31+00:00 2026-05-27T12:37:31+00:00

When looking for a solution to this question , I found the this thread

  • 0

When looking for a solution to this question, I found the this thread on another forum, which says that the standard requires all template parameters to STL-Datastructure to be fully defined. This means producing a structure which stores elements of the it’s own type within itself invokes undefined behavior. However as far as I can tell this is not caught for most pre-C++11 datastructure (i.e. std::vector, std::map etc.).

What actually could be the problem of using incomplete types within STL-Datastructures? Or more exactely what potential danger could the following code cause:

#include <stdint.h>
#include <map>

struct Test {
  std::map<uint32_t, Test> m_map1;
};

int main() {
  return 1;
}

Or is this one of those issues, where this code might not compile with some STL-Implementations, but if it does compile, you can be sure that it works?

  • 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-05-27T12:37:31+00:00Added an answer on May 27, 2026 at 12:37 pm

    The short answer is: because the standard says so. More generally,
    depending on the implementation, and what each type and function does,
    instantiating a template may require a complete definition. The authors
    of the standard either didn’t want to, or didn’t have time to analyse
    and specify in detail in what cases they didn’t want to require complete
    definitions, and settled for a blanket statement. Note too that when
    the standard was written, there was relatively little experience with
    STL, and one could be sure that there wasn’t some clever optimization
    which would require an instance of the argument type within a class;
    rather than risk banning such an optimization, it seemed safer to
    require a complete type.

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

Sidebar

Related Questions

I've been looking around for a solution to this thing but I haven't found
I hope that this question hasn't been asked already, but I was looking for
This question is related to another question that I posted on SO earlier How
I'm not sure that's the right plattform asking this question. I'm searching a solution
I was looking around and found no solution to this. I´d be glad if
I guess this question was asked in one way or another, but I'm looking
I'm looking for a quick-and-dirty solution to this, I have to set up a
I'm looking for a nice tight regex solution to this problem. I'm looking to
I hope this is the proper location to ask this question which is the
I've looked at various Q&As on SO similar to this question but haven't found

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.