Vendor import of libc++ trunk r306325:

https://llvm.org/svn/llvm-project/libcxx/trunk@306325
This commit is contained in:
dim 2017-06-26 20:33:34 +00:00
parent 37ec3a3c04
commit 5defb46a4e
41 changed files with 899 additions and 163 deletions

View File

@ -118,6 +118,7 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
cxxabi.h
PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include
${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
NO_DEFAULT_PATH
)
if (LIBCXX_TARGETING_MSVC)

View File

@ -1154,6 +1154,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
__attribute__((availability(watchos,strict,introduced=3.0)))
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
__attribute__((availability(macosx,strict,introduced=10.12))) \
__attribute__((availability(ios,strict,introduced=10.0))) \
@ -1175,25 +1176,35 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
__attribute__((availability(macosx,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION \
__attribute__((availability(macosx,strict,introduced=10.13))) \
__attribute__((availability(ios,strict,introduced=11.0))) \
__attribute__((availability(tvos,strict,introduced=11.0))) \
__attribute__((availability(watchos,strict,introduced=4.0)))
#else
#define _LIBCPP_AVAILABILITY_SHARED_MUTEX
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
#define _LIBCPP_AVAILABILITY_FUTURE_ERROR
#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION
#endif
// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
#ifdef _LIBCPP_NO_EXCEPTIONS
#define _LIBCPP_AVAILABILITY_DYNARRAY
#define _LIBCPP_AVAILABILITY_FUTURE
#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
#else
#define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
#define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST \
_LIBCPP_AVAILABILITY_BAD_ANY_CAST
#endif
// Availability of stream API in the dylib got dropped and re-added. The
@ -1202,9 +1213,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
// availability(ios,introduced=7.0)
#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1090) || \
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ <= 70000))
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
#define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
#endif

View File

@ -89,7 +89,7 @@ inline namespace fundamentals_v1 {
_LIBCPP_BEGIN_NAMESPACE_LFTS
class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
{
public:
virtual const char* what() const _NOEXCEPT;
@ -98,6 +98,7 @@ public:
#if _LIBCPP_STD_VER > 11 // C++ > 11
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
void __throw_bad_any_cast()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
@ -506,7 +507,7 @@ void swap(any & __lhs, any & __rhs) _NOEXCEPT
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any const & __v)
{
static_assert(
@ -522,7 +523,7 @@ _ValueType any_cast(any const & __v)
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any & __v)
{
static_assert(
@ -537,7 +538,7 @@ _ValueType any_cast(any & __v)
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
_ValueType any_cast(any && __v)
{
static_assert(

View File

@ -193,20 +193,20 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operato
#endif
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
#endif
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
#endif
#endif

View File

@ -81,6 +81,20 @@ template<class InputIterator, class OutputIterator, class T, class BinaryOperati
exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init, BinaryOperation binary_op); // C++17
template<class InputIterator, class OutputIterator>
OutputIterator
inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
template<class InputIterator, class OutputIterator, class BinaryOperation>
OutputIterator
inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op); // C++17
template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
OutputIterator
inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op, T init); // C++17
template<class InputIterator, class OutputIterator, class T,
class BinaryOperation, class UnaryOperation>
OutputIterator
@ -88,6 +102,21 @@ template<class InputIterator, class OutputIterator, class T,
OutputIterator result, T init,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template<class InputIterator, class OutputIterator,
class BinaryOperation, class UnaryOperation>
OutputIterator
transform_inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result,
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
template<class InputIterator, class OutputIterator,
class BinaryOperation, class UnaryOperation, class T>
OutputIterator
transform_inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result,
BinaryOperation binary_op, UnaryOperation unary_op,
T init); // C++17
template <class InputIterator, class OutputIterator>
OutputIterator
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
@ -295,6 +324,38 @@ exclusive_scan(_InputIterator __first, _InputIterator __last,
return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
}
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _Tp __init)
{
for (; __first != __last; ++__first, (void) ++__result) {
__init = __b(__init, *__first);
*__result = __init;
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp>
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b)
{
if (__first != __last) {
typename std::iterator_traits<_InputIterator>::value_type __init = *__first;
*__result++ = __init;
if (++__first != __last)
return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);
}
return __result;
}
template <class _InputIterator, class _OutputIterator>
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result)
{
return _VSTD::inclusive_scan(__first, __last, __result, std::plus<>());
}
template <class _InputIterator, class _OutputIterator, class _Tp,
class _BinaryOp, class _UnaryOp>
inline _LIBCPP_INLINE_VISIBILITY
@ -316,6 +377,32 @@ transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
{
for (; __first != __last; ++__first, (void) ++__result) {
__init = __b(__init, __u(*__first));
*__result = __init;
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
{
if (__first != __last) {
typename std::iterator_traits<_InputIterator>::value_type __init = __u(*__first);
*__result++ = __init;
if (++__first != __last)
return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
}
return __result;
}
#endif
template <class _InputIterator, class _OutputIterator>

View File

@ -1116,6 +1116,8 @@ public:
template <
class _Arg,
enable_if_t<!is_same_v<decay_t<_Arg>, variant>, int> = 0,
enable_if_t<!__is_inplace_type<decay_t<_Arg>>::value, int> = 0,
enable_if_t<!__is_inplace_index<decay_t<_Arg>>::value, int> = 0,
class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
size_t _Ip =
__find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,

View File

@ -261,7 +261,8 @@ private:
string_view_pair separate_filename(string_view_t const & s) {
if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""};
auto pos = s.find_last_of('.');
if (pos == string_view_t::npos) return string_view_pair{s, string_view{}};
if (pos == string_view_t::npos)
return string_view_pair{s, string_view_t{}};
return string_view_pair{s.substr(0, pos), s.substr(pos)};
}
@ -396,7 +397,7 @@ int path::__compare(string_view_t __s) const {
size_t hash_value(const path& __p) noexcept {
auto PP = PathParser::CreateBegin(__p.native());
size_t hash_value = 0;
std::hash<string_view> hasher;
std::hash<string_view_t> hasher;
while (PP) {
hash_value = __hash_combine(hash_value, hasher(*PP));
++PP;

View File

@ -36,15 +36,15 @@ int main()
auto f = for_each_test(0);
Iter it = std::for_each_n(Iter(ia), 0, std::ref(f));
assert(it == Iter(ia));
assert(f.count == 0);
assert(f.count == 0);
}
{
auto f = for_each_test(0);
Iter it = std::for_each_n(Iter(ia), s, std::ref(f));
assert(it == Iter(ia+s));
assert(f.count == s);
assert(f.count == s);
for (unsigned i = 0; i < s; ++i)
assert(ia[i] == static_cast<int>(i+1));
}
@ -52,9 +52,9 @@ int main()
{
auto f = for_each_test(0);
Iter it = std::for_each_n(Iter(ia), 1, std::ref(f));
assert(it == Iter(ia+1));
assert(f.count == 1);
assert(f.count == 1);
for (unsigned i = 0; i < 1; ++i)
assert(ia[i] == static_cast<int>(i+2));
}

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -9,12 +9,7 @@
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: availability=macosx
// <experimental/any>

View File

@ -35,7 +35,7 @@ test(It i, typename std::iterator_traits<It>::difference_type n, It x)
#if TEST_STD_VER > 14
template <class It>
constexpr bool
constexpr bool
constepxr_test(It i, typename std::iterator_traits<It>::difference_type n, It x)
{
std::advance(i, n);

View File

@ -71,5 +71,5 @@ int main()
static_assert( constexpr_test(s+1, s), "" );
}
#endif
}

View File

@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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
// REQUIRES: availability=macosx10.12
// test availability of new/delete operators introduced in c++17.
#include <new>
int main () {
int *p0 = new ((std::align_val_t)16) int(1);
(void)p0;
int *p1 = new ((std::align_val_t)16) int[1];
(void)p1;
// expected-error@-4 {{call to unavailable function 'operator new': introduced in macOS 10.13}}
// expected-note@new:* {{candidate function has been explicitly made unavailable}}
// expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'const std::nothrow_t' for 2nd argument}}
// expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'void *' for 2nd argument}}
// expected-note@new:* {{candidate function not viable: requires single argument '__sz', but 2 arguments were provided}}
// expected-note@new:* {{candidate function not viable: requires 3 arguments, but 2 were provided}}
// expected-error@-9 {{call to unavailable function 'operator new[]': introduced in macOS 10.13}}
// expected-note@new:* {{candidate function has been explicitly made unavailable}}
// expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'const std::nothrow_t' for 2nd argument}}
// expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'void *' for 2nd argument}}
// expected-note@new:* {{candidate function not viable: requires single argument '__sz', but 2 arguments were provided}}
// expected-note@new:* {{candidate function not viable: requires 3 arguments, but 2 were provided}}
return 0;
}

View File

@ -13,7 +13,7 @@
// template<class InputIterator, class OutputIterator, class T>
// OutputIterator exclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result, T init);
//
//
#include <numeric>
#include <vector>
@ -26,7 +26,7 @@ void
test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast)
{
std::vector<typename std::iterator_traits<Iter1>::value_type> v;
// Not in place
std::exclusive_scan(first, last, std::back_inserter(v), init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
@ -35,7 +35,7 @@ test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast)
v.clear();
v.assign(first, last);
std::exclusive_scan(v.begin(), v.end(), v.begin(), init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}

View File

@ -13,7 +13,7 @@
// template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
// OutputIterator
// exclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result,
// OutputIterator result,
// T init, BinaryOperation binary_op); // C++17
#include <numeric>
@ -36,7 +36,7 @@ test(Iter1 first, Iter1 last, T init, Op op, Iter2 rFirst, Iter2 rLast)
v.clear();
v.assign(first, last);
std::exclusive_scan(v.begin(), v.end(), v.begin(), init, op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
@ -84,4 +84,3 @@ int main()
}
}
}

View File

@ -0,0 +1,102 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T>
// OutputIterator inclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result, T init);
//
#include <numeric>
#include <vector>
#include <cassert>
#include "test_iterators.h"
template <class Iter1, class Iter2>
void
test(Iter1 first, Iter1 last, Iter2 rFirst, Iter2 rLast)
{
std::vector<typename std::iterator_traits<Iter1>::value_type> v;
// Not in place
std::inclusive_scan(first, last, std::back_inserter(v));
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
v.clear();
v.assign(first, last);
std::inclusive_scan(v.begin(), v.end(), v.begin());
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
void
test()
{
int ia[] = {1, 3, 5, 7, 9};
const int pRes[] = {1, 4, 9, 16, 25};
const unsigned sa = sizeof(ia) / sizeof(ia[0]);
static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure
for (unsigned int i = 0; i < sa; ++i )
test(Iter(ia), Iter(ia + i), pRes, pRes + i);
}
int triangle(int n) { return n*(n+1)/2; }
// Basic sanity
void basic_tests()
{
{
std::vector<int> v(10);
std::fill(v.begin(), v.end(), 3);
std::inclusive_scan(v.begin(), v.end(), v.begin());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == (int)(i+1) * 3);
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 0);
std::inclusive_scan(v.begin(), v.end(), v.begin());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == triangle(i));
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 1);
std::inclusive_scan(v.begin(), v.end(), v.begin());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == triangle(i + 1));
}
{
std::vector<int> v, res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res));
assert(res.empty());
}
}
int main()
{
basic_tests();
// All the iterator categories
test<input_iterator <const int*> >();
test<forward_iterator <const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test< int*>();
}

View File

@ -0,0 +1,112 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
// OutputIterator
// inclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result,
// BinaryOperation binary_op); // C++17
#include <numeric>
#include <vector>
#include <cassert>
#include <iostream>
#include "test_iterators.h"
template <class Iter1, class T, class Op, class Iter2>
void
test(Iter1 first, Iter1 last, Op op, Iter2 rFirst, Iter2 rLast)
{
std::vector<typename std::iterator_traits<Iter1>::value_type> v;
// Not in place
std::inclusive_scan(first, last, std::back_inserter(v), op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
v.clear();
v.assign(first, last);
std::inclusive_scan(v.begin(), v.end(), v.begin(), op);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
void
test()
{
int ia[] = {1, 3, 5, 7, 9};
const int pRes[] = {1, 4, 9, 16, 25};
const int mRes[] = {1, 3, 15, 105, 945};
const unsigned sa = sizeof(ia) / sizeof(ia[0]);
static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure
static_assert(sa == sizeof(mRes) / sizeof(mRes[0])); // just to be sure
for (unsigned int i = 0; i < sa; ++i ) {
test(Iter(ia), Iter(ia + i), std::plus<>(), pRes, pRes + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), mRes, mRes + i);
}
}
int triangle(int n) { return n*(n+1)/2; }
// Basic sanity
void basic_tests()
{
{
std::vector<int> v(10);
std::fill(v.begin(), v.end(), 3);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == (int)(i+1) * 3);
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 0);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == triangle(i));
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 1);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == triangle(i + 1));
}
{
std::vector<int> v, res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>());
assert(res.empty());
}
}
int main()
{
basic_tests();
// All the iterator categories
// test<input_iterator <const int*> >();
// test<forward_iterator <const int*> >();
// test<bidirectional_iterator<const int*> >();
// test<random_access_iterator<const int*> >();
// test<const int*>();
// test< int*>();
}

View File

@ -0,0 +1,128 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
// OutputIterator
// inclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result,
// BinaryOperation binary_op, T init); // C++17
#include <numeric>
#include <vector>
#include <cassert>
#include "test_iterators.h"
template <class Iter1, class T, class Op, class Iter2>
void
test(Iter1 first, Iter1 last, Op op, T init, Iter2 rFirst, Iter2 rLast)
{
std::vector<typename std::iterator_traits<Iter1>::value_type> v;
// Not in place
std::inclusive_scan(first, last, std::back_inserter(v), op, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// In place
v.clear();
v.assign(first, last);
std::inclusive_scan(v.begin(), v.end(), v.begin(), op, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
void
test()
{
int ia[] = {1, 3, 5, 7, 9};
const int pRes[] = {1, 4, 9, 16, 25};
const int mRes[] = {1, 3, 15, 105, 945};
const unsigned sa = sizeof(ia) / sizeof(ia[0]);
static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure
static_assert(sa == sizeof(mRes) / sizeof(mRes[0])); // just to be sure
for (unsigned int i = 0; i < sa; ++i ) {
test(Iter(ia), Iter(ia + i), std::plus<>(), 0, pRes, pRes + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), 1, mRes, mRes + i);
}
}
int triangle(int n) { return n*(n+1)/2; }
// Basic sanity
void basic_tests()
{
{
std::vector<int> v(10);
std::fill(v.begin(), v.end(), 3);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), 50);
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == 50 + (int)(i+1) * 3);
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 0);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), 40);
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == 40 + triangle(i));
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 1);
std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), 30);
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == 30 + triangle(i + 1));
}
{
std::vector<int> v, res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), 40);
assert(res.empty());
}
// Make sure that the calculations are done using the init typedef
{
std::vector<unsigned char> v(10);
std::iota(v.begin(), v.end(), 1);
std::vector<int> res;
std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), 1);
assert(res.size() == 10);
int j = 1;
assert(res[0] == 1);
for (size_t i = 1; i < v.size(); ++i)
{
j *= i + 1;
assert(res[i] == j);
}
}
}
int main()
{
basic_tests();
// All the iterator categories
test<input_iterator <const int*> >();
test<forward_iterator <const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test< int*>();
}

View File

@ -12,7 +12,7 @@
// template<class InputIterator, class T, class BinaryOperation>
// T reduce(InputIterator first, InputIterator last, T init, BinaryOperation op);
#include <numeric>
#include <cassert>

View File

@ -10,7 +10,7 @@
// <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T,
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result, T init,
@ -64,11 +64,11 @@ test()
{
int ia[] = { 1, 3, 5, 7, 9};
const int pResI0[] = { 0, 1, 4, 9, 16}; // with identity
const int mResI0[] = { 0, 0, 0, 0, 0};
const int mResI0[] = { 0, 0, 0, 0, 0};
const int pResN0[] = { 0, -1, -4, -9, -16}; // with negate
const int mResN0[] = { 0, 0, 0, 0, 0};
const int pResI2[] = { 2, 3, 6, 11, 18}; // with identity
const int mResI2[] = { 2, 2, 6, 30, 210};
const int mResI2[] = { 2, 2, 6, 30, 210};
const int pResN2[] = { 2, 1, -2, -7, -14}; // with negate
const int mResN2[] = { 2, -2, 6, -30, 210};
const unsigned sa = sizeof(ia) / sizeof(ia[0]);
@ -149,7 +149,7 @@ void basic_tests()
int main()
{
basic_tests();
// All the iterator categories
test<input_iterator <const int*> >();
test<forward_iterator <const int*> >();

View File

@ -0,0 +1,133 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result,
// BinaryOperation binary_op,
// UnaryOperation unary_op);
#include <numeric>
#include <vector>
#include <cassert>
#include <iostream>
#include "test_iterators.h"
template <class _Tp = void>
struct identity : std::unary_function<_Tp, _Tp>
{
constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
};
template <>
struct identity<void>
{
template <class _Tp>
constexpr auto operator()(_Tp&& __x) const
_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
-> decltype (_VSTD::forward<_Tp>(__x))
{ return _VSTD::forward<_Tp>(__x); }
};
template <class Iter1, class BOp, class UOp, class Iter2>
void
test(Iter1 first, Iter1 last, BOp bop, UOp uop, Iter2 rFirst, Iter2 rLast)
{
std::vector<typename std::iterator_traits<Iter1>::value_type> v;
// Test not in-place
std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// Test in-place
v.clear();
v.assign(first, last);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
void
test()
{
int ia[] = { 1, 3, 5, 7, 9};
const int pResI0[] = { 1, 4, 9, 16, 25}; // with identity
const int mResI0[] = { 1, 3, 15, 105, 945};
const int pResN0[] = { -1, -4, -9, -16, -25}; // with negate
const int mResN0[] = { -1, 3, -15, 105, -945};
const unsigned sa = sizeof(ia) / sizeof(ia[0]);
static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure
static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure
static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0])); // just to be sure
static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure
for (unsigned int i = 0; i < sa; ++i ) {
test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), pResI0, pResI0 + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), mResI0, mResI0 + i);
test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), pResN0, pResN0 + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), mResN0, mResN0 + i);
}
}
int triangle(int n) { return n*(n+1)/2; }
// Basic sanity
void basic_tests()
{
{
std::vector<int> v(10);
std::fill(v.begin(), v.end(), 3);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>());
std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == (int)(i+1) * 3);
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 0);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == triangle(i));
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 1);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>());
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == triangle(i + 1));
}
{
std::vector<int> v, res;
std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), identity<>());
assert(res.empty());
}
}
int main()
{
basic_tests();
// All the iterator categories
test<input_iterator <const int*> >();
test<forward_iterator <const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test< int*>();
}

View File

@ -0,0 +1,160 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
// OutputIterator result,
// BinaryOperation binary_op,
// UnaryOperation unary_op,
// T init);
#include <numeric>
#include <vector>
#include <cassert>
#include "test_iterators.h"
template <class _Tp = void>
struct identity : std::unary_function<_Tp, _Tp>
{
constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
};
template <>
struct identity<void>
{
template <class _Tp>
constexpr auto operator()(_Tp&& __x) const
_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
-> decltype (_VSTD::forward<_Tp>(__x))
{ return _VSTD::forward<_Tp>(__x); }
};
template <class Iter1, class BOp, class UOp, class T, class Iter2>
void
test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
{
std::vector<typename std::iterator_traits<Iter1>::value_type> v;
// Test not in-place
std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
// Test in-place
v.clear();
v.assign(first, last);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop, init);
assert(std::equal(v.begin(), v.end(), rFirst, rLast));
}
template <class Iter>
void
test()
{
int ia[] = { 1, 3, 5, 7, 9};
const int pResI0[] = { 1, 4, 9, 16, 25}; // with identity
const int mResI0[] = { 0, 0, 0, 0, 0};
const int pResN0[] = { -1, -4, -9, -16, -25}; // with negate
const int mResN0[] = { 0, 0, 0, 0, 0};
const int pResI2[] = { 3, 6, 11, 18, 27}; // with identity
const int mResI2[] = { 2, 6, 30, 210, 1890};
const int pResN2[] = { 1, -2, -7, -14, -23}; // with negate
const int mResN2[] = { -2, 6, -30, 210, -1890};
const unsigned sa = sizeof(ia) / sizeof(ia[0]);
static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure
static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure
static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0])); // just to be sure
static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure
static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0])); // just to be sure
static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0])); // just to be sure
static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0])); // just to be sure
static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0])); // just to be sure
for (unsigned int i = 0; i < sa; ++i ) {
test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 0, pResI0, pResI0 + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 0, mResI0, mResI0 + i);
test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 0, pResN0, pResN0 + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 2, pResI2, pResI2 + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 2, mResI2, mResI2 + i);
test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 2, pResN2, pResN2 + i);
test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i);
}
}
int triangle(int n) { return n*(n+1)/2; }
// Basic sanity
void basic_tests()
{
{
std::vector<int> v(10);
std::fill(v.begin(), v.end(), 3);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 50);
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == 50 + (int) (i + 1) * 3);
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 0);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 30);
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == 30 + triangle(i));
}
{
std::vector<int> v(10);
std::iota(v.begin(), v.end(), 1);
std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 40);
for (size_t i = 0; i < v.size(); ++i)
assert(v[i] == 40 + triangle(i + 1));
}
{
std::vector<int> v, res;
std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), identity<>(), 1);
assert(res.empty());
}
// Make sure that the calculations are done using the init typedef
{
std::vector<unsigned char> v(10);
std::iota(v.begin(), v.end(), 1);
std::vector<int> res;
std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), identity<>(), 1);
assert(res.size() == 10);
int j = 1;
assert(res[0] == 1);
for (size_t i = 1; i < res.size(); ++i)
{
j *= i + 1;
assert(res[i] == j);
}
}
}
int main()
{
basic_tests();
// All the iterator categories
test<input_iterator <const int*> >();
test<forward_iterator <const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test< int*>();
}

View File

@ -14,8 +14,8 @@
// class BinaryOperation, class UnaryOperation>
// T transform_reduce(InputIterator1 first1, InputIterator1 last1,
// T init, BinaryOperation binary_op, UnaryOperation unary_op);
//
//
#include <numeric>
#include <cassert>
@ -58,7 +58,7 @@ template <class Iter1, class T, class BOp, class UOp>
void
test(Iter1 first1, Iter1 last1, T init, BOp bOp, UOp uOp, T x)
{
static_assert( std::is_same_v<T,
static_assert( std::is_same_v<T,
decltype(std::transform_reduce(first1, last1, init, bOp, uOp))> );
assert(std::transform_reduce(first1, last1, init, bOp, uOp) == x);
}
@ -93,7 +93,7 @@ template <typename T, typename Init>
void test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init,
static_assert( std::is_same_v<Init,
decltype(std::transform_reduce(p, p, Init{}, std::plus<>(), identity<>()))> );
}

View File

@ -24,7 +24,7 @@ template <class Iter1, class Iter2, class T>
void
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
{
static_assert( std::is_same_v<T,
static_assert( std::is_same_v<T,
decltype(std::transform_reduce(first1, last1, first2, init))> );
assert(std::transform_reduce(first1, last1, first2, init) == x);
}
@ -52,7 +52,7 @@ template <typename T, typename Init>
void test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init,
static_assert( std::is_same_v<Init,
decltype(std::transform_reduce(p, p, p, Init{}))> );
}

View File

@ -15,8 +15,8 @@
// T transform_reduce(InputIterator1 first1, InputIterator1 last1,
// InputIterator2 first2, T init,
// BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
//
//
#include <numeric>
#include <cassert>
@ -26,7 +26,7 @@ template <class Iter1, class Iter2, class T, class Op1, class Op2>
void
test(Iter1 first1, Iter1 last1, Iter2 first2, T init, Op1 op1, Op2 op2, T x)
{
static_assert( std::is_same_v<T,
static_assert( std::is_same_v<T,
decltype(std::transform_reduce(first1, last1, first2, init, op1, op2))> );
assert(std::transform_reduce(first1, last1, first2, init, op1, op2) == x);
}
@ -54,7 +54,7 @@ template <typename T, typename Init>
void test_return_type()
{
T *p = nullptr;
static_assert( std::is_same_v<Init,
static_assert( std::is_same_v<Init,
decltype(std::transform_reduce(p, p, p, Init{}, std::plus<>(), std::multiplies<>()))> );
}

View File

@ -111,7 +111,7 @@ int main()
{
static_assert(!std::is_convertible<A1<int>, A2<int>>::value, "");
static_assert(!std::is_convertible<
std::scoped_allocator_adaptor<A1<int>>,
std::scoped_allocator_adaptor<A1<int>>,
std::scoped_allocator_adaptor<A2<int>>>::value, "");
}
}

View File

@ -12,7 +12,7 @@
// class function<R(ArgTypes...)>
// function(const function& f);
// function(const function&& f);
// function(function&& f);
#include <functional>
#include <memory>

View File

@ -157,7 +157,7 @@ int main()
test<int>(3);
static_assert(constexpr_test<int>(), "" );
static_assert(constexpr_test<int>(3), "" );
{
optional<const int> o(42);
optional<const int> o2(std::move(o));

View File

@ -16,7 +16,7 @@
// ~tuple();
// C++17 added:
// The destructor of tuple shall be a trivial destructor
// The destructor of tuple shall be a trivial destructor
// if (is_trivially_destructible_v<Types> && ...) is true.
#include <tuple>

View File

@ -64,18 +64,22 @@ void test_decomp_tuple() {
void test_decomp_pair() {
typedef std::pair<int, double> T;
{
T s{99, 42.1};
T s{99, 42.5};
auto [m1, m2] = s;
auto& [r1, r2] = s;
assert(m1 == 99);
assert(m2 == 42.5);
assert(&r1 == &std::get<0>(s));
assert(&r2 == &std::get<1>(s));
}
{
T const s{99, 42.1};
T const s{99, 42.5};
auto [m1, m2] = s;
auto& [r1, r2] = s;
assert(m1 == 99);
assert(m2 == 42.5);
assert(&r1 == &std::get<0>(s));
assert(&r2 == &std::get<1>(s));
}
}
@ -86,14 +90,22 @@ void test_decomp_array() {
auto [m1, m2, m3] = s;
auto& [r1, r2, r3] = s;
assert(m1 == 99);
assert(m2 == 42);
assert(m3 == -1);
assert(&r1 == &std::get<0>(s));
assert(&r2 == &std::get<1>(s));
assert(&r3 == &std::get<2>(s));
}
{
T const s{{99, 42, -1}};
auto [m1, m2, m3] = s;
auto& [r1, r2, r3] = s;
assert(m1 == 99);
assert(m2 == 42);
assert(m3 == -1);
assert(&r1 == &std::get<0>(s));
assert(&r2 == &std::get<1>(s));
assert(&r3 == &std::get<2>(s));
}
}

View File

@ -16,7 +16,7 @@
// ~pair()
// C++17 added:
// The destructor of pair shall be a trivial destructor
// The destructor of pair shall be a trivial destructor
// if (is_trivially_destructible_v<T1> && is_trivially_destructible_v<T2>) is true.

View File

@ -37,6 +37,9 @@ struct NoThrowT {
NoThrowT(int) noexcept(true) {}
};
struct AnyConstructible { template <typename T> AnyConstructible(T&&) {} };
struct NoConstructible { NoConstructible() = delete; };
void test_T_ctor_noexcept() {
{
using V = std::variant<Dummy, NoThrowT>;
@ -62,6 +65,17 @@ void test_T_ctor_sfinae() {
static_assert(!std::is_constructible<V, int>::value,
"no matching constructor");
}
{
using V = std::variant<AnyConstructible, NoConstructible>;
static_assert(
!std::is_constructible<V, std::in_place_type_t<NoConstructible>>::value,
"no matching constructor");
static_assert(!std::is_constructible<V, std::in_place_index_t<1>>::value,
"no matching constructor");
}
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int, int &&>;

View File

@ -231,12 +231,17 @@ public:
const bool MemCounter::disable_checking = false;
#endif
MemCounter globalMemCounter((MemCounter::MemCounterCtorArg_()));
inline MemCounter* getGlobalMemCounter() {
static MemCounter counter((MemCounter::MemCounterCtorArg_()));
return &counter;
}
MemCounter &globalMemCounter = *getGlobalMemCounter();
#ifndef DISABLE_NEW_COUNT
void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
globalMemCounter.newCalled(s);
getGlobalMemCounter()->newCalled(s);
void* ret = std::malloc(s);
if (ret == nullptr)
detail::throw_bad_alloc_helper();
@ -245,21 +250,21 @@ void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
void operator delete(void* p) TEST_NOEXCEPT
{
globalMemCounter.deleteCalled(p);
getGlobalMemCounter()->deleteCalled(p);
std::free(p);
}
void* operator new[](std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
globalMemCounter.newArrayCalled(s);
getGlobalMemCounter()->newArrayCalled(s);
return operator new(s);
}
void operator delete[](void* p) TEST_NOEXCEPT
{
globalMemCounter.deleteArrayCalled(p);
getGlobalMemCounter()->deleteArrayCalled(p);
operator delete(p);
}

View File

@ -55,6 +55,7 @@ void assertEmpty(std::experimental::any const& a) {
// Assert that an 'any' object stores the specified 'Type' and 'value'.
template <class Type>
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
void assertContains(std::experimental::any const& a, int value = 1) {
assert(!a.empty());
RTTI_ASSERT(a.type() == typeid(Type));
@ -64,6 +65,7 @@ void assertContains(std::experimental::any const& a, int value = 1) {
// Modify the value of a "test type" stored within an any to the specified
// 'value'.
template <class Type>
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
void modifyValue(std::experimental::any& a, int value) {
assert(!a.empty());
RTTI_ASSERT(a.type() == typeid(Type));

View File

@ -36,7 +36,7 @@
<!--*********************************************************************-->
<p>This is a temporary page; please check the c++1z status <a href="http://libcxx.llvm.org/cxx1z_status.html">here</a></p>
<p>This page shows the status of the papers and issues that are expected to be adopted in Issaquah.</p>
<p>This page shows the status of the papers and issues that are expected to be adopted in Toronto.</p>
<p>The groups that have contributed papers:
<ul>
@ -45,7 +45,7 @@
<li>SG1 - Study group #1 (Concurrency working group)</li>
</ul>
</p>
<h3>Paper Status</h3>
<table id="papers" border="1">
<tr><th>Paper #</th><th>Group</th><th>Paper Name</th><th>Meeting</th><th>Status</th><th>First released version</th></tr>
@ -59,71 +59,41 @@
<table id="issues" border="1">
<tr><th>Issue #</th><th>Issue Name</th><th>Meeting</th><th>Status</th></tr>
<tr><td><a href="http://wg21.link/LWG2260">2260</a></td><td>Missing requirement for Allocator::pointer</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2768">2768</a></td><td>any_cast and move semantics</td><td>Kona</td><td></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&amp;)</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2781">2781</a></td><td>Contradictory requirements for std::function and std::reference_wrapper</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2782">2782</a></td><td>scoped_allocator_adaptor constructors must be constrained</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2784">2784</a></td><td>Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parse</td><td>Kona</td><td><i>Patch Ready</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2785">2785</a></td><td>quoted should work with basic_string_view</td><td>Kona</td><td><i>We do this already</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2786">2786</a></td><td>Annex C should mention shared_ptr changes for array support</td><td>Kona</td><td><i>Nothing to do</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2787">2787</a></td><td>&sect;[file_status.cons] doesn't match class definition</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2789">2789</a></td><td>Equivalence of contained objects</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2794">2794</a></td><td>Missing requirements for allocator pointers</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2795">2795</a></td><td>&sect;[global.functions] provides incorrect example of ADL use</td><td>Kona</td><td><i>Nothing to do</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2804">2804</a></td><td>Unconditional constexpr default constructor for istream_iterator</td><td>Kona</td><td><i>We do this already</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2812">2812</a></td><td>Range access is available with &lt;string_view&gt;</td><td>Kona</td><td><i>We do this already</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2824">2824</a></td><td>list::sort should say that the order of elements is unspecified if an exception is thrown</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2826">2826</a></td><td>string_view iterators use old wording</td><td>Kona</td><td><i>Nothing to do</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2834">2834</a></td><td>Resolution LWG 2223 is missing wording about end iterators</td><td>Kona</td><td><i>Nothing to do</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2835">2835</a></td><td>LWG 2536 seems to misspecify &lt;tgmath.h&gt;</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2837">2837</a></td><td>gcd and lcm should support a wider range of input values</td><td>Kona</td><td><i>We do this already</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2838">2838</a></td><td>is_literal_type specification needs a little cleanup</td><td>Kona</td><td><i>Nothing to do</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2842">2842</a></td><td>in_place_t check for optional::optional(U&amp;&amp;) should decay U</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2850">2850</a></td><td>std::function move constructor does unnecessary work</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2853">2853</a></td><td>Possible inconsistency in specification of erase in [vector.modifiers]</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2855">2855</a></td><td>std::throw_with_nested("string_literal")</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2444">2444</a></td><td>Inconsistent complexity for std::sort_heap</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2593">2593</a></td><td>Moved-from state of Allocators</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2597">2597</a></td><td>std::log misspecified for complex numbers</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2783">2783</a></td><td>stack::emplace() and queue::emplace() should return decltype(auto)</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2932">2932</a></td><td>Constraints on parallel algorithm implementations are underspecified</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2937">2937</a></td><td>Is equivalent("existing_thing", "not_existing_thing") an error?</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2940">2940</a></td><td>result_of specification also needs a little cleanup</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2942">2942</a></td><td>LWG 2873's resolution missed weak_ptr::owner_before</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2954">2954</a></td><td>Specialization of the convenience variable templates should be prohibited</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2961">2961</a></td><td>Bad postcondition for set_default_resource</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2966">2966</a></td><td>Incomplete resolution of US 74</td><td>Toronto</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2974">2974</a></td><td>Diagnose out of bounds tuple_element/variant_alternative</td><td>Toronto</td><td></td></tr>
<tr><td></td><td><center><b>Priority 1 Bugs</b></center></td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2665">2665</a></td><td>remove_filename() post condition is incorrect</td><td>Kona</td><td>We do this already</td></tr>
<tr><td><a href="http://wg21.link/LWG2806">2806</a></td><td>Base class of bad_optional_access</td><td>Kona</td><td><i>We do this already</i></td></tr>
<tr><td><a href="http://wg21.link/LWG2857">2857</a></td><td>{variant,optional,any}::emplace should return the constructed value</td><td>Kona</td><td></td></tr>
</table>
<h3>Comments about the issues</h3>
<ul>
<li>2260 - Check our current allocators to make sure we do this</li>
<li>2768 - Resolution is "apply 2769"</li>
<li>2769 - This should be easy; trick will be devising tests.</li>
<li>2781 - </li>
<li>2782 - Looks straightforward.</li>
<li>2784 - Patch Ready</li>
<li>2785 - We do this already.</li>
<li>2786 - Nothing to do; just moving words around</li>
<li>2787 - Eric? </li>
<li>2789 - I don't think there are any code changes required here</li>
<li>2794 - I don't think there are any code changes required here - maybe a static_assert.</li>
<li>2795 - Nothing to do; just moving words around</li>
<li>2804 - We do this already.</li>
<li>2812 - We do this already.</li>
<li>2824 - Nothing do to here, but we should add some throwing sort tests.</li>
<li>2826 - Nothing to do; just moving words around</li>
<li>2834 - Nothing to do; just moving words around</li>
<li>2835 - I'm pretty sure we already do this.</li>
<li>2837 - Added some tests to ensure we do this already.</li>
<li>2838 - Nothing to do; just moving words around</li>
<li>2842 - This should be easy; trick will be devising tests.</li>
<li>2850 - I think we already do this.</li>
<li>2853 - I think that this will be mostly adding tests.</li>
<li>2855 - This should be easy; trick will be devising tests.</li></li>
<li></li>
<li>2665 - We do this already.</li>
<li>2806 - We do this already.</li>
<li>2857 - This is the subject of several NB comments.</li>
<li>2444 - </li>
<li>2593 - </li>
<li>2597 - I think we do this already; probably needs tests</li>
<li>2783 - should be easy to change; needs tests</li>
<li>2932 - We're not doing the parallel algorithms yet.</li>
<li>2937 - file system; Eric?</li>
<li>2940 - We haven't implemented result_of yet, but I don't think that this will require any changes.</li>
<li>2942 - all of our owner_before overloads are already noexcept; just need to update the tests.</li>
<li>2954 - I don't think there's anything to do here.</li>
<li>2961 - We haven't implemented the PMR stuff yet.</li>
<li>2966 - Wording cleanup; no code or test changes needed.</li>
<li>2974 - I have some code lying around that does this.</li>
</ul>
<p>Last Updated: 7-Feb-2017</p>
<p>Last Updated: 25-Jun-2017</p>
</div>
</body>
</html>