diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-11-14 18:22:19 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-11-14 18:22:19 +0000 |
commit | 1c7fe126ee16857243738ebc1dbaea69caffefb1 (patch) | |
tree | 9ccb4a534b61893d510b4ab870a93892479b92a6 /libcxx/include | |
parent | ccf2fa1cb64f8b292cfbe964905c4a802fb6dd87 (diff) | |
download | bcm5719-llvm-1c7fe126ee16857243738ebc1dbaea69caffefb1.tar.gz bcm5719-llvm-1c7fe126ee16857243738ebc1dbaea69caffefb1.zip |
Fixes for LWG 2598, 2686, 2739, 2742, 2747, and 2759, which were adopted last week in Issaquah
llvm-svn: 286858
Diffstat (limited to 'libcxx/include')
-rw-r--r-- | libcxx/include/algorithm | 2 | ||||
-rw-r--r-- | libcxx/include/chrono | 3 | ||||
-rw-r--r-- | libcxx/include/memory | 3 | ||||
-rw-r--r-- | libcxx/include/numeric | 4 | ||||
-rw-r--r-- | libcxx/include/string | 20 | ||||
-rw-r--r-- | libcxx/include/string_view | 5 | ||||
-rw-r--r-- | libcxx/include/system_error | 12 | ||||
-rw-r--r-- | libcxx/include/type_traits | 4 |
8 files changed, 47 insertions, 6 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 3bafd3df79d..c5a5d0ad880 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -877,7 +877,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); - return _LIBCPP_EXPLICIT_MOVE(__f); // explicitly moved for (emulated) C++03 + return __f; } // find diff --git a/libcxx/include/chrono b/libcxx/include/chrono index 68484e98243..3cef9ed4430 100644 --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -1026,7 +1026,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { - return __lhs + (-__rhs); + typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; + return _Ret(__lhs.time_since_epoch() -__rhs); } // duration operator-(time_point x, time_point y); diff --git a/libcxx/include/memory b/libcxx/include/memory index 69068f34daa..daa17403eec 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -164,6 +164,7 @@ template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept template <class T> void return_temporary_buffer(T* p) noexcept; template <class T> T* addressof(T& r) noexcept; +template <class T> T* addressof(const T&& r) noexcept = delete; template <class InputIterator, class ForwardIterator> ForwardIterator @@ -675,7 +676,7 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) { #endif } -// addressof moved to <__functional_base> +// addressof moved to <type_traits> template <class _Tp> class allocator; diff --git a/libcxx/include/numeric b/libcxx/include/numeric index 1643d6400d1..e00580854d4 100644 --- a/libcxx/include/numeric +++ b/libcxx/include/numeric @@ -230,6 +230,8 @@ common_type_t<_Tp,_Up> gcd(_Tp __m, _Up __n) { static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); + static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" ); + static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" ); using _Rp = common_type_t<_Tp,_Up>; using _Wp = make_unsigned_t<_Rp>; return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)), @@ -242,6 +244,8 @@ common_type_t<_Tp,_Up> lcm(_Tp __m, _Up __n) { static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); + static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" ); + static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" ); if (__m == 0 || __n == 0) return 0; diff --git a/libcxx/include/string b/libcxx/include/string index 347cb6813ef..840fd0098ca 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -102,6 +102,8 @@ public: const allocator_type& a = allocator_type()); basic_string(const basic_string& str, size_type pos, size_type n, const Allocator& a = Allocator()); + template<class T> + basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17 explicit basic_string(const basic_string_view<charT, traits> sv, const Allocator& a = Allocator()); basic_string(const value_type* s, const allocator_type& a = allocator_type()); basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); @@ -789,6 +791,10 @@ public: _LIBCPP_INLINE_VISIBILITY basic_string(const basic_string& __str, size_type __pos, const allocator_type& __a = allocator_type()); + template<class _Tp> + basic_string(const _Tp& __t, size_type __pos, size_type __n, + const allocator_type& __a = allocator_type(), + typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0); _LIBCPP_INLINE_VISIBILITY explicit basic_string(__self_view __sv); _LIBCPP_INLINE_VISIBILITY @@ -1717,6 +1723,20 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st } template <class _CharT, class _Traits, class _Allocator> +template <class _Tp> +basic_string<_CharT, _Traits, _Allocator>::basic_string( + const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a, + typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *) + : __r_(__a) +{ + __self_view __sv = __self_view(__t).substr(__pos, __n); + __init(__sv.data(), __sv.size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif +} + +template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv) { diff --git a/libcxx/include/string_view b/libcxx/include/string_view index baba4644552..60c0ad00fc9 100644 --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -164,7 +164,6 @@ namespace std { #include <__config> #include <__string> -#include <algorithm> #include <iterator> #include <__debug> @@ -320,8 +319,8 @@ public: { if (__pos > size()) __throw_out_of_range("string_view::copy"); - size_type __rlen = _VSTD::min( __n, size() - __pos ); - copy_n(begin() + __pos, __rlen, __s ); + size_type __rlen = _VSTD::min(__n, size() - __pos); + _Traits::copy(__s, data() + __pos, __rlen); return __rlen; } diff --git a/libcxx/include/system_error b/libcxx/include/system_error index faaeaa06d05..c7e73d4ab82 100644 --- a/libcxx/include/system_error +++ b/libcxx/include/system_error @@ -219,6 +219,7 @@ bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; template <> struct hash<std::error_code>; +template <> struct hash<std::error_condition>; } // std @@ -629,6 +630,17 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<error_code> } }; +template <> +struct _LIBCPP_TYPE_VIS_ONLY hash<error_condition> + : public unary_function<error_condition, size_t> +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(const error_condition& __ec) const _NOEXCEPT + { + return static_cast<size_t>(__ec.value()); + } +}; + // system_error class _LIBCPP_TYPE_VIS system_error diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 4d24886ee9e..fbfc9d33729 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -488,6 +488,10 @@ addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT } #endif +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_DELETED_FUNCTIONS) +template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete; +#endif + struct __two {char __lx[2];}; // helper class: |