Consider this code snippet:
struct Foo {
};
template<typename T>
struct Bar {
const T foo;
};
int main() {
Bar<Foo> test;
}
I'm compiling it with g++-4.9.2 with [-std=c++11] and getting error: uninitialized const member in ‘struct Bar<Foo>’
. This is pretty obvious.
BUT try just add std::string as Foo member and program compiles!
#include <string>
struct Foo {
std::string test;
};
// (...)
What happening? Replacing test's type into double causes program to fail to compile again. What string member changes in class?
Aucun commentaire:
Enregistrer un commentaire