操作符的初始列表和RHS
class foo { };struct bar{ template<typename... T> bar(T const&...) { }};foo& operator<<(foo& f, bar const&) { return f; }int main(){ foo baz; baz << {1, -2, "foo", 4, 5}; return 0;}
clang.cc:14:9: error: initializer list cannot be used on the right hand side of operator '<<' baz << {1, -2, "foo", 4, 5}; ^ ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
baz << bar{1, -2, "foo", 4, 5};
?
相关分类