<string_view> for libc++
mclow.lists at gmail.com
Mon Jan 6 16:49:51 PST 2014
On Jan 6, 2014, at 2:01 PM, G M <gmisocpp at gmail.com> wrote:
> Hi Marshall
> Some early feed back for your patch:
> 1. string_view implements it's own __min function, but this is unfortunately a macro in mingw's stdlib.h
Frackety frack frack.
I can’t use std::min () because it’s not constexpr - but it should be.
I’ll change __min to something else.
> and therefore compilation yields these type of error's with clang++ and g++ using mingw:
> /libcxx/include\string_view:181:18: error: expected ')'
> constexpr _T __min ( const _T& __t1, const _T& __t2 )
> c:\mingw\bin\..\lib\clang\3.5\../../../x86_64-w64-mingw32/include\stdlib.h:113:26: note: expanded from macro '__min'
> #define __min(a,b) (((a) < (b)) ? (a) : (b))
> Changing __min to ___min which allowed it to compile for me.
> 2. With the above change in place, I find I c++1y is required. Makes sense, but using string_view without a c++1y compiler might be a worthwhile consideration if it's easy.
> /libcxx/include\string_view:241:13: warning: use of this statement in a constexpr function is a C++1y extension
> if (__pos >= size ())
> /libcxx/include\string_view:292:23: warning: variable declaration in a constexpr function is a C++1y extension
> size_type rlen_ = ____min ( __n, size() - __pos );
> /libcxx/include\string_view:290:13: warning: use of this statement in a constexpr function is a C++1y extension
> if (__pos > size())
it needs the C++14 constexpr rules.
[ And the source code needs an include guard based on the C++ language version or something, but we don’t have one of those yet. ]
[ And all the tests need the same guard ]
> 3. g++ reports this:
> In file included from sv.cpp:1:0:
> /libcxx/include/string_view:199:53: error: declaration of 'typedef std::experimental::__library_fundamentals::basic_strin
> _view<_CharT, _Traits>::const_reverse_iterator std::experimental::__library_fundamentals::basic_string_view<_CharT, _Trai
> s>::reverse_iterator' [-fpermissive]
> typedef const_reverse_iterator reverse_iterator;
> In file included from /libcxx/include/memory:600:0,
> from /libcxx/include/algorithm:627,
> from /libcxx/include/string:439,
> from /libcxx/include/string_view:173,
> from sv.cpp:1:
> /libcxx/include/iterator:529:29: error: changes meaning of 'reverse_iterator' from 'class std::__1::reverse_iterator<cons
> _CharT*>' [-fpermissive]
> class _LIBCPP_TYPE_VIS_ONLY reverse_iterator
> I commented out line 199 and it compiled. i.e.:
> //typedef const_reverse_iterator reverse_iterator;
> That's it for now.
The line before that needs a _VSTD::.
> Hope this helps.
More information about the cfe-commits