[libcxx] r212569 - string_view enhancements. Move to the correct namespace. Better constexpr support (thanks to Richard for the suggestions). Update the tests to match this. Add <experimental/__config for experimental macros/etc to live.
Marshall Clow
mclow.lists at gmail.com
Tue Jul 8 15:38:12 PDT 2014
Author: marshall
Date: Tue Jul 8 17:38:11 2014
New Revision: 212569
URL: http://llvm.org/viewvc/llvm-project?rev=212569&view=rev
Log:
string_view enhancements. Move to the correct namespace. Better constexpr support (thanks to Richard for the suggestions). Update the tests to match this. Add <experimental/__config for experimental macros/etc to live.
Added:
libcxx/trunk/include/experimental/__config
Modified:
libcxx/trunk/include/experimental/string_view
libcxx/trunk/test/experimental/string.view/string.view.access/at.pass.cpp
Added: libcxx/trunk/include/experimental/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=212569&view=auto
==============================================================================
--- libcxx/trunk/include/experimental/__config (added)
+++ libcxx/trunk/include/experimental/__config Tue Jul 8 17:38:11 2014
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+//===--------------------------- __config ---------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_CONFIG
+#define _LIBCPP_EXPERIMENTAL_CONFIG
+
+#include <__config>
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } }
+#define _VSTD_EXPERIMENTAL std::experimental
+
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
+#define _LIBCPP_END_NAMESPACE_LFTS } } }
+#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
+
+#endif
Modified: libcxx/trunk/include/experimental/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=212569&r1=212568&r2=212569&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Tue Jul 8 17:38:11 2014
@@ -174,7 +174,7 @@ namespace std {
*/
-#include <__config>
+#include <experimental/__config>
#include <string>
#include <algorithm>
@@ -186,9 +186,7 @@ namespace std {
#pragma GCC system_header
#endif
-namespace std {
- namespace experimental {
- inline namespace library_fundamentals_v1 {
+_LIBCPP_BEGIN_NAMESPACE_LFTS
template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_string_view {
@@ -276,12 +274,15 @@ namespace std {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference operator[](size_type __pos) const { return __data[__pos]; }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_reference at(size_type __pos) const
{
- if (__pos >= size())
- throw out_of_range("string_view::at");
- return __data[__pos];
+ return __pos >= size()
+ ? throw out_of_range("string_view::at")
+ : __data[__pos];
+// if (__pos >= size())
+// throw out_of_range("string_view::at");
+// return __data[__pos];
}
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
@@ -358,7 +359,8 @@ namespace std {
return __rlen;
}
- _LIBCPP_CONSTEXPR basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
+ _LIBCPP_CONSTEXPR
+ basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
{
// if (__pos > size())
// throw out_of_range("string_view::substr");
@@ -776,8 +778,7 @@ namespace std {
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
-}}} // close std::experimental::library_fundamentals_v1
-
+_LIBCPP_END_NAMESPACE_LFTS
_LIBCPP_BEGIN_NAMESPACE_STD
// [string.view.hash]
Modified: libcxx/trunk/test/experimental/string.view/string.view.access/at.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/experimental/string.view/string.view.access/at.pass.cpp?rev=212569&r1=212568&r2=212569&view=diff
==============================================================================
--- libcxx/trunk/test/experimental/string.view/string.view.access/at.pass.cpp (original)
+++ libcxx/trunk/test/experimental/string.view/string.view.access/at.pass.cpp Tue Jul 8 17:38:11 2014
@@ -43,7 +43,7 @@ int main () {
test ( U"a", 1 );
#endif
-#if _LIBCPP_STD_VER > 11
+#if __cplusplus >= 201103L
{
constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
static_assert ( sv.length() == 2, "" );
More information about the cfe-commits
mailing list