diff --git a/clang/www/cxx_compatibility.html b/clang/www/cxx_compatibility.html index 46e3a9f90914..5ad443fc4338 100644 --- a/clang/www/cxx_compatibility.html +++ b/clang/www/cxx_compatibility.html @@ -120,11 +120,11 @@ Note that the forthcoming C++0x standard will allow this.
Some versions of GCC accept the following invalid code:
-#include <iostream> -#include <utility> +#include <iostream> +#include <utility> -template<typename T> -void Dump(const T& value) { +template<typename T> +void Dump(const T& value) { std::cout << value << "\n"; } @@ -132,7 +132,7 @@ namespace ns { struct Data {}; } -std::ostream& operator<<(std::ostream& out, ns::Data) { +std::ostream& operator<<(std::ostream& out, ns::Data) { return out << "Some data"; } @@ -141,8 +141,8 @@ void Use() { Dump(ns::Data()); } -template<typename T, typename U> -std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) { +template<typename T, typename U> +std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) { return out << '(' << p.first << ", " << p.second << ")"; }@@ -150,16 +150,16 @@ std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) {
Clang complains:
-test.cc:6:13: error: invalid operands to binary expression ('ostream' (aka 'basic_ostream<char>') and 'std::pair<int, double> const') +test.cc:6:13: error: invalid operands to binary expression ('ostream' (aka 'basic_ostream<char>') and 'std::pair<int, double> const') std::cout << value << "\n"; ~~~~~~~~~ ^ ~~~~~ -test.cc:18:3: note: in instantiation of function template specialization 'Dump<std::pair<int, double> >' requested here +test.cc:18:3: note: in instantiation of function template specialization 'Dump<std::pair<int, double> >' requested here Dump(std::make_pair(3, 4.5)); ^ -test.cc:6:13: error: invalid operands to binary expression ('ostream' (aka 'basic_ostream<char>') and 'ns::Data const') +test.cc:6:13: error: invalid operands to binary expression ('ostream' (aka 'basic_ostream<char>') and 'ns::Data const') std::cout << value << "\n"; ~~~~~~~~~ ^ ~~~~~ -test.cc:19:3: note: in instantiation of function template specialization 'Dump<ns::Data>' requested here +test.cc:19:3: note: in instantiation of function template specialization 'Dump<ns::Data>' requested here Dump(ns::Data()); ^ 2 errors generated. @@ -168,8 +168,8 @@ std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) {The standard, in [temp.dep.candidate], says that unqualified names like operator<< are looked up when the template is defined, not when it's instantiated. Since -operator<<(std::ostream&, const std::pair<>&) -and operator<<(std::ostream&, ns::Data) were not +operator<<(std::ostream&, const std::pair<>&) +and operator<<(std::ostream&, ns::Data) were not declared yet when Dump was defined, they're not considered.
This is complicated by argument-dependent lookup (ADL),