This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Implement N3762 string_view: a non-owning reference to a string.
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 15 Nov 2013 11:18:59 +0000
- Subject: Re: Implement N3762 string_view: a non-owning reference to a string.
- Authentication-results: sourceware.org; auth=none
- References: <5285A634 dot 7070907 at verizon dot net>
On 15 November 2013 04:42, Ed Smith-Rowland wrote:
>
> As the title says. It's a pretty simple class" a non-mutating read-only
> view into a const CharT* or a basic_string.
Nice, thanks.
+/** @file experimantal/string_view
+ * This is a Standard C++ Library header.
+ */
s/experimantal/experimental/
The same doxygen header appears in string_view.tcc but shouldn't be
there (it should either have no doxygen @file block or should have a
"This is an internal header file, ..." block.
Can you use the same approach as std::array::at to make
basic_string_view::at constexpr?
basic_string_view::substr would need a constexpr std::min to use the
same technique.
_S_compare should be possible to make constexpr, I can look into that
once it's committed.
+ namespace __detail
+ {
+ // Identiry transform to make ADL work with just one argument.
+ // See n3766.html.
+ template<class _Tp=void>
+ struct __identity
+ { typedef _Tp type; };
+
+ template<>
+ struct __identity<void>;
+
+ template<class _Tp>
+ using __idt = typename __identity<_Tp>::type;
+ }
s/Identiry/Identity/ and please use typename _Tp instead of class _Tp
in the template parameter list.
+ template<typename _CharT, typename _Traits>
+ bool
+ operator==(basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+ { return __x.compare(__y) == 0; }
+ template<typename _CharT, typename _Traits>
+ bool
+ operator==(basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>>
__y) noexcept
+ { return __x.compare(__y) == 0; }
+ template<typename _CharT, typename _Traits>
+ bool
+ operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+ { return __x.compare(__y) == 0; }
Please add a blank line between these function templates.
I think the std::hash declaration and specializations should be inside
a _GLIBCXX_BEGIN_NAMESPACE_VERSION / _GLIBCXX_END_NAMESPACE_VERSION
pair, because when using versioned namespaces they will be in
std::__v7 not std.