#include <iostream>
#include <boost/type_index.hpp>
using boost::typeindex::type_id_with_cvr;
#define print_type(var) do { \
std::cout << type_id_with_cvr<decltype(var)>().pretty_name() \
<< std::endl; \
} while(0)
int main() {
auto il1 = { 1 };
auto il2{ 1 };
print_type(il1);
print_type(il2);
return 0;
}
output
$ ./item2
std::initializer_list<int>
int
I expected every output is initializer_list. But the second is deduced to the just int
type.
- tested with g++ 5.4, clang 3.8, clang 4.0.
- built using
clang++ -std=c++11 ../item2.cpp
or-std=gnu++11
Could somebody explain this issue?
Aucun commentaire:
Enregistrer un commentaire