변수 템플릿 선언에서 auto를 사용할 수 있는지 살펴 보았습니다.Clang 자동 변수 템플릿 버그
template <typename T>
auto F = T{};
그래도 사용하려고하면 크랩을 잡습니다.
int f = F<int>; // error: cannot initialize a variable of type 'int' with an lvalue of type 'auto'
auto f = F<int>; // Stacktrace
decltype(F<int>) f = F<int>; // StackFace
std::cout << std::is_same<int, decltype(F<int>)>::value; // false
std::cout << typeid(decltype(F<int>)).name(); // Stacktrace
std::cout << std::is_same<decltype(F<int>), decltype(F<int>)>::value; // true
이 auto
이 좌변 것을 말한다 불구하고 decltype(auto)
의 조합은, auto
도 작동하지 않습니다.
int f = static_cast<int>(F<int>); // error: static_cast from 'auto' to 'int' is not allowed
나는 전에 이런 식의 자동 행동을 본 적이 없습니다. 그것은 변수 템플릿 때문에 또는 clang이 자동을 다루는 방법 때문에 발생합니까?
아마도 아직 완전히 구현되지 않았을 것 같습니다. –
"// Stacktrace"메시지가 나타날 때마다 "clang : note : diagnostic msg : http://llvm.org/bugs/에 버그 보고서를 제출하고 크래시 백 추적, 사전 처리 된 소스 및 관련 실행 스크립트를 포함하십시오 . " 출력에 포함됩니다. 그렇게 해주세요, 이것은 clang의 버그입니다. clang 개발자는 여기에있는 사람들보다 유용한 응답을 줄 가능성이 훨씬 큽니다. – hvd