Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. C++11 - Initializer list of the aggregate does not work
Forum Updated to NodeBB v4.3 + New Features

C++11 - Initializer list of the aggregate does not work

Scheduled Pinned Locked Moved C++ Gurus
2 Posts 2 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peppy
    wrote on 29 Jul 2013, 13:39 last edited by
    #1

    Hello guys, I have a structure and test function:
    @
    struct Structure
    {
    QString s;
    QString a;
    };
    void testFunc(std::initializer_list<Structure> list)
    {
    // ...
    }
    @
    When I call it:
    @
    testFunc({"a", "b"});
    @

    MinGW yells:
    @
    error: could not convert '{"a", "b"}' from '<brace-enclosed initializer list>' to 'std::initializer_list<Structure>'.
    @

    What am I missing?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bipll
      wrote on 4 Aug 2013, 13:31 last edited by
      #2

      Can't say now, is this illegal in C++11 or just gcc flaw, but it certainly wants another pair of braces enclosing the first one, since it considers {"a", "b"} a single Structure literal, not the whole list.

      1 Reply Last reply
      0

      1/2

      29 Jul 2013, 13:39

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved