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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:23:40+00:00 2026-05-23T20:23:40+00:00

In the Standard-Text there is an example in 8.5.4 (3) List-initialization [dcl.init.list] struct S

  • 0

In the Standard-Text there is an example in 8.5.4 (3) List-initialization [dcl.init.list]

struct S {
    S(std::initializer_list<double>);  // #1
    S(const std::string&);             // #2
};
const S& r1 = { 1, 2, 3.0 };  // OK: invoke #1
const S& r2 { "Spinach" };    // OK: invoke #2 !!!

(the example is about the ref-to-temp, but I refer to the overload resolution here).

Whereas Scott Meyers in his talk/slides tells a different story:

std::initializer_list parameters are always preferred over other types:

class Widget {
public:
    Widget(double value, double uncertainty);           // #1
    Widget(std::initializer_list<std::string> values);  // #2
};
double d1, d2;
Widget w1 { d1, d2 }; // tries to call #2; fails because
                      // no double ⇒ string conversion

The examples are slightly different, but aren’t those about the same thing? When and how overload resolution with initializer_list-constructors happens? Or is there a different issue here?

How is the overloading decided in both cases? If both are correct, what do I miss here?

Edit/Clarification upon Keric’s Comment: My feeling ist, that the two examples contradict each other:

  • The Std gives an example where a const char* is converted to a string, which does not match the provided initializer_list<int> and therefore the provided “normal” const string&-c’tor is used.
  • Scott’s example initializes with {double, double} when an intializer_list<int>-c’tor is available and therefore chosen, because the list, he argues, is preferred. Thus the also provided (double, double)-c’tor is never chosen when initialized this way.

Of course, the Std is always right, but maybe I apply the example wrongly. The Std example has & in it, that I don’t think are relevant for my question, but maybe I am wrong.

Scott’s slides are quite recent, and I can not see that the relevant section(s) in the Std have changed to that respect (although, it’s difficult to get everything into scope, because it’s somewhat “widely spread” 🙂

Edit-2: I got a mail from Scott himself that there was a late change in the Standard that had not been incorporated into the slides.

  • 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-23T20:23:40+00:00Added an answer on May 23, 2026 at 8:23 pm

    Pursuant to N3291, the Working Draft from April 5, 2011, there has been a few changes to initializer lists, so Scott Meyer’s slides may be from old data.

    According to section 13.3.1.7 (so close to 1337):

    • Initially, the candidate functions are the initializer-list constructors (8.5.4) of the class T and the argument list consists of the initializer list as a single argument
    • If no viable initializer-list constructor is found, overload resolution is performed again, where the candidate functions are all the constructors of the class T and the argument list consists of the elements of the initializer list.

    So it does prefer initailizer lists. But if the initializer list doesn’t match, then it will check the regular constructors to see if they match.

    It goes on to say that if the initializer list is empty, then the default constructor is used.

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

Sidebar

Related Questions

Is there a way to alter the standard background and text colors in cocoa
In CFEclipse, I do a lot of double-clicking to select text. The standard behavior
Is there an xml or some form of a text standard that one can
When using the standard api, for example the collections library, the predictive text options
There are many "standards" for the JSON content type: application/json application/x-javascript text/javascript text/x-javascript text/x-json
What's the quickest, easiest way to draw text in standard OGL ??
I find the standard Powershell display of errors (red text, multi-line display) a bit
Can a Java Applet able to print out text/html easily to standard printer driver(s)
I would like to break a long line of text assigned to the standard
I've been trying to deal with some delimited text files that have non standard

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.