From -7906466253318994670
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,dde8aef4d690b866
X-Google-Attributes: gidf78e5,public
From: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Subject: Re: Problem with std::make_pair?
Date: 1999/08/04
Message-ID: <37A5D98C.1100@wanadoo.fr>#1/1
X-Deja-AN: 508659878
Content-Transfer-Encoding: 7bit
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
References: <zdv176.933510565@zam229> <37A4AEED.4CCE@wanadoo.fr> <zdv176.933595590@zam229>
X-Original-Date: Mon, 02 Aug 1999 19:46:52 +0200
Content-Type: text/plain; charset=us-ascii
Organization: Ecole normale superieure
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN6fRm6wEuYhIxRhxAQFVZwH/QeNbW8nA/iDLj9F2IGnnsppQVqUID4DM 7UbVN5i3+2hWOr25L8SIR4LmW41/128kRu6X9WyjhXG8VS3mGoIBmQ== =UCXQ
Mime-Version: 1.0
Newsgroups: comp.std.c++

B.Mohr wrote:

> Valentin Bonnard <Bonnard.V@wanadoo.fr> writes:

> > So your code is ill-formed, egcs is correct here.
> 
> Sorry, forgot something to ask in my last follow-up:
> 
> As explained in my other answers to this thread, I still think
> make_pair should be able to handle string literal -> std::string
> "conversion". 

Again, there is no problem with the conversion in itself.

> So, is it possible to rewrite pair<> or make_pair<>
> in a standard conforming way that my code would compile?

Use non reference arguments, it will force the char array to 
decay:

#include <utility>
#include <string>

template <typename T1, typename T2>
std::pair<T1, T2> my_make_pair (T1 l, T2 r)
{
    return std::pair<T1, T2> (l, r);
}

std::pair<std::string, int> p = my_make_pair ("A", 1);

The cost is an additionnal copy of both arguments.

-- 

Valentin Bonnard
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



