This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
PR 31426: TR1 and the Experimental C++0x Mode
- From: Doug Gregor <dgregor at cs dot indiana dot edu>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 5 Apr 2007 11:05:04 -0400
- Subject: PR 31426: TR1 and the Experimental C++0x Mode
Hello all,
I've filed PR 31426, which concerns the interaction between TR1 and
the experimental C++0x mode. The program in question is:
#include <tr1/tuple>
int main()
{
std::tr1::tuple<int, double> x(17, 3.14);
return 0;
}
Currently, this compiles in the default (C++98) mode but fails in the
experimental C++0x mode. I don't think this is what we want. If the
user includes a tr1/ header specifically, s/he should get these
facilities in the std::tr1 namespace, regardless of what mode the C++
compiler is in. The current situation makes a lot of code break when -
std=c++0x is turned on.
I can see two easy solutions:
(1) Namespace alias: in each of the tr1/ headers, include the header
<tr1/import.h> shown below:
#ifndef _TR1_IMPORT
#define _TR1_IMPORT 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
namespace std {
namespace tr1 = __cxx200x;
}
#endif
#endif
(2) Strong using without the __cxx200x namespace: make the tr1/
headers actually put everything into namespace std::tr1. When we're
in C++0x mode, have each of the C++0x headers (or C++98 headers that
have been extended by C++0x), do this:
#ifdef __GXX_EXPERIMENTAL_CXX0X__
# include <tr1/the_equivalent_tr1_header>
# include <bits/import_from_tr1.h>
#endif
where bits/import_from_tr1.h is:
#ifndef _IMPORT_FROM_TR1
#define _IMPORT_FROM_TR1 1
namespace std
{
using namespace tr1 __attribute__ ((strong));
}
#endif
Cheers,
Doug