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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:12:05+00:00 2026-06-14T13:12:05+00:00

We know that T v(x); is called direct-initialization , while T v = x;

  • 0

We know that T v(x); is called direct-initialization, while T v = x; is called copy-initialization, meaning that it will construct a temporary T from x that will get copied / moved into v (which is most likely elided).

For list-initialization, the standard differentiates between two forms, depending on the context. T v{x}; is called direct-list-initialization while T v = {x}; is called copy-list-initialization:

§8.5.4 [dcl.init.list] p1

[…] List-initialization can occur in direct-initialization or copy-initialization
contexts; list-initialization in a direct-initialization context is called direct-list-initialization and list-initialization in a copy-initialization context is called copy-list-initialization. […]

However, there are only two more references each in the whole standard. For direct-list-initialization, it’s mentioned when creating temporaries like T{x} (§5.2.3/3). For copy-list-initialization, it’s for the expression in return statements like return {x}; (§6.6.3/2).

Now, what about the following snippet?

#include <initializer_list>

struct X{
  X(X const&) = delete; // no copy
  X(X&&) = delete; // no move
  X(std::initializer_list<int>){} // only list-init from 'int's
};

int main(){
  X x = {42};
}

Normally, from the X x = expr; pattern, we expect the code to fail to compile, because the move constructor of X is defined as deleted. However, the latest versions of Clang and GCC compile the above code just fine, and after digging a bit (and finding the above quote), that seems to be correct behaviour. The standard only ever defines the behaviour for the whole of list-initialization, and doesn’t differentiate between the two forms at all except for the above mentioned points. Well, atleast as far as I can see, anyways.

So, to summarize my question again:

What is the use of splitting list-initialization into its two forms if they (apparently) do the exact same thing?

  • 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-14T13:12:07+00:00Added an answer on June 14, 2026 at 1:12 pm

    Because they don’t do the exact same thing. As stated in 13.3.1.7 [over.match.list]:

    In copy-list-initialization, if an explicit constructor is chosen, the initialization is ill-formed.

    In short, you can only use implicit conversion in copy-list-initialization contexts.

    This was explicitly added to make uniform initialization not, um, uniform. Yeah, I know how stupid that sounds, but bear with me.

    In 2008, N2640 was published (PDF), taking a look at the current state of uniform initialization. It looked specifically at the difference between direct initialization (T{...}) and copy-initialization (T = {...}).

    To summarize, the concern was that explicit constructors would effectively become pointless. If I have some type T that I want to be able to be constructed from an integer, but I don’t want implicit conversion, I label the constructor explicit.

    Then somebody does this:

    T func()
    {
      return {1};
    }
    

    Without the current wording, this will call my explicit constructor. So what good is it to make the constructor explicit if it doesn’t change much?

    With the current wording, you need to at least use the name directly:

    T func()
    {
      return T{1};
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that when glDrawElements is called it uses a buffer of indices to
I know that if I am inside some function foo() which is called somewhere
I know that to filter an element with an atttribute called attrName which has
Can RMI (JRMP) server be called by RMI IIOP? I know that RMI IIOP
I know about map/reduce alghoritm and its use. It's using functions that are called
What i know as of now that a constructor is called when an object
I have a script in Bash called Script.sh that needs to know its own
Does anyone know how I can force CanExecute to get called on a custom
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still

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.