[cfe-dev] initializer_list deduction

Fernando Pelliccioni fpelliccioni at gmail.com
Wed May 9 11:18:22 PDT 2012


Hi all,

Is it this behavior correct ?

//Code ----------------------
#include <initializer_list>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void foo( initializer_list<typename vector<string>::value_type> list )
{
    for (auto& item : list)
    {
        cout << item << endl;
    }
}

int main( /* int argc, char* argv[] */ )
{
    foo( { {"k0", "v0"}, {"k1", "v1"} } );
    return 0;
}

//End code ----------------------


$ clang++ --version
clang version 3.1 (trunk 155038)
Target: i386-pc-linux-gnu
Thread model: posix

$ clang++ -std=c++11 initializer_list_test.cpp
$ ./a.out
k0
k1

------------------------------------------

I would have expected that the initializer_list be deduced to something
like an associative container (a compile time error).

Thanks and Regards,
Fernando Pelliccioni.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120509/462a2d20/attachment.html>


More information about the cfe-dev mailing list