This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[libstdc++-v3 patch] Disambiguate uses of TR1 components when in C++0x mode
- From: "Doug Gregor" <doug dot gregor at gmail dot com>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>, "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 12 Jul 2007 09:46:38 -0400
- Subject: [libstdc++-v3 patch] Disambiguate uses of TR1 components when in C++0x mode
When testing libstdc++ under -std=gnu++0x, several of the TR1 test
cases fail because the entities named show up under namespace std::
and namespace std::tr1, causing ambiguities. This boring patch tweaks
using directives, using declarations, and qualifications in the test
suite to make it run cleanly under C++0x and C++98.
There's still an annoying problem that the PCH for stdtr1c++.h does
not build cleanly under -std=gnu++0x, but it's due to some strange
interaction between header inclusion order and using directives in
std::tr1. My current patch for it is unsatisfactory, so I'll see if I
can come up with anything better before posting that.
Tested i686-pc-linux-gnu with cxx_dialect as cxx0x and cxx98; no regressions.
Okay for mainline?
- Doug
2007-07-12 Douglas Gregor <doug.gregor@gmail.com>
* tr1/3_function_objects/bind/all_bound.cc: Disambiguate uses of
TR1/C++0x facilities.
* tr1/3_function_objects/bind/nested.cc: Ditto.
* tr1/3_function_objects/bind/placeholders.cc: Ditto.
* tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc:
Ditto.
* tr1/6_containers/unordered_multimap/swap/1.cc: Ditto.
* tr1/6_containers/unordered_multimap/swap/2.cc: Ditto.
* tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc:
Ditto.
* tr1/6_containers/unordered_set/swap/1.cc: Ditto.
* tr1/6_containers/unordered_set/swap/2.cc: Ditto.
* tr1/6_containers/utility/pair.cc: Ditto.
* tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc:
Ditto.
* tr1/6_containers/unordered_map/24064.cc: Ditto.
* tr1/6_containers/unordered_map/swap/1.cc: Ditto.
* tr1/6_containers/unordered_map/swap/2.cc: Ditto.
* tr1/6_containers/tuple/cons/big_tuples.cc: Ditto.
* tr1/6_containers/tuple/cons/constructor.cc: Ditto.
* tr1/6_containers/tuple/cons/assignment.cc: Ditto.
* tr1/6_containers/tuple/tuple_element.cc: Ditto.
* tr1/6_containers/tuple/tuple_size.cc: Ditto.
* tr1/6_containers/tuple/comparison_operators/comparisons.cc:
Ditto.
* tr1/6_containers/tuple/element_access/get.cc: Ditto.
* tr1/6_containers/tuple/creation_functions/23978.cc: Ditto.
* tr1/6_containers/tuple/creation_functions/tie.cc: Ditto.
* tr1/6_containers/tuple/creation_functions/make_tuple.cc: Ditto.
* tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc:
Ditto.
* tr1/6_containers/unordered_multiset/swap/1.cc: Ditto.
* tr1/6_containers/unordered_multiset/swap/2.cc: Ditto.
Index: tr1/3_function_objects/bind/all_bound.cc
===================================================================
--- tr1/3_function_objects/bind/all_bound.cc (revision 126350)
+++ tr1/3_function_objects/bind/all_bound.cc (working copy)
@@ -30,12 +30,10 @@ bool test __attribute__((unused)) = true
// Operations on empty function<> objects
void test01()
{
- using std::tr1::bind;
-
- VERIFY( bind(std::plus<int>(), 3, 5)() == 8 );
- VERIFY( bind(std::minus<int>(), 3, 5)() == -2 );
- VERIFY( bind<int>(std::plus<int>(), 3, 5)() == 8 );
- VERIFY( bind<int>(std::minus<int>(), 3, 5)() == -2 );
+ VERIFY( std::tr1::bind(std::plus<int>(), 3, 5)() == 8 );
+ VERIFY( std::tr1::bind(std::minus<int>(), 3, 5)() == -2 );
+ VERIFY( std::tr1::bind<int>(std::plus<int>(), 3, 5)() == 8 );
+ VERIFY( std::tr1::bind<int>(std::minus<int>(), 3, 5)() == -2 );
}
int main()
Index: tr1/3_function_objects/bind/nested.cc
===================================================================
--- tr1/3_function_objects/bind/nested.cc (revision 126350)
+++ tr1/3_function_objects/bind/nested.cc (working copy)
@@ -30,13 +30,12 @@ bool test __attribute__((unused)) = true
// Operations on empty function<> objects
void test01()
{
- using std::tr1::bind;
using namespace std::tr1::placeholders;
int five = 5;
int seven = 7;
- VERIFY( bind(std::multiplies<int>(), _1, bind(std::minus<int>(), 6, _2))(five, seven) == -5 );
- VERIFY( bind(std::multiplies<int>(), _1, bind(std::minus<int>(), 6, _2))(seven, five) == 7 );
+ VERIFY( std::tr1::bind(std::multiplies<int>(), _1, std::tr1::bind(std::minus<int>(), 6, _2))(five, seven) == -5 );
+ VERIFY( std::tr1::bind(std::multiplies<int>(), _1, std::tr1::bind(std::minus<int>(), 6, _2))(seven, five) == 7 );
}
int main()
Index: tr1/3_function_objects/bind/placeholders.cc
===================================================================
--- tr1/3_function_objects/bind/placeholders.cc (revision 126350)
+++ tr1/3_function_objects/bind/placeholders.cc (working copy)
@@ -30,13 +30,12 @@ bool test __attribute__((unused)) = true
// Operations on empty function<> objects
void test01()
{
- using std::tr1::bind;
using namespace std::tr1::placeholders;
int five = 5;
int seven = 7;
- VERIFY( bind(std::minus<int>(), _1, _2)(five, seven) == -2 );
- VERIFY( bind(std::minus<int>(), _2, _1)(five, seven) == 2 );
+ VERIFY( std::tr1::bind(std::minus<int>(), _1, _2)(five, seven) == -2 );
+ VERIFY( std::tr1::bind(std::minus<int>(), _2, _1)(five, seven) == 2 );
}
int main()
Index: tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc
===================================================================
--- tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc (revision 126350)
+++ tr1/6_containers/unordered_multimap/requirements/explicit_instantiation.cc (working copy)
@@ -25,8 +25,11 @@
#include <string>
#include <tr1/unordered_map>
-using namespace std;
using namespace std::tr1;
+using std::string;
+using std::equal_to;
+using std::allocator;
+using std::pair;
template class unordered_multimap<string, float>;
template class unordered_multimap<string, int,
Index: tr1/6_containers/unordered_multimap/swap/1.cc
===================================================================
--- tr1/6_containers/unordered_multimap/swap/1.cc (revision 126350)
+++ tr1/6_containers/unordered_multimap/swap/1.cc (working copy)
@@ -30,8 +30,11 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::pair;
+ using std::equal_to;
+ using std::map;
+ using std::multimap;
typedef pair<const char, int> my_pair;
typedef __gnu_test::uneq_allocator<my_pair> my_alloc;
Index: tr1/6_containers/unordered_multimap/swap/2.cc
===================================================================
--- tr1/6_containers/unordered_multimap/swap/2.cc (revision 126350)
+++ tr1/6_containers/unordered_multimap/swap/2.cc (working copy)
@@ -30,8 +30,11 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::pair;
+ using std::equal_to;
+ using std::map;
+ using std::multimap;
typedef pair<const char, int> my_pair;
typedef __gnu_test::uneq_allocator<my_pair> my_alloc;
Index: tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc
===================================================================
--- tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc (revision 126350)
+++ tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc (working copy)
@@ -24,8 +24,9 @@
#include <tr1/unordered_set>
-using namespace std;
using namespace std::tr1;
+using std::equal_to;
+using std::allocator;
template class unordered_set<int>;
template class unordered_set<float, hash<float>, equal_to<float>,
Index: tr1/6_containers/unordered_set/swap/1.cc
===================================================================
--- tr1/6_containers/unordered_set/swap/1.cc (revision 126350)
+++ tr1/6_containers/unordered_set/swap/1.cc (working copy)
@@ -30,8 +30,9 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::equal_to;
+ using std::set;
typedef __gnu_test::uneq_allocator<char> my_alloc;
typedef unordered_set<char, hash<char>, equal_to<char>, my_alloc> my_uset;
Index: tr1/6_containers/unordered_set/swap/2.cc
===================================================================
--- tr1/6_containers/unordered_set/swap/2.cc (revision 126350)
+++ tr1/6_containers/unordered_set/swap/2.cc (working copy)
@@ -30,8 +30,9 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::equal_to;
+ using std::set;
typedef __gnu_test::uneq_allocator<char> my_alloc;
typedef unordered_set<char, hash<char>, equal_to<char>, my_alloc> my_uset;
Index: tr1/6_containers/utility/pair.cc
===================================================================
--- tr1/6_containers/utility/pair.cc (revision 126350)
+++ tr1/6_containers/utility/pair.cc (working copy)
@@ -23,8 +23,8 @@
#include <tr1/utility>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
+using std::pair;
struct blank_class
{ };
Index: tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc
===================================================================
--- tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc (revision 126350)
+++ tr1/6_containers/unordered_map/requirements/explicit_instantiation.cc (working copy)
@@ -25,8 +25,11 @@
#include <string>
#include <tr1/unordered_map>
-using namespace std;
using namespace std::tr1;
+using std::string;
+using std::allocator;
+using std::pair;
+using std::equal_to;
template class unordered_map<string, float>;
template class unordered_map<string, int,
Index: tr1/6_containers/unordered_map/24064.cc
===================================================================
--- tr1/6_containers/unordered_map/24064.cc (revision 126350)
+++ tr1/6_containers/unordered_map/24064.cc (working copy)
@@ -26,8 +26,10 @@ void test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::allocator;
+ using std::pair;
+ using std::equal_to;
__unordered_map<int, char, hash<int>, equal_to<int>,
allocator<pair<const int, char> >, true> m;
Index: tr1/6_containers/unordered_map/swap/1.cc
===================================================================
--- tr1/6_containers/unordered_map/swap/1.cc (revision 126350)
+++ tr1/6_containers/unordered_map/swap/1.cc (working copy)
@@ -30,8 +30,10 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::pair;
+ using std::equal_to;
+ using std::map;
typedef pair<const char, int> my_pair;
typedef __gnu_test::uneq_allocator<my_pair> my_alloc;
Index: tr1/6_containers/unordered_map/swap/2.cc
===================================================================
--- tr1/6_containers/unordered_map/swap/2.cc (revision 126350)
+++ tr1/6_containers/unordered_map/swap/2.cc (working copy)
@@ -30,8 +30,10 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::pair;
+ using std::equal_to;
+ using std::map;
typedef pair<const char, int> my_pair;
typedef __gnu_test::uneq_allocator<my_pair> my_alloc;
Index: tr1/6_containers/tuple/cons/big_tuples.cc
===================================================================
--- tr1/6_containers/tuple/cons/big_tuples.cc (revision 126350)
+++ tr1/6_containers/tuple/cons/big_tuples.cc (working copy)
@@ -23,8 +23,8 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
+using std::pair;
// A simple class without conversions to check some things
struct foo
Index: tr1/6_containers/tuple/cons/constructor.cc
===================================================================
--- tr1/6_containers/tuple/cons/constructor.cc (revision 126350)
+++ tr1/6_containers/tuple/cons/constructor.cc (working copy)
@@ -23,8 +23,8 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
+using std::pair;
int
main()
Index: tr1/6_containers/tuple/cons/assignment.cc
===================================================================
--- tr1/6_containers/tuple/cons/assignment.cc (revision 126350)
+++ tr1/6_containers/tuple/cons/assignment.cc (working copy)
@@ -23,8 +23,7 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
int
main()
Index: tr1/6_containers/tuple/tuple_element.cc
===================================================================
--- tr1/6_containers/tuple/tuple_element.cc (revision 126350)
+++ tr1/6_containers/tuple/tuple_element.cc (working copy)
@@ -23,8 +23,7 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
struct foo
{ };
Index: tr1/6_containers/tuple/tuple_size.cc
===================================================================
--- tr1/6_containers/tuple/tuple_size.cc (revision 126350)
+++ tr1/6_containers/tuple/tuple_size.cc (working copy)
@@ -23,8 +23,7 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
int
main()
Index: tr1/6_containers/tuple/comparison_operators/comparisons.cc
===================================================================
--- tr1/6_containers/tuple/comparison_operators/comparisons.cc (revision 126350)
+++ tr1/6_containers/tuple/comparison_operators/comparisons.cc (working copy)
@@ -23,8 +23,7 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
#define TEST1(x) VERIFY( x == x && !(x != x) && x <= x && !(x < x) )
Index: tr1/6_containers/tuple/element_access/get.cc
===================================================================
--- tr1/6_containers/tuple/element_access/get.cc (revision 126350)
+++ tr1/6_containers/tuple/element_access/get.cc (working copy)
@@ -23,8 +23,7 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
int
main()
Index: tr1/6_containers/tuple/creation_functions/23978.cc
===================================================================
--- tr1/6_containers/tuple/creation_functions/23978.cc (revision 126350)
+++ tr1/6_containers/tuple/creation_functions/23978.cc (working copy)
@@ -24,8 +24,8 @@
#include <tr1/utility>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
+using std::pair;
// libstdc++/23978
void test01()
Index: tr1/6_containers/tuple/creation_functions/tie.cc
===================================================================
--- tr1/6_containers/tuple/creation_functions/tie.cc (revision 126350)
+++ tr1/6_containers/tuple/creation_functions/tie.cc (working copy)
@@ -23,8 +23,7 @@
#include <tr1/tuple>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
int
main()
Index: tr1/6_containers/tuple/creation_functions/make_tuple.cc
===================================================================
--- tr1/6_containers/tuple/creation_functions/make_tuple.cc (revision 126350)
+++ tr1/6_containers/tuple/creation_functions/make_tuple.cc (working copy)
@@ -24,8 +24,7 @@
#include <tr1/functional>
#include <testsuite_hooks.h>
-using namespace std;
-using namespace tr1;
+using namespace std::tr1;
int
main()
Index: tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc
===================================================================
--- tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc (revision 126350)
+++ tr1/6_containers/unordered_multiset/requirements/explicit_instantiation.cc (working copy)
@@ -24,8 +24,9 @@
#include <tr1/unordered_set>
-using namespace std;
using namespace std::tr1;
+using std::equal_to;
+using std::allocator;
template class unordered_multiset<int>;
template class unordered_multiset<float, hash<float>, equal_to<float>,
Index: tr1/6_containers/unordered_multiset/swap/1.cc
===================================================================
--- tr1/6_containers/unordered_multiset/swap/1.cc (revision 126350)
+++ tr1/6_containers/unordered_multiset/swap/1.cc (working copy)
@@ -30,8 +30,9 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::equal_to;
+ using std::multiset;
typedef __gnu_test::uneq_allocator<char> my_alloc;
typedef unordered_multiset<char, hash<char>, equal_to<char>, my_alloc>
Index: tr1/6_containers/unordered_multiset/swap/2.cc
===================================================================
--- tr1/6_containers/unordered_multiset/swap/2.cc (revision 126350)
+++ tr1/6_containers/unordered_multiset/swap/2.cc (working copy)
@@ -30,8 +30,9 @@ void
test01()
{
bool test __attribute__((unused)) = true;
- using namespace std;
- using namespace tr1;
+ using namespace std::tr1;
+ using std::equal_to;
+ using std::multiset;
typedef __gnu_test::uneq_allocator<char> my_alloc;
typedef unordered_multiset<char, hash<char>, equal_to<char>, my_alloc>