This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::pair<reference,reference>


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]