mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 01:18:52 +08:00
Fixes for LWG 2598, 2686, 2739, 2742, 2747, and 2759, which were adopted last week in Issaquah
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286858 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
@@ -1716,6 +1722,20 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
|
||||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// template <class T>
|
||||
// struct hash
|
||||
// : public unary_function<T, size_t>
|
||||
// {
|
||||
// size_t operator()(T val) const;
|
||||
// };
|
||||
|
||||
#include <system_error>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
void
|
||||
test(int i)
|
||||
{
|
||||
typedef std::error_condition T;
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
|
||||
H h;
|
||||
T ec(i, std::system_category());
|
||||
const std::size_t result = h(ec);
|
||||
LIBCPP_ASSERT(result == i);
|
||||
((void)result); // Prevent unused warning
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(0);
|
||||
test(2);
|
||||
test(10);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::gcd(false, 4);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::gcd(2, true);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::gcd<volatile bool, int>(false, 4);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::gcd<int, const bool>(2, true);
|
||||
}
|
@@ -13,7 +13,8 @@
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type, the program is ill-formed.
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
@@ -13,7 +13,8 @@
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type, the program is ill-formed.
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::lcm(false, 4);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::lcm(2, true);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::lcm<volatile bool, int>(false, 4);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::lcm<int, const bool>(2, true);
|
||||
}
|
@@ -13,7 +13,8 @@
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type, the program is ill-formed.
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
@@ -13,7 +13,8 @@
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type, the program is ill-formed.
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
166
test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
Normal file
166
test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<class _Tp>
|
||||
// basic_string(const _Tp& __t, size_type __pos, size_type __n,
|
||||
// const allocator_type& __a = allocator_type());
|
||||
//
|
||||
// Mostly we're testing string_view here
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
test(SV sv, unsigned pos, unsigned n)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
try
|
||||
{
|
||||
S s2(sv, pos, n);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(pos <= sv.size());
|
||||
unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
|
||||
assert(s2.size() == rlen);
|
||||
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
catch (std::out_of_range&)
|
||||
{
|
||||
assert(pos > sv.size());
|
||||
}
|
||||
}
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
try
|
||||
{
|
||||
S s2(sv, pos, n, a);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(pos <= sv.size());
|
||||
unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
|
||||
assert(s2.size() == rlen);
|
||||
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
|
||||
assert(s2.get_allocator() == a);
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
catch (std::out_of_range&)
|
||||
{
|
||||
assert(pos > sv.size());
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
typedef std::basic_string <char, std::char_traits<char>, A> S;
|
||||
|
||||
test<S,SV>(SV(), 0, 0);
|
||||
test<S,SV>(SV(), 0, 1);
|
||||
test<S,SV>(SV(), 1, 0);
|
||||
test<S,SV>(SV(), 1, 1);
|
||||
test<S,SV>(SV(), 1, 2);
|
||||
test<S,SV>(SV("1"), 0, 0);
|
||||
test<S,SV>(SV("1"), 0, 1);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
|
||||
|
||||
test<S,SV>(SV(), 0, 0, A(4));
|
||||
test<S,SV>(SV(), 0, 1, A(4));
|
||||
test<S,SV>(SV(), 1, 0, A(4));
|
||||
test<S,SV>(SV(), 1, 1, A(4));
|
||||
test<S,SV>(SV(), 1, 2, A(4));
|
||||
test<S,SV>(SV("1"), 0, 0, A(6));
|
||||
test<S,SV>(SV("1"), 0, 1, A(6));
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, A(8));
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A(8));
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A(8));
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A(8));
|
||||
}
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
typedef std::basic_string <char, std::char_traits<char>, A> S;
|
||||
|
||||
test<S,SV>(SV(), 0, 0);
|
||||
test<S,SV>(SV(), 0, 1);
|
||||
test<S,SV>(SV(), 1, 0);
|
||||
test<S,SV>(SV(), 1, 1);
|
||||
test<S,SV>(SV(), 1, 2);
|
||||
test<S,SV>(SV("1"), 0, 0);
|
||||
test<S,SV>(SV("1"), 0, 1);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
|
||||
|
||||
test<S,SV>(SV(), 0, 0, A());
|
||||
test<S,SV>(SV(), 0, 1, A());
|
||||
test<S,SV>(SV(), 1, 0, A());
|
||||
test<S,SV>(SV(), 1, 1, A());
|
||||
test<S,SV>(SV(), 1, 2, A());
|
||||
test<S,SV>(SV("1"), 0, 0, A());
|
||||
test<S,SV>(SV("1"), 0, 1, A());
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, A());
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A());
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A());
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A());
|
||||
}
|
||||
#endif
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
S s = "ABCD";
|
||||
SV sv = "EFGH";
|
||||
char arr[] = "IJKL";
|
||||
|
||||
S s1("CDEF", 4); // calls ctor(const char *, len)
|
||||
assert(s1 == "CDEF");
|
||||
|
||||
S s2("QRST", 0, 3); // calls ctor(string("QRST", pos, len)
|
||||
assert(s2 == "QRS");
|
||||
|
||||
S s3(sv, 0, std::string::npos); // calls ctor(T, pos, npos)
|
||||
assert(s3 == sv);
|
||||
|
||||
S s4(sv, 0, 3); // calls ctor(T, pos, len)
|
||||
assert(s4 == "EFG");
|
||||
|
||||
S s5(arr, 0, 2); // calls ctor(const char *, len)
|
||||
assert(s5 == "IJ");
|
||||
|
||||
S s6(arr, 0); // calls ctor(const char *, len)
|
||||
assert(s6 == "");
|
||||
|
||||
S s7(s.data(), 2); // calls ctor(const char *, len)
|
||||
assert(s7 == "AB");
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <ObjectType T> T* addressof(T&& r) = delete;
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
const int *p = std::addressof<const int>(0);
|
||||
}
|
@@ -20,6 +20,17 @@
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class D>
|
||||
void test2739() // LWG2739
|
||||
{
|
||||
typedef std::chrono::time_point<std::chrono::system_clock> TimePoint;
|
||||
typedef std::chrono::duration<D> Dur;
|
||||
const Dur d(5);
|
||||
TimePoint t0 = std::chrono::system_clock::from_time_t(200);
|
||||
TimePoint t1 = t0 - d;
|
||||
assert(t1 < t0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
@@ -37,4 +48,6 @@ int main()
|
||||
static_assert(t2.time_since_epoch() == Duration2(2995), "");
|
||||
}
|
||||
#endif
|
||||
test2739<int32_t>();
|
||||
test2739<uint32_t>();
|
||||
}
|
||||
|
@@ -367,7 +367,7 @@
|
||||
<tr><td><a href="http://wg21.link/LWG2588">2588</a></td><td>[fund.ts.v2] "Convertible to bool" requirement in conjunction and disjunction</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2589">2589</a></td><td>match_results can't satisfy the requirements of a container</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2591">2591</a></td><td>std::function's member template target() should not lead to undefined behaviour</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2598">2598</a></td><td>addressof works on temporaries</td><td>Issaquah</td><td>Patch ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2598">2598</a></td><td>addressof works on temporaries</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2664">2664</a></td><td>operator/ (and other append) semantics not useful if argument has root</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2665">2665</a></td><td>remove_filename() post condition is incorrect</td><td>Issaquah</td><td>See Below</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2672">2672</a></td><td>Should is_empty use error_code in its specification?</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
@@ -388,12 +388,12 @@
|
||||
<tr><td><a href="http://wg21.link/LWG2735">2735</a></td><td>std::abs(short), std::abs(signed char) and others should return int instead of double in order to be compatible with C++98 and C</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2736">2736</a></td><td>nullopt_t insufficiently constrained</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2738">2738</a></td><td>is_constructible with void types</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2739">2739</a></td><td>Issue with time_point non-member subtraction with an unsigned duration</td><td>Issaquah</td><td>Patch Ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2739">2739</a></td><td>Issue with time_point non-member subtraction with an unsigned duration</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2740">2740</a></td><td>constexpr optional<T>::operator-></td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2742">2742</a></td><td>Inconsistent string interface taking string_view</td><td>Issaquah</td><td>Patch Ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2742">2742</a></td><td>Inconsistent string interface taking string_view</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2744">2744</a></td><td>any's in_place constructors</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2745">2745</a></td><td>[fund.ts.v2] Implementability of LWG 2451</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2747">2747</a></td><td>Possibly redundant std::move in [alg.foreach]</td><td>Issaquah</td><td>Patch ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2747">2747</a></td><td>Possibly redundant std::move in [alg.foreach]</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2748">2748</a></td><td>swappable traits for optionals</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2749">2749</a></td><td>swappable traits for variants</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2750">2750</a></td><td>[fund.ts.v2] LWG 2451 conversion constructor constraint</td><td>Issaquah</td><td></td></tr>
|
||||
@@ -401,14 +401,14 @@
|
||||
<tr><td><a href="http://wg21.link/LWG2755">2755</a></td><td>[string.view.io] uses non-existent basic_string_view::to_string function</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2756">2756</a></td><td>C++ WP optional<T> should 'forward' T's implicit conversions</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2758">2758</a></td><td>std::string{}.assign("ABCDE", 0, 1) is ambiguous</td><td>Complete</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2759">2759</a></td><td>gcd / lcm and bool for the WP</td><td>Issaquah</td><td>Patch ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2759">2759</a></td><td>gcd / lcm and bool for the WP</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2760">2760</a></td><td>non-const basic_string::data should not invalidate iterators</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2765">2765</a></td><td>Did LWG 1123 go too far?</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2767">2767</a></td><td>not_fn call_wrapper can form invalid types</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2769">2769</a></td><td>Redundant const in the return type of any_cast(const any&)</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2771">2771</a></td><td>Broken Effects of some basic_string::compare functions in terms of basic_string_view</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2773">2773</a></td><td>Making std::ignore constexpr</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2777">2777</a></td><td>basic_string_view::copy should use char_traits::copy</td><td>Issaquah</td><td>Patch Ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2777">2777</a></td><td>basic_string_view::copy should use char_traits::copy</td><td>Issaquah</td><td>Complete</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2778">2778</a></td><td>basic_string_view is missing constexpr</td><td>Issaquah</td><td></td></tr>
|
||||
|
||||
<!--
|
||||
|
Reference in New Issue
Block a user