From 83179a788ff3e3ca95d0f30c94a9d705b12c4e06 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 27 Aug 2013 20:18:59 +0000 Subject: [PATCH] LWG issues 2174/5/6 - mark wstring_convert::converted as noexcept, and make (some of) the constructors for wstring_convert and wbuffer_convert as explicit. Add configuration macro _LIBCPP_EXPLICIT_AFTER_CXX11 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@189398 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__config | 2 ++ include/locale | 27 +++++++++++-------- .../conversions.buffer/ctor.pass.cpp | 4 +++ .../conversions.string/ctor_codecvt.pass.cpp | 4 +++ .../ctor_err_string.pass.cpp | 4 +++ www/cxx1y_status.html | 6 ++--- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/include/__config b/include/__config index d7e9014c..41907a4b 100644 --- a/include/__config +++ b/include/__config @@ -570,8 +570,10 @@ template struct __static_assert_check {}; #if _LIBCPP_STD_VER <= 11 #define _LIBCPP_CONSTEXPR_AFTER_CXX11 +#define _LIBCPP_EXPLICIT_AFTER_CXX11 #else #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr +#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit #endif #endif // _LIBCPP_CONFIG diff --git a/include/locale b/include/locale index 768bb39b..5db25663 100644 --- a/include/locale +++ b/include/locale @@ -93,10 +93,12 @@ public: typedef typename Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; - wstring_convert(Codecvt* pcvt = new Codecvt); + explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14 wstring_convert(Codecvt* pcvt, state_type state); - wstring_convert(const byte_string& byte_err, + explicit wstring_convert(const byte_string& byte_err, // explicit in C++14 const wide_string& wide_err = wide_string()); + wstring_convert(const wstring_convert&) = delete; // C++14 + wstring_convert & operator=(const wstring_convert &) = delete; // C++14 ~wstring_convert(); wide_string from_bytes(char byte); @@ -109,7 +111,7 @@ public: byte_string to_bytes(const wide_string& wstr); byte_string to_bytes(const Elem* first, const Elem* last); - size_t converted() const; + size_t converted() const; // noexcept in C++14 state_type state() const; }; @@ -120,9 +122,12 @@ class wbuffer_convert public: typedef typename Tr::state_type state_type; - wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, - state_type state = state_type()); - + explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // explicit in C++14 + wbuffer_convert(const wbuffer_convert&) = delete; // C++14 + wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14 + ~wbuffer_convert(); // C++14 + streambuf* rdbuf() const; streambuf* rdbuf(streambuf* bytebuf); @@ -4009,9 +4014,9 @@ private: wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: - wstring_convert(_Codecvt* __pcvt = new _Codecvt); + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); wstring_convert(_Codecvt* __pcvt, state_type __state); - wstring_convert(const byte_string& __byte_err, + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES wstring_convert(wstring_convert&& __wc); @@ -4041,7 +4046,7 @@ public: byte_string to_bytes(const _Elem* __first, const _Elem* __last); _LIBCPP_ALWAYS_INLINE - size_t converted() const {return __cvtcount_;} + size_t converted() const _NOEXCEPT {return __cvtcount_;} _LIBCPP_ALWAYS_INLINE state_type state() const {return __cvtstate_;} }; @@ -4275,8 +4280,8 @@ private: wbuffer_convert(const wbuffer_convert&); wbuffer_convert& operator=(const wbuffer_convert&); public: - wbuffer_convert(streambuf* __bytebuf = 0, _Codecvt* __pcvt = new _Codecvt, - state_type __state = state_type()); + _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0, + _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); ~wbuffer_convert(); _LIBCPP_INLINE_VISIBILITY diff --git a/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp index c9995325..6935c3e8 100644 --- a/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp +++ b/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp @@ -37,6 +37,10 @@ void operator delete(void* p) throw() int main() { typedef std::wbuffer_convert > B; +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible::value, ""); + static_assert( std::is_constructible::value, ""); +#endif { B b; assert(b.rdbuf() == nullptr); diff --git a/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp b/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp index 887d1f05..9099b5e3 100644 --- a/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp +++ b/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp @@ -30,5 +30,9 @@ int main() typedef std::wstring_convert Myconv; Myconv myconv(new Codecvt); assert(myconv.converted() == 0); +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible::value, ""); + static_assert( std::is_constructible::value, ""); +#endif } } diff --git a/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp b/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp index 62f68575..27a3da76 100644 --- a/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp +++ b/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp @@ -22,6 +22,10 @@ int main() { typedef std::codecvt_utf8 Codecvt; typedef std::wstring_convert Myconv; +#if _LIBCPP_STD_VER > 11 + static_assert(!std::is_convertible::value, ""); + static_assert( std::is_constructible::value, ""); +#endif { Myconv myconv; try diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html index 899586c4..5dbdc125 100644 --- a/www/cxx1y_status.html +++ b/www/cxx1y_status.html @@ -158,9 +158,9 @@ 2138atomic_flag::clear ordering constraintsBristol 2140notify_all_at_thread_exit synchronizationBristol 2144Missing noexcept specification in type_indexBristolComplete - 2174wstring_convert::converted() should be noexceptBristol - 2175string_convert and wbuffer_convert validityBristol - 2176Special members for wstring_convert and wbuffer_convertBristol + 2174wstring_convert::converted() should be noexceptBristolComplete + 2175string_convert and wbuffer_convert validityBristolComplete + 2176Special members for wstring_convert and wbuffer_convertBristolComplete 2177Requirements on Copy/MoveInsertableBristol 2185Missing throws clause for future/shared_future::wait_for/wait_untilBristolComplete 2187vector<bool> is missing emplace and emplace_back member functionsBristolComplete