dimanche 4 janvier 2015

String assignment with initializer lists


  • Can you explain me, why are there differences?

  • What's mean PKcE?


Code:



#include <iostream>
#include <typeinfo>
using namespace std;

int main() {
string s {"IDE"};
std::cout<<typeid(s).name()<<std::endl;

auto S{"IDE"}; // why do not deduced as string?
std::cout<<typeid(S).name()<<std::endl;

auto c = {"IDE"}; // why do not deduced as string?
std::cout<<typeid(c).name()<<std::endl;

auto C {string{"IDE"}}; // why do not deduced as string?
std::cout<<typeid(C).name()<<std::endl;

auto Z = string{"IDE"};
std::cout<<typeid(Z).name()<<std::endl;

}


output:



Ss
St16initializer_listIPKcE
St16initializer_listIPKcE
St16initializer_listISsE
Ss

Aucun commentaire:

Enregistrer un commentaire