[libcxx] r269789 - Implement LWG2576: istream_iterator and ostream_iterator should use std::addressof

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue May 17 13:36:57 PDT 2016


Or maybe I'm still wrong. I tried using a custom traits class to hijack ADL
for "operator&" but it doesn't seem to work.

Sorry for the spam.

/Eric

On Tue, May 17, 2016 at 2:25 PM, Eric Fiselier <eric at efcs.ca> wrote:

> Woops. I was incorrect. It seems that user defined "operator&" overloads
> can be found in the constructor. From the LWG issue:
>
> > Note that {i,o}stream_type are specializations of basic_{i,o}stream, but
> the constructors might still pick up an overloaded & via the traits
> template parameter.
>
> At least that also tells us how to test it.
>
> /Eric
>
> On Tue, May 17, 2016 at 2:08 PM, Eric Fiselier <eric at efcs.ca> wrote:
>
>> The difference between "operator&" and "addressof"  is inconsequential
>> when user defined overloads of "operator&" can't be found, which is the
>> case for the changes in the stream iterator constructors. We might as well
>> keep it consistent though. I don't see any value changing it back to use
>> "operator&" in either the library or the standard.
>>
>> /Eric
>>
>> On Tue, May 17, 2016 at 2:02 PM, David Blaikie <dblaikie at gmail.com>
>> wrote:
>>
>>> If some parts are not testable & as you say, not meaningful, then it
>>> seems OK to just not implement them & file a DR on the standard, no?
>>>
>>> On Tue, May 17, 2016 at 1:00 PM, Eric Fiselier <eric at efcs.ca> wrote:
>>>
>>>> I added a test for operator->() in r269812. Marshall and I discussed
>>>> offline about how not all parts of this change are testable (and hence not
>>>> meaningful) but that's what the standard says to do.
>>>>
>>>>
>>>> On Tue, May 17, 2016 at 1:51 PM, David Blaikie via cfe-commits <
>>>> cfe-commits at lists.llvm.org> wrote:
>>>>
>>>>> Test coverage?
>>>>>
>>>>> On Tue, May 17, 2016 at 10:44 AM, Marshall Clow via cfe-commits <
>>>>> cfe-commits at lists.llvm.org> wrote:
>>>>>
>>>>>> Author: marshall
>>>>>> Date: Tue May 17 12:44:40 2016
>>>>>> New Revision: 269789
>>>>>>
>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=269789&view=rev
>>>>>> Log:
>>>>>> Implement LWG2576: istream_iterator and ostream_iterator should use
>>>>>> std::addressof
>>>>>>
>>>>>> Modified:
>>>>>>     libcxx/trunk/include/iterator
>>>>>>     libcxx/trunk/www/cxx1z_status.html
>>>>>>
>>>>>> Modified: libcxx/trunk/include/iterator
>>>>>> URL:
>>>>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=269789&r1=269788&r2=269789&view=diff
>>>>>>
>>>>>> ==============================================================================
>>>>>> --- libcxx/trunk/include/iterator (original)
>>>>>> +++ libcxx/trunk/include/iterator Tue May 17 12:44:40 2016
>>>>>> @@ -772,14 +772,14 @@ private:
>>>>>>      _Tp __value_;
>>>>>>  public:
>>>>>>      _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() :
>>>>>> __in_stream_(0), __value_() {}
>>>>>> -    _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>>>>>> __in_stream_(&__s)
>>>>>> +    _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) :
>>>>>> __in_stream_(_VSTD::addressof(__s))
>>>>>>          {
>>>>>>              if (!(*__in_stream_ >> __value_))
>>>>>>                  __in_stream_ = 0;
>>>>>>          }
>>>>>>
>>>>>>      _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return
>>>>>> __value_;}
>>>>>> -    _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>>>>>> &(operator*());}
>>>>>> +    _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return
>>>>>> _VSTD::addressof((operator*()));}
>>>>>>      _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
>>>>>>          {
>>>>>>              if (!(*__in_stream_ >> __value_))
>>>>>> @@ -811,9 +811,9 @@ private:
>>>>>>      const char_type* __delim_;
>>>>>>  public:
>>>>>>      _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
>>>>>> -        : __out_stream_(&__s), __delim_(0) {}
>>>>>> +        : __out_stream_(_VSTD::addressof(__s)), __delim_(0) {}
>>>>>>      _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s,
>>>>>> const _CharT* __delimiter)
>>>>>> -        : __out_stream_(&__s), __delim_(__delimiter) {}
>>>>>> +        : __out_stream_(_VSTD::addressof(__s)),
>>>>>> __delim_(__delimiter) {}
>>>>>>      _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp&
>>>>>> __value_)
>>>>>>          {
>>>>>>              *__out_stream_ << __value_;
>>>>>>
>>>>>> Modified: libcxx/trunk/www/cxx1z_status.html
>>>>>> URL:
>>>>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=269789&r1=269788&r2=269789&view=diff
>>>>>>
>>>>>> ==============================================================================
>>>>>> --- libcxx/trunk/www/cxx1z_status.html (original)
>>>>>> +++ libcxx/trunk/www/cxx1z_status.html Tue May 17 12:44:40 2016
>>>>>> @@ -222,7 +222,7 @@
>>>>>>         <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2572">2572</a></td><td>The
>>>>>> remarks for <tt>shared_ptr::operator*</tt> should apply to
>>>>>> <i>cv</i>-qualified <tt>void</tt> as
>>>>>> well</td><td>Jacksonville</td><td>Complete</td></tr>
>>>>>>         <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2574">2574</a></td><td>[fund.ts.v2]
>>>>>> <tt>std::experimental::function::operator=(F&&)</tt> should be
>>>>>> constrained</td><td>Jacksonville</td><td></td></tr>
>>>>>>         <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2575">2575</a></td><td>[fund.ts.v2]
>>>>>> <tt>experimental::function::assign</tt> should be
>>>>>> removed</td><td>Jacksonville</td><td></td></tr>
>>>>>> -       <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2576">2576</a></td><td><tt>istream_iterator</tt>
>>>>>> and <tt>ostream_iterator</tt> should use
>>>>>> <tt>std::addressof</tt></td><td>Jacksonville</td><td></td></tr>
>>>>>> +       <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2576">2576</a></td><td><tt>istream_iterator</tt>
>>>>>> and <tt>ostream_iterator</tt> should use
>>>>>> <tt>std::addressof</tt></td><td>Jacksonville</td><td>Complete</td></tr>
>>>>>>         <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2577">2577</a></td><td><tt>{shared,unique}_lock</tt>
>>>>>> should use
>>>>>> <tt>std::addressof</tt></td><td>Jacksonville</td><td>Complete</td></tr>
>>>>>>         <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2579">2579</a></td><td>Inconsistency
>>>>>> wrt Allocators in <tt>basic_string</tt> assignment vs.
>>>>>> <tt>basic_string::assign</tt></td><td>Jacksonville</td><td>Complete</td></tr>
>>>>>>         <tr><td><a href="
>>>>>> http://cplusplus.github.io/LWG/lwg-defects.html#2581">2581</a></td><td>Specialization
>>>>>> of <tt><type_traits></tt> variable templates should be
>>>>>> prohibited</td><td>Jacksonville</td><td>Complete</td></tr>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> cfe-commits mailing list
>>>>>> cfe-commits at lists.llvm.org
>>>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> cfe-commits mailing list
>>>>> cfe-commits at lists.llvm.org
>>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160517/1d88abc1/attachment-0001.html>


More information about the cfe-commits mailing list