つまり、なぜこれを行うのですか:
struct S {};
struct T
{
T(S& s) : s{s} {}
S& s;
};
int main()
{
S s;
T t{s};
}
GCC 4.7 でコンパイラ エラーが発生する場合:
test.cpp: In constructor 'T::T(S&)':
test.cpp:5:18: error: invalid initialization of non-const reference of type 'S&' from an rvalue of type '<brace-enclosed initializer list>'
?
エラーを修正するには、 を に変更する必要がありs{s}
ますs(s)
。これは、均一な初期化の均一性を壊しませんか?
編集:clangで試してみたところ、clangはそれを受け入れたので、おそらくGCCのバグですか?