This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::pair<reference,reference>
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Theodore dot Papadopoulo at sophia dot inria dot fr
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 18 May 2006 00:21:56 -0500
- Subject: Re: std::pair<reference,reference>
- References: <1147801627.5952.10.camel@samoa>
> I wonder whether it would be possible to add some specializations of
> pair for it to work even one of its template arguments is a reference.
> Below is the specialization example for the case when the two
> parameters are references. Obviously, DR 106 (if/when
> adopted/implemented) is a better fix, but in the meantime, maybe a awful
> trick like this one could be considered as a quality of
> implementation....
Hmm. Are you sure you have the right number?
include <utility>
int main()
{
using namespace std;
int i = 6;
int j = 7;
int& r1 = i;
int& r2 = j;
make_pair(r1, r2);
pair<r1, r2> p;
}
%g++ -c pair.cc
pair.cc: In function 'int main()':
pair.cc:12: error: 'r1' cannot appear in a constant-expression
pair.cc:12: error: 'r2' cannot appear in a constant-expression
pair.cc:12: error: template argument 1 is invalid
pair.cc:12: error: template argument 2 is invalid
pair.cc:12: error: invalid type in declaration before ';' token
This, you mean?
> If acceptable, I would be glad to implement and test it.
Sure.
-benjamin