following code ile yapıcı başlatma listesindeki tek tip başlatma kullanamazsınız:gcc ile derleme değil try/catch
struct test {
int x;
test() try : x{123} {
}
catch (...) {
}
};
int main() {}
Hataları: x(123)
için x{123}
yardımcı olur değiştirilmesi
prog.cpp:3:25: error: expected unqualified-id before ‘{’ token
test() try : x{123} {
^
prog.cpp:5:5: error: expected unqualified-id before ‘catch’
catch (...) {
^
prog.cpp: In constructor ‘test::test()’:
prog.cpp:3:23: error: expected ‘{’ at end of input
test() try : x{123} {
^
prog.cpp:3:23: error: expected ‘catch’ at end of input
prog.cpp:3:23: error: expected ‘(’ at end of input
prog.cpp:3:23: error: expected type-specifier at end of input
prog.cpp:3:23: error: expected ‘)’ at end of input
prog.cpp:3:23: error: expected ‘{’ at end of input
. Bu şekilde çalışmalı mıyım? (Aynı catch
GCC 4.8 sahiptir yanlış, ama GCC 4.9 düzgün kolları -
Clang [derler] (http://coliru.stacked-crooked.com/a/0e8921393e3a52f1) hatasız – Praetorian
Parantez ve C++ 11 ile ilgili her şey çok Tamamen eksik olması muhtemel Bir süredir derleyicilerde düzeltilmiş köşe ... –
@KerrekSB Başlangıçta bir hata olduğunu düşündüm, fakat Stroustrup'un kitabında kurucularda üniforma başlatma işlemini kullanıyor, çünkü bir deneme/yakalama olduğu zamanlar hariç, bu beni biraz şaşırttı. – catscradle