[cfe-commits] [libcxx] r173172 - in /libcxx/trunk: include/locale src/string.cpp

Howard Hinnant hhinnant at apple.com
Tue Jan 22 13:23:02 PST 2013


On Jan 22, 2013, at 4:18 PM, Sebastian Redl <sebastian.redl at getdesigned.at> wrote:

> 
> On 22.01.2013, at 21:41, Howard Hinnant wrote:
> 
>> On Jan 22, 2013, at 3:22 PM, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
>> 
>>> On Tue, Jan 22, 2013 at 05:26:09PM -0000, Howard Hinnant wrote:
>>>> Author: hhinnant
>>>> Date: Tue Jan 22 11:26:08 2013
>>>> New Revision: 173172
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=173172&view=rev
>>>> Log:
>>>> Saleem Abdulrasool: If errno is defined as volatile int, the qualifier differences can cause
>>>> template typename deductions on swap<> (used in string.cpp).
>>> 
>>> Why are you using swap<> in first place? errno is either an integer or
>>> lvalue of int type and a plain assignment should be exactly what is
>>> desired here?
>>> 
>>> Joerg
>> 
>> Hmmm..  just looking at float stof(const string& str, size_t* idx) as an example.  If I didn't use swap, I think this is how I would code it:
>> 
>> float
>> stof(const string& str, size_t* idx)
>> {
>>   char* ptr;
>>   const char* const p = str.c_str();
>>   typename remove_reference<decltype(errno)>::type errno_save = errno;
> 
> I'm just slightly fuzzy on the auto deduction rules, but wouldn't
> 
> auto errno_save = errno;
> 
> have exactly the same effect?
> 
> Sebastian

auto works for me in src/string.cpp.  I don't want to put it in locale though.  Under C++03 mode we've got an emulation for remove_reference<decltype(errno)>::type, but not for auto.

Howard




More information about the cfe-commits mailing list