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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:27:39+00:00 2026-05-26T03:27:39+00:00

The C++ Language Standard states the following concerning template components in the Standard Library:

  • 0

The C++ Language Standard states the following concerning template components in the Standard Library:

The effects are undefined…if an incomplete type is used as a template argument when instantiating a template component, unless specifically allowed for that component (C++11 §17.6.4.8/2).

Does the following cause instantiation of the std::vector class template?

class X;
std::vector<X> f(); // Declaration only; we will define it when X is complete

To ask it another way, in the function declaration std::vector<X> f();, is std::vector instantiated with the argument X? Or, is std::vector<X> not instantiated until f() is odr-used or defined?

Likewise, does the following cause instantiation of the std::vector class template?

class X;
typedef std::vector<X> XVector; // We will complete X before we use XVector

While I use std::vector in these examples, the question applies equally to all templates.

  • 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-26T03:27:39+00:00Added an answer on May 26, 2026 at 3:27 am

    § 14.7.1\1 Implicit instantiation [temp.inst]

    Unless a class template specialization has been explicitly
    instantiated (14.7.2) or explicitly specialized (14.7.3), the class
    template specialization is implicitly instantiated when the
    specialization is referenced in a context that requires a
    completely-defined object type or when the completeness of the class
    type affects the semantics of the program.
    The implicit instantiation
    of a class template specialization causes the implicit instantiation
    of the declarations, but not of the definitions or default arguments,
    of the class member functions, member classes, static data members and
    member templates; and it causes the implicit instantiation of the
    definitions of member anonymous unions. Unless a member of a class
    template or a member template has been explicitly instantiated or
    explicitly specialized, the specialization of the member is implicitly
    instantiated when the specialization is referenced in a context that
    requires the member definition to exist;
    in particular, the
    initialization (and any associated side-effects) of a static data
    member does not occur unless the static data member is itself used in
    a way that requires the definition of the static data member to exist.

    § 8.3.5\9 Functions [dcl.fct]

    Types shall not be defined in return or parameter types. The type of a
    parameter or the return type for a function definition shall not be an
    incomplete class type (possibly cv-qualified) unless the function
    definition is nested within the member-specification for that class
    (including definitions in nested classes defined within the class).

    § 3.1\2 Declarations and definitions [basic.def]

    A declaration is a definition unless it declares a function without
    specifying the function’s body (8.4),
    it contains the extern specifier
    (7.1.1) or a linkage-specification25 (7.5) and neither an initializer
    nor a function-body, it declares a static data member in a class
    definition (9.4), it is a class name declaration (9.1), it is an
    opaque-enum-declaration (7.2), or it is a typedef declaration (7.1.3),
    a using-declaration (7.3.3), a static_assert-declaration (Clause 7),
    an attribute-declaration (Clause 7), an empty-declaration (Clause 7),
    or a using-directive (7.3.4).

    It’s only instantiated if it’s required. I couldn’t find a clear definition anywhere, but the second quote says that those declaratations are not definitions, which seems to be the same to me.

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

Sidebar

Related Questions

My project (an interpreted language) has a standard library composed by multiple files, each
Many languages and frameworks offer a byte array type, but the C++ standard library
The C++ standard (ISO/IEC 14882:03) states the following ( 2.11 / 2 ): Furthermore,
I'm looking for a standard markup language to transmit addresses (locations). I really need
I am reading the IEEE Standard Verilog Hardware Description Language (specifically IEEE Std 1364-2001)
Stroustrup states in C++ Language book that order of definitions in the class does
I can't find an answer in the standard documentation. Does the C++ language standard
I'm looking for a programming language that has the following features: First-class functions and
The C++ Programming Language : Special Edition states on page 431 that... For every
In C is it undefined behaviour to call a 3rd party library function (not

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.