Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,57 @@
// -*- C++ -*-
//===--------------------------- __config ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_CONFIG
#define _LIBCPP_EXPERIMENTAL_CONFIG
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } }
#define _VSTD_EXPERIMENTAL std::experimental
#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
#define _LIBCPP_END_NAMESPACE_LFTS } } }
#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } }
#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr {
#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \
namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem { \
inline namespace v1 {
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
} } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES \
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace coroutines_v1 {
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES \
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
#define _VSTD_CORO _VSTD_EXPERIMENTAL::coroutines_v1
#define _VSTD_FS ::std::experimental::filesystem::v1
#endif

View File

@ -0,0 +1,90 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL___MEMORY
#define _LIBCPP_EXPERIMENTAL___MEMORY
#include <experimental/__config>
#include <experimental/utility> // for erased_type
#include <__functional_base>
#include <type_traits>
_LIBCPP_BEGIN_NAMESPACE_LFTS
template <
class _Tp, class _Alloc
, bool = uses_allocator<_Tp, _Alloc>::value
, bool = __has_allocator_type<_Tp>::value
>
struct __lfts_uses_allocator : public false_type {};
template <class _Tp, class _Alloc>
struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {};
template <class _Tp, class _Alloc, bool HasAlloc>
struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {};
template <class _Tp, class _Alloc>
struct __lfts_uses_allocator<_Tp, _Alloc, false, true>
: public integral_constant<bool
, is_convertible<_Alloc, typename _Tp::allocator_type>::value
|| is_same<erased_type, typename _Tp::allocator_type>::value
>
{};
template <bool _UsesAlloc, class _Tp, class _Alloc, class ..._Args>
struct __lfts_uses_alloc_ctor_imp
{
static const int value = 0;
};
template <class _Tp, class _Alloc, class ..._Args>
struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...>
{
static const bool __ic_first
= is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
static const bool __ic_second =
conditional<
__ic_first,
false_type,
is_constructible<_Tp, _Args..., _Alloc>
>::type::value;
static_assert(__ic_first || __ic_second,
"Request for uses allocator construction is ill-formed");
static const int value = __ic_first ? 1 : 2;
};
template <class _Tp, class _Alloc, class ..._Args>
struct __lfts_uses_alloc_ctor
: integral_constant<int,
__lfts_uses_alloc_ctor_imp<
__lfts_uses_allocator<_Tp, _Alloc>::value
, _Tp, _Alloc, _Args...
>::value
>
{};
template <class _Tp, class _Alloc, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
void __lfts_user_alloc_construct(
_Tp * __store, const _Alloc & __a, _Args &&... __args)
{
_VSTD::__user_alloc_construct_impl(
typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type()
, __store, __a, _VSTD::forward<_Args>(__args)...
);
}
_LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_EXPERIMENTAL___MEMORY */

View File

@ -0,0 +1,73 @@
// -*- C++ -*-
//===-------------------------- algorithm ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_ALGORITHM
#define _LIBCPP_EXPERIMENTAL_ALGORITHM
/*
experimental/algorithm synopsis
#include <algorithm>
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
template <class ForwardIterator, class Searcher>
ForwardIterator search(ForwardIterator first, ForwardIterator last,
const Searcher &searcher);
template <class PopulationIterator, class SampleIterator, class Distance,
class UniformRandomNumberGenerator>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n,
UniformRandomNumberGenerator &&g);
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <algorithm>
#include <type_traits>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_LFTS
template <class _ForwardIterator, class _Searcher>
_LIBCPP_INLINE_VISIBILITY
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
{ return __s(__f, __l).first; }
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
inline _LIBCPP_INLINE_VISIBILITY
_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
_SampleIterator __output_iter, _Distance __n,
_UniformRandomNumberGenerator &&__g) {
return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
}
_LIBCPP_END_NAMESPACE_LFTS
_LIBCPP_POP_MACROS
#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,59 @@
// -*- C++ -*-
//===------------------------------ chrono ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
#define _LIBCPP_EXPERIMENTAL_CHRONO
/**
experimental/chrono synopsis
// C++1y
#include <chrono>
namespace std {
namespace chrono {
namespace experimental {
inline namespace fundamentals_v1 {
// See C++14 20.12.4, customization traits
template <class Rep> constexpr bool treat_as_floating_point_v
= treat_as_floating_point<Rep>::value;
} // namespace fundamentals_v1
} // namespace experimental
} // namespace chrono
} // namespace std
*/
#include <experimental/__config>
#include <chrono>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 11
_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
= treat_as_floating_point<_Rep>::value;
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
_LIBCPP_END_NAMESPACE_CHRONO_LFTS
#endif /* _LIBCPP_STD_VER > 11 */
#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */

View File

@ -0,0 +1,296 @@
// -*- C++ -*-
//===----------------------------- coroutine -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_COROUTINE
#define _LIBCPP_EXPERIMENTAL_COROUTINE
/**
experimental/coroutine synopsis
// C++next
namespace std {
namespace experimental {
inline namespace coroutines_v1 {
// 18.11.1 coroutine traits
template <typename R, typename... ArgTypes>
class coroutine_traits;
// 18.11.2 coroutine handle
template <typename Promise = void>
class coroutine_handle;
// 18.11.2.7 comparison operators:
bool operator==(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT;
bool operator!=(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT;
bool operator<(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT;
bool operator<=(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT;
bool operator>=(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT;
bool operator>(coroutine_handle<> x, coroutine_handle<> y) _NOEXCEPT;
// 18.11.3 trivial awaitables
struct suspend_never;
struct suspend_always;
// 18.11.2.8 hash support:
template <class T> struct hash;
template <class P> struct hash<coroutine_handle<P>>;
} // namespace coroutines_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <new>
#include <type_traits>
#include <functional>
#include <memory> // for hash<T*>
#include <cstddef>
#include <cassert>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_COROUTINES
# if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler")
# else
# warning <experimental/coroutine> cannot be used with this compiler
# endif
#endif
#ifndef _LIBCPP_HAS_NO_COROUTINES
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES
template <class _Tp, class = void>
struct __coroutine_traits_sfinae {};
template <class _Tp>
struct __coroutine_traits_sfinae<
_Tp, typename __void_t<typename _Tp::promise_type>::type>
{
using promise_type = typename _Tp::promise_type;
};
template <typename _Ret, typename... _Args>
struct _LIBCPP_TEMPLATE_VIS coroutine_traits
: public __coroutine_traits_sfinae<_Ret>
{
};
template <typename _Promise = void>
class _LIBCPP_TEMPLATE_VIS coroutine_handle;
template <>
class _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
public:
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR coroutine_handle() _NOEXCEPT : __handle_(nullptr) {}
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR coroutine_handle(nullptr_t) _NOEXCEPT : __handle_(nullptr) {}
_LIBCPP_ALWAYS_INLINE
coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
__handle_ = nullptr;
return *this;
}
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR void* address() const _NOEXCEPT { return __handle_; }
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return __handle_; }
_LIBCPP_ALWAYS_INLINE
void operator()() { resume(); }
_LIBCPP_ALWAYS_INLINE
void resume() {
_LIBCPP_ASSERT(__is_suspended(),
"resume() can only be called on suspended coroutines");
_LIBCPP_ASSERT(!done(),
"resume() has undefined behavior when the coroutine is done");
__builtin_coro_resume(__handle_);
}
_LIBCPP_ALWAYS_INLINE
void destroy() {
_LIBCPP_ASSERT(__is_suspended(),
"destroy() can only be called on suspended coroutines");
__builtin_coro_destroy(__handle_);
}
_LIBCPP_ALWAYS_INLINE
bool done() const {
_LIBCPP_ASSERT(__is_suspended(),
"done() can only be called on suspended coroutines");
return __builtin_coro_done(__handle_);
}
public:
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_address(void* __addr) _NOEXCEPT {
coroutine_handle __tmp;
__tmp.__handle_ = __addr;
return __tmp;
}
// FIXME: Should from_address(nullptr) be allowed?
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
return coroutine_handle(nullptr);
}
template <class _Tp, bool _CallIsValid = false>
static coroutine_handle from_address(_Tp*) {
static_assert(_CallIsValid,
"coroutine_handle<void>::from_address cannot be called with "
"non-void pointers");
}
private:
bool __is_suspended() const _NOEXCEPT {
// FIXME actually implement a check for if the coro is suspended.
return __handle_;
}
template <class _PromiseT> friend class coroutine_handle;
void* __handle_;
};
// 18.11.2.7 comparison operators:
inline _LIBCPP_ALWAYS_INLINE
bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
return __x.address() == __y.address();
}
inline _LIBCPP_ALWAYS_INLINE
bool operator!=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
return !(__x == __y);
}
inline _LIBCPP_ALWAYS_INLINE
bool operator<(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
return less<void*>()(__x.address(), __y.address());
}
inline _LIBCPP_ALWAYS_INLINE
bool operator>(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
return __y < __x;
}
inline _LIBCPP_ALWAYS_INLINE
bool operator<=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
return !(__x > __y);
}
inline _LIBCPP_ALWAYS_INLINE
bool operator>=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
return !(__x < __y);
}
template <typename _Promise>
class _LIBCPP_TEMPLATE_VIS coroutine_handle : public coroutine_handle<> {
using _Base = coroutine_handle<>;
public:
#ifndef _LIBCPP_CXX03_LANG
// 18.11.2.1 construct/reset
using coroutine_handle<>::coroutine_handle;
#else
_LIBCPP_ALWAYS_INLINE coroutine_handle() _NOEXCEPT : _Base() {}
_LIBCPP_ALWAYS_INLINE coroutine_handle(nullptr_t) _NOEXCEPT : _Base(nullptr) {}
#endif
_LIBCPP_INLINE_VISIBILITY
coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
_Base::operator=(nullptr);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
_Promise& promise() const {
return *reinterpret_cast<_Promise*>(
__builtin_coro_promise(this->__handle_, __alignof(_Promise), false));
}
public:
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_address(void* __addr) _NOEXCEPT {
coroutine_handle __tmp;
__tmp.__handle_ = __addr;
return __tmp;
}
// NOTE: this overload isn't required by the standard but is needed so
// the deleted _Promise* overload doesn't make from_address(nullptr)
// ambiguous.
// FIXME: should from_address work with nullptr?
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
return coroutine_handle(nullptr);
}
template <class _Tp, bool _CallIsValid = false>
static coroutine_handle from_address(_Tp*) {
static_assert(_CallIsValid,
"coroutine_handle<promise_type>::from_address cannot be called with "
"non-void pointers");
}
template <bool _CallIsValid = false>
static coroutine_handle from_address(_Promise*) {
static_assert(_CallIsValid,
"coroutine_handle<promise_type>::from_address cannot be used with "
"pointers to the coroutine's promise type; use 'from_promise' instead");
}
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
typedef typename remove_cv<_Promise>::type _RawPromise;
coroutine_handle __tmp;
__tmp.__handle_ = __builtin_coro_promise(
_VSTD::addressof(const_cast<_RawPromise&>(__promise)),
__alignof(_Promise), true);
return __tmp;
}
};
struct _LIBCPP_TYPE_VIS suspend_never {
_LIBCPP_ALWAYS_INLINE
bool await_ready() const _NOEXCEPT { return true; }
_LIBCPP_ALWAYS_INLINE
void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
_LIBCPP_ALWAYS_INLINE
void await_resume() const _NOEXCEPT {}
};
struct _LIBCPP_TYPE_VIS suspend_always {
_LIBCPP_ALWAYS_INLINE
bool await_ready() const _NOEXCEPT { return false; }
_LIBCPP_ALWAYS_INLINE
void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
_LIBCPP_ALWAYS_INLINE
void await_resume() const _NOEXCEPT {}
};
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_COROUTINES
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct hash<_VSTD_CORO::coroutine_handle<_Tp> > {
using __arg_type = _VSTD_CORO::coroutine_handle<_Tp>;
_LIBCPP_INLINE_VISIBILITY
size_t operator()(__arg_type const& __v) const _NOEXCEPT
{return hash<void*>()(__v.address());}
};
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_COROUTINES)
#endif /* _LIBCPP_EXPERIMENTAL_COROUTINE */

View File

@ -0,0 +1,47 @@
// -*- C++ -*-
//===--------------------------- deque ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_DEQUE
#define _LIBCPP_EXPERIMENTAL_DEQUE
/*
experimental/deque synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
namespace pmr {
template <class T>
using deque = std::deque<T,polymorphic_allocator<T>>;
} // namespace pmr
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <deque>
#include <experimental/memory_resource>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
template <class _ValueT>
using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */

View File

@ -0,0 +1,304 @@
// -*- C++ -*-
//===-------------------------- dynarray ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_DYNARRAY
#define _LIBCPP_DYNARRAY
/*
dynarray synopsis
namespace std { namespace experimental {
template< typename T >
class dynarray
{
// types:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
public:
// construct/copy/destroy:
explicit dynarray(size_type c);
dynarray(size_type c, const T& v);
dynarray(const dynarray& d);
dynarray(initializer_list<T>);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, initializer_list<T>, const Alloc& alloc);
dynarray& operator=(const dynarray&) = delete;
~dynarray();
// iterators:
iterator begin() noexcept;
const_iterator begin() const noexcept;
const_iterator cbegin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cend() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator crbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crend() const noexcept;
// capacity:
size_type size() const noexcept;
size_type max_size() const noexcept;
bool empty() const noexcept;
// element access:
reference operator[](size_type n);
const_reference operator[](size_type n) const;
reference front();
const_reference front() const;
reference back();
const_reference back() const;
const_reference at(size_type n) const;
reference at(size_type n);
// data access:
T* data() noexcept;
const T* data() const noexcept;
// mutating member functions:
void fill(const T& v);
};
}} // std::experimental
*/
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__functional_base>
#include <iterator>
#include <stdexcept>
#include <initializer_list>
#include <new>
#include <algorithm>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
namespace std { namespace experimental { inline namespace __array_extensions_v1 {
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_DYNARRAY dynarray
{
public:
// types:
typedef dynarray __self;
typedef _Tp value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
private:
size_t __size_;
value_type * __base_;
_LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {}
static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
{
if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
__throw_bad_array_length();
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
}
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept
{
_VSTD::__libcpp_deallocate (static_cast<void *> (__ptr));
}
public:
_LIBCPP_INLINE_VISIBILITY
explicit dynarray(size_type __c);
_LIBCPP_INLINE_VISIBILITY
dynarray(size_type __c, const value_type& __v);
_LIBCPP_INLINE_VISIBILITY
dynarray(const dynarray& __d);
_LIBCPP_INLINE_VISIBILITY
dynarray(initializer_list<value_type>);
// We're not implementing these right now.
// Updated with the resolution of LWG issue #2255
// template <typename _Alloc>
// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c);
// template <typename _Alloc>
// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v);
// template <typename _Alloc>
// dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d);
// template <typename _Alloc>
// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>);
dynarray& operator=(const dynarray&) = delete;
_LIBCPP_INLINE_VISIBILITY
~dynarray();
// iterators:
inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); }
inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); }
inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); }
inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); }
inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); }
inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); }
inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
// capacity:
inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; }
inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; }
inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; }
// element access:
inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; }
inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; }
inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; }
inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; }
inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; }
inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; }
inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const;
inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n);
// data access:
inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; }
inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; }
// mutating member functions:
inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); }
};
template <class _Tp>
inline
dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
{
__base_ = __allocate (__c);
value_type *__data = data ();
for ( __size_ = 0; __size_ < __c; ++__size_, ++__data )
::new (__data) value_type;
}
template <class _Tp>
inline
dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
{
__base_ = __allocate (__c);
value_type *__data = data ();
for ( __size_ = 0; __size_ < __c; ++__size_, ++__data )
::new (__data) value_type (__v);
}
template <class _Tp>
inline
dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
{
size_t sz = __il.size();
__base_ = __allocate (sz);
value_type *__data = data ();
auto src = __il.begin();
for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src )
::new (__data) value_type (*src);
}
template <class _Tp>
inline
dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
{
size_t sz = __d.size();
__base_ = __allocate (sz);
value_type *__data = data ();
auto src = __d.begin();
for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src )
::new (__data) value_type (*src);
}
template <class _Tp>
inline
dynarray<_Tp>::~dynarray()
{
value_type *__data = data () + __size_;
for ( size_t i = 0; i < __size_; ++i )
(--__data)->value_type::~value_type();
__deallocate_value( __base_ );
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename dynarray<_Tp>::reference
dynarray<_Tp>::at(size_type __n)
{
if (__n >= __size_)
__throw_out_of_range("dynarray::at");
return data()[__n];
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename dynarray<_Tp>::const_reference
dynarray<_Tp>::at(size_type __n) const
{
if (__n >= __size_)
__throw_out_of_range("dynarray::at");
return data()[__n];
}
}}}
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Alloc>
struct _LIBCPP_TEMPLATE_VIS uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#endif // if _LIBCPP_STD_VER > 11
#endif // _LIBCPP_DYNARRAY

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
// -*- C++ -*-
//===--------------------------- forward_list -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST
#define _LIBCPP_EXPERIMENTAL_FORWARD_LIST
/*
experimental/forward_list synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
namespace pmr {
template <class T>
using forward_list = std::forward_list<T,polymorphic_allocator<T>>;
} // namespace pmr
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <forward_list>
#include <experimental/memory_resource>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
template <class _ValueT>
using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */

View File

@ -0,0 +1,462 @@
// -*- C++ -*-
//===-------------------------- functional --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL
#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL
/*
experimental/functional synopsis
#include <algorithm>
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
// See C++14 20.9.9, Function object binders
template <class T> constexpr bool is_bind_expression_v
= is_bind_expression<T>::value;
template <class T> constexpr int is_placeholder_v
= is_placeholder<T>::value;
// 4.2, Class template function
template<class> class function; // undefined
template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
template<class R, class... ArgTypes>
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
// 4.3, Searchers
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
class default_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher;
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
default_searcher<ForwardIterator, BinaryPredicate>
make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last,
BinaryPredicate pred = BinaryPredicate());
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
boyer_moore_searcher<RandomAccessIterator, Hash, BinaryPredicate>
make_boyer_moore_searcher(
RandomAccessIterator pat_first, RandomAccessIterator pat_last,
Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
boyer_moore_horspool_searcher<RandomAccessIterator, Hash, BinaryPredicate>
make_boyer_moore_horspool_searcher(
RandomAccessIterator pat_first, RandomAccessIterator pat_last,
Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
} // namespace fundamentals_v1
} // namespace experimental
template<class R, class... ArgTypes, class Alloc>
struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
} // namespace std
*/
#include <experimental/__config>
#include <functional>
#include <algorithm>
#include <type_traits>
#include <vector>
#include <array>
#include <unordered_map>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_LFTS
#if _LIBCPP_STD_VER > 11
// default searcher
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
_LIBCPP_TYPE_VIS
class default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
_BinaryPredicate __p = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__p) {}
template <typename _ForwardIterator2>
_LIBCPP_INLINE_VISIBILITY
pair<_ForwardIterator2, _ForwardIterator2>
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
{
return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
}
private:
_ForwardIterator __first_;
_ForwardIterator __last_;
_BinaryPredicate __pred_;
};
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
default_searcher<_ForwardIterator, _BinaryPredicate>
make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
{
return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p);
}
template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*useArray*/> class _BMSkipTable;
// General case for BM data searching; use a map
template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
public: // TODO private:
typedef _Value value_type;
typedef _Key key_type;
const _Value __default_value_;
std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;
public:
_LIBCPP_INLINE_VISIBILITY
_BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
: __default_value_(__default), __table(__sz, __hf, __pred) {}
_LIBCPP_INLINE_VISIBILITY
void insert(const key_type &__key, value_type __val)
{
__table [__key] = __val; // Would skip_.insert (val) be better here?
}
_LIBCPP_INLINE_VISIBILITY
value_type operator [](const key_type & __key) const
{
auto __it = __table.find (__key);
return __it == __table.end() ? __default_value_ : __it->second;
}
};
// Special case small numeric values; use an array
template<class _Key, typename _Value, class _Hash, class _BinaryPredicate>
class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> {
private:
typedef _Value value_type;
typedef _Key key_type;
typedef typename std::make_unsigned<key_type>::type unsigned_key_type;
typedef std::array<value_type, _VSTD::numeric_limits<unsigned_key_type>::max()> skip_map;
skip_map __table;
public:
_LIBCPP_INLINE_VISIBILITY
_BMSkipTable(std::size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
{
std::fill_n(__table.begin(), __table.size(), __default);
}
_LIBCPP_INLINE_VISIBILITY
void insert(key_type __key, value_type __val)
{
__table[static_cast<unsigned_key_type>(__key)] = __val;
}
_LIBCPP_INLINE_VISIBILITY
value_type operator [](key_type __key) const
{
return __table[static_cast<unsigned_key_type>(__key)];
}
};
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_TYPE_VIS
class boyer_moore_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate,
_VSTD::is_integral<value_type>::value && // what about enums?
sizeof(value_type) == 1 &&
is_same<_Hash, hash<value_type>>::value &&
is_same<_BinaryPredicate, equal_to<>>::value
> skip_table_type;
public:
boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
__skip_{make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
__suffix_{make_shared<vector<difference_type>>(__pattern_length_ + 1)}
{
// build the skip table
for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
__skip_->insert(*__f, __i);
this->__build_suffix_table ( __first_, __last_, __pred_ );
}
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
static_assert ( std::is_same<
typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
>::value,
"Corpus and Pattern iterators must point to the same type" );
if (__f == __l ) return make_pair(__l, __l); // empty corpus
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
if ( __pattern_length_ > _VSTD::distance (__f, __l))
return make_pair(__l, __l);
// Do the search
return this->__search(__f, __l);
}
public: // TODO private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
_BinaryPredicate __pred_;
difference_type __pattern_length_;
shared_ptr<skip_table_type> __skip_;
shared_ptr<vector<difference_type>> __suffix_;
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
__search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
_RandomAccessIterator2 __cur = __f;
const _RandomAccessIterator2 __last = __l - __pattern_length_;
const skip_table_type & __skip = *__skip_.get();
const vector<difference_type> & __suffix = *__suffix_.get();
while (__cur <= __last)
{
// Do we match right where we are?
difference_type __j = __pattern_length_;
while (__pred_(__first_ [__j-1], __cur [__j-1])) {
__j--;
// We matched - we're done!
if ( __j == 0 )
return make_pair(__cur, __cur + __pattern_length_);
}
// Since we didn't match, figure out how far to skip forward
difference_type __k = __skip[__cur [ __j - 1 ]];
difference_type __m = __j - __k - 1;
if (__k < __j && __m > __suffix[ __j ])
__cur += __m;
else
__cur += __suffix[ __j ];
}
return make_pair(__l, __l); // We didn't find anything
}
template<typename _Iterator, typename _Container>
void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix )
{
const std::size_t __count = _VSTD::distance(__f, __l);
__prefix[0] = 0;
std::size_t __k = 0;
for ( std::size_t __i = 1; __i < __count; ++__i )
{
while ( __k > 0 && !__pred ( __f[__k], __f[__i] ))
__k = __prefix [ __k - 1 ];
if ( __pred ( __f[__k], __f[__i] ))
__k++;
__prefix [ __i ] = __k;
}
}
void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_BinaryPredicate __pred)
{
const std::size_t __count = _VSTD::distance(__f, __l);
vector<difference_type> & __suffix = *__suffix_.get();
if (__count > 0)
{
_VSTD::vector<value_type> __scratch(__count);
__compute_bm_prefix(__f, __l, __pred, __scratch);
for ( std::size_t __i = 0; __i <= __count; __i++ )
__suffix[__i] = __count - __scratch[__count-1];
typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter;
__compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch);
for ( std::size_t __i = 0; __i < __count; __i++ )
{
const std::size_t __j = __count - __scratch[__i];
const difference_type __k = __i - __scratch[__i] + 1;
if (__suffix[__j] > __k)
__suffix[__j] = __k;
}
}
}
};
template<class _RandomAccessIterator,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
{
return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
}
// boyer-moore-horspool
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_TYPE_VIS
class boyer_moore_horspool_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate,
_VSTD::is_integral<value_type>::value && // what about enums?
sizeof(value_type) == 1 &&
is_same<_Hash, hash<value_type>>::value &&
is_same<_BinaryPredicate, equal_to<>>::value
> skip_table_type;
public:
boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__pred),
__pattern_length_(_VSTD::distance(__first_, __last_)),
__skip_{_VSTD::make_shared<skip_table_type>(__pattern_length_, __pattern_length_, __hf, __pred_)}
{
// build the skip table
if ( __f != __l )
{
__l = __l - 1;
for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
__skip_->insert(*__f, __pattern_length_ - 1 - __i);
}
}
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
{
static_assert ( std::is_same<
typename std::decay<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
typename std::decay<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
>::value,
"Corpus and Pattern iterators must point to the same type" );
if (__f == __l ) return make_pair(__l, __l); // empty corpus
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
if ( __pattern_length_ > _VSTD::distance (__f, __l))
return make_pair(__l, __l);
// Do the search
return this->__search(__f, __l);
}
private:
_RandomAccessIterator1 __first_;
_RandomAccessIterator1 __last_;
_BinaryPredicate __pred_;
difference_type __pattern_length_;
shared_ptr<skip_table_type> __skip_;
template <typename _RandomAccessIterator2>
pair<_RandomAccessIterator2, _RandomAccessIterator2>
__search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const {
_RandomAccessIterator2 __cur = __f;
const _RandomAccessIterator2 __last = __l - __pattern_length_;
const skip_table_type & __skip = *__skip_.get();
while (__cur <= __last)
{
// Do we match right where we are?
difference_type __j = __pattern_length_;
while (__pred_(__first_[__j-1], __cur[__j-1]))
{
__j--;
// We matched - we're done!
if ( __j == 0 )
return make_pair(__cur, __cur + __pattern_length_);
}
__cur += __skip[__cur[__pattern_length_-1]];
}
return make_pair(__l, __l);
}
};
template<class _RandomAccessIterator,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>,
class _BinaryPredicate = equal_to<>>
_LIBCPP_INLINE_VISIBILITY
boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>
make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
_Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ())
{
return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p);
}
#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_LFTS
_LIBCPP_POP_MACROS
#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */

View File

@ -0,0 +1,114 @@
// -*- C++ -*-
//===----------------------------- iterator -------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_ITERATOR
#define _LIBCPP_EXPERIMENTAL_ITERATOR
/*
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
template <class DelimT, class charT = char, class traits = char_traits<charT>>
class ostream_joiner {
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_ostream<charT, traits> ostream_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
ostream_joiner(ostream_type& s, const DelimT& delimiter);
ostream_joiner(ostream_type& s, DelimT&& delimiter);
template<typename T>
ostream_joiner& operator=(const T& value);
ostream_joiner& operator*() noexcept;
ostream_joiner& operator++() noexcept;
ostream_joiner& operator++(int) noexcept;
private:
ostream_type* out_stream; // exposition only
DelimT delim; // exposition only
bool first_element; // exposition only
};
template <class charT, class traits, class DelimT>
ostream_joiner<decay_t<DelimT>, charT, traits>
make_ostream_joiner(basic_ostream<charT, traits>& os, DelimT&& delimiter);
} // inline namespace fundamentals_v2
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#if _LIBCPP_STD_VER > 11
#include <iterator>
_LIBCPP_BEGIN_NAMESPACE_LFTS
template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>>
class ostream_joiner {
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_ostream<char_type,traits_type> ostream_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
ostream_joiner(ostream_type& __os, _Delim&& __d)
: __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
ostream_joiner(ostream_type& __os, const _Delim& __d)
: __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
template<typename _Tp>
ostream_joiner& operator=(const _Tp& __v)
{
if (!__first)
*__output_iter << __delim;
__first = false;
*__output_iter << __v;
return *this;
}
ostream_joiner& operator*() _NOEXCEPT { return *this; }
ostream_joiner& operator++() _NOEXCEPT { return *this; }
ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
private:
ostream_type* __output_iter;
_Delim __delim;
bool __first;
};
template <class _CharT, class _Traits, class _Delim>
ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)
{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }
_LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_STD_VER > 11 */
#endif // _LIBCPP_EXPERIMENTAL_ITERATOR

View File

@ -0,0 +1,47 @@
// -*- C++ -*-
//===--------------------------- list ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_LIST
#define _LIBCPP_EXPERIMENTAL_LIST
/*
experimental/list synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
namespace pmr {
template <class T>
using list = std::list<T,polymorphic_allocator<T>>;
} // namespace pmr
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <list>
#include <experimental/memory_resource>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
template <class _ValueT>
using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>;
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_LIST */

View File

@ -0,0 +1,57 @@
// -*- C++ -*-
//===----------------------------- map ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_MAP
#define _LIBCPP_EXPERIMENTAL_MAP
/*
experimental/map synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
namespace pmr {
template <class Key, class T, class Compare = less<Key>>
using map = std::map<Key, T, Compare,
polymorphic_allocator<pair<const Key,T>>>;
template <class Key, class T, class Compare = less<Key>>
using multimap = std::multimap<Key, T, Compare,
polymorphic_allocator<pair<const Key,T>>>;
} // namespace pmr
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <map>
#include <experimental/memory_resource>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
template <class _Key, class _Value, class _Compare = less<_Key>>
using map = _VSTD::map<_Key, _Value, _Compare,
polymorphic_allocator<pair<const _Key, _Value>>>;
template <class _Key, class _Value, class _Compare = less<_Key>>
using multimap = _VSTD::multimap<_Key, _Value, _Compare,
polymorphic_allocator<pair<const _Key, _Value>>>;
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_MAP */

View File

@ -0,0 +1,427 @@
// -*- C++ -*-
//===------------------------ memory_resource -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE
#define _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE
/**
experimental/memory_resource synopsis
// C++1y
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
namespace pmr {
class memory_resource;
bool operator==(const memory_resource& a,
const memory_resource& b) noexcept;
bool operator!=(const memory_resource& a,
const memory_resource& b) noexcept;
template <class Tp> class polymorphic_allocator;
template <class T1, class T2>
bool operator==(const polymorphic_allocator<T1>& a,
const polymorphic_allocator<T2>& b) noexcept;
template <class T1, class T2>
bool operator!=(const polymorphic_allocator<T1>& a,
const polymorphic_allocator<T2>& b) noexcept;
// The name resource_adaptor_imp is for exposition only.
template <class Allocator> class resource_adaptor_imp;
template <class Allocator>
using resource_adaptor = resource_adaptor_imp<
allocator_traits<Allocator>::rebind_alloc<char>>;
// Global memory resources
memory_resource* new_delete_resource() noexcept;
memory_resource* null_memory_resource() noexcept;
// The default memory resource
memory_resource* set_default_resource(memory_resource* r) noexcept;
memory_resource* get_default_resource() noexcept;
// Standard memory resources
struct pool_options;
class synchronized_pool_resource;
class unsynchronized_pool_resource;
class monotonic_buffer_resource;
} // namespace pmr
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <experimental/__memory>
#include <limits>
#include <memory>
#include <new>
#include <stdexcept>
#include <tuple>
#include <type_traits>
#include <utility>
#include <cstddef>
#include <cstdlib>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
// Round __s up to next multiple of __a.
inline _LIBCPP_INLINE_VISIBILITY
size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
{
_LIBCPP_ASSERT(__s + __a > __s, "aligned allocation size overflows");
return (__s + __a - 1) & ~(__a - 1);
}
// 8.5, memory.resource
class _LIBCPP_TEMPLATE_VIS memory_resource
{
static const size_t __max_align = alignof(max_align_t);
// 8.5.2, memory.resource.public
public:
virtual ~memory_resource() = default;
_LIBCPP_INLINE_VISIBILITY
void* allocate(size_t __bytes, size_t __align = __max_align)
{ return do_allocate(__bytes, __align); }
_LIBCPP_INLINE_VISIBILITY
void deallocate(void * __p, size_t __bytes, size_t __align = __max_align)
{ do_deallocate(__p, __bytes, __align); }
_LIBCPP_INLINE_VISIBILITY
bool is_equal(memory_resource const & __other) const _NOEXCEPT
{ return do_is_equal(__other); }
// 8.5.3, memory.resource.priv
protected:
virtual void* do_allocate(size_t, size_t) = 0;
virtual void do_deallocate(void*, size_t, size_t) = 0;
virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;
};
// 8.5.4, memory.resource.eq
inline _LIBCPP_INLINE_VISIBILITY
bool operator==(memory_resource const & __lhs,
memory_resource const & __rhs) _NOEXCEPT
{
return &__lhs == &__rhs || __lhs.is_equal(__rhs);
}
inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(memory_resource const & __lhs,
memory_resource const & __rhs) _NOEXCEPT
{
return !(__lhs == __rhs);
}
_LIBCPP_FUNC_VIS
memory_resource * new_delete_resource() _NOEXCEPT;
_LIBCPP_FUNC_VIS
memory_resource * null_memory_resource() _NOEXCEPT;
_LIBCPP_FUNC_VIS
memory_resource * get_default_resource() _NOEXCEPT;
_LIBCPP_FUNC_VIS
memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;
// 8.6, memory.polymorphic.allocator.class
// 8.6.1, memory.polymorphic.allocator.overview
template <class _ValueType>
class _LIBCPP_TEMPLATE_VIS polymorphic_allocator
{
public:
typedef _ValueType value_type;
// 8.6.2, memory.polymorphic.allocator.ctor
_LIBCPP_INLINE_VISIBILITY
polymorphic_allocator() _NOEXCEPT
: __res_(_VSTD_LFTS_PMR::get_default_resource())
{}
_LIBCPP_INLINE_VISIBILITY
polymorphic_allocator(memory_resource * __r) _NOEXCEPT
: __res_(__r)
{}
polymorphic_allocator(polymorphic_allocator const &) = default;
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
polymorphic_allocator(polymorphic_allocator<_Tp> const & __other) _NOEXCEPT
: __res_(__other.resource())
{}
polymorphic_allocator &
operator=(polymorphic_allocator const &) = delete;
// 8.6.3, memory.polymorphic.allocator.mem
_LIBCPP_INLINE_VISIBILITY
_ValueType* allocate(size_t __n) {
if (__n > __max_size()) {
__throw_length_error(
"std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
}
return static_cast<_ValueType*>(
__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))
);
}
_LIBCPP_INLINE_VISIBILITY
void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT {
_LIBCPP_ASSERT(__n <= __max_size(),
"deallocate called for size which exceeds max_size()");
__res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
}
template <class _Tp, class ..._Ts>
_LIBCPP_INLINE_VISIBILITY
void construct(_Tp* __p, _Ts &&... __args)
{
_VSTD_LFTS::__lfts_user_alloc_construct(
__p, resource(), _VSTD::forward<_Ts>(__args)...
);
}
template <class _T1, class _T2, class ..._Args1, class ..._Args2>
_LIBCPP_INLINE_VISIBILITY
void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
tuple<_Args1...> __x, tuple<_Args2...> __y)
{
::new ((void*)__p) pair<_T1, _T2>(piecewise_construct
, __transform_tuple(
typename __lfts_uses_alloc_ctor<
_T1, memory_resource*, _Args1...
>::type()
, _VSTD::move(__x)
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
)
, __transform_tuple(
typename __lfts_uses_alloc_ctor<
_T2, memory_resource*, _Args2...
>::type()
, _VSTD::move(__y)
, typename __make_tuple_indices<sizeof...(_Args2)>::type{}
)
);
}
template <class _T1, class _T2>
_LIBCPP_INLINE_VISIBILITY
void construct(pair<_T1, _T2>* __p) {
construct(__p, piecewise_construct, tuple<>(), tuple<>());
}
template <class _T1, class _T2, class _Up, class _Vp>
_LIBCPP_INLINE_VISIBILITY
void construct(pair<_T1, _T2> * __p, _Up && __u, _Vp && __v) {
construct(__p, piecewise_construct
, _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__u))
, _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__v)));
}
template <class _T1, class _T2, class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY
void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> const & __pr) {
construct(__p, piecewise_construct
, _VSTD::forward_as_tuple(__pr.first)
, _VSTD::forward_as_tuple(__pr.second));
}
template <class _T1, class _T2, class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY
void construct(pair<_T1, _T2> * __p, pair<_U1, _U2> && __pr){
construct(__p, piecewise_construct
, _VSTD::forward_as_tuple(_VSTD::forward<_U1>(__pr.first))
, _VSTD::forward_as_tuple(_VSTD::forward<_U2>(__pr.second)));
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
void destroy(_Tp * __p) _NOEXCEPT
{ __p->~_Tp(); }
_LIBCPP_INLINE_VISIBILITY
polymorphic_allocator
select_on_container_copy_construction() const _NOEXCEPT
{ return polymorphic_allocator(); }
_LIBCPP_INLINE_VISIBILITY
memory_resource * resource() const _NOEXCEPT
{ return __res_; }
private:
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<_Args&&...>
__transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,
__tuple_indices<_Idx...>) const
{
return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);
}
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<allocator_arg_t const&, memory_resource*, _Args&&...>
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
__tuple_indices<_Idx...>) const
{
using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>;
return _Tup(allocator_arg, resource(),
_VSTD::get<_Idx>(_VSTD::move(__t))...);
}
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<_Args&&..., memory_resource*>
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
__tuple_indices<_Idx...>) const
{
using _Tup = tuple<_Args&&..., memory_resource*>;
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
}
_LIBCPP_INLINE_VISIBILITY
size_t __max_size() const _NOEXCEPT
{ return numeric_limits<size_t>::max() / sizeof(value_type); }
memory_resource * __res_;
};
// 8.6.4, memory.polymorphic.allocator.eq
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
bool operator==(polymorphic_allocator<_Tp> const & __lhs,
polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
{
return *__lhs.resource() == *__rhs.resource();
}
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
{
return !(__lhs == __rhs);
}
// 8.7, memory.resource.adaptor
// 8.7.1, memory.resource.adaptor.overview
template <class _CharAlloc>
class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp
: public memory_resource
{
using _CTraits = allocator_traits<_CharAlloc>;
static_assert(is_same<typename _CTraits::value_type, char>::value
&& is_same<typename _CTraits::pointer, char*>::value
&& is_same<typename _CTraits::void_pointer, void*>::value, "");
static const size_t _MaxAlign = alignof(max_align_t);
using _Alloc = typename _CTraits::template rebind_alloc<
typename aligned_storage<_MaxAlign, _MaxAlign>::type
>;
using _ValueType = typename _Alloc::value_type;
_Alloc __alloc_;
public:
typedef _CharAlloc allocator_type;
__resource_adaptor_imp() = default;
__resource_adaptor_imp(__resource_adaptor_imp const &) = default;
__resource_adaptor_imp(__resource_adaptor_imp &&) = default;
// 8.7.2, memory.resource.adaptor.ctor
_LIBCPP_INLINE_VISIBILITY
explicit __resource_adaptor_imp(allocator_type const & __a)
: __alloc_(__a)
{}
_LIBCPP_INLINE_VISIBILITY
explicit __resource_adaptor_imp(allocator_type && __a)
: __alloc_(_VSTD::move(__a))
{}
__resource_adaptor_imp &
operator=(__resource_adaptor_imp const &) = default;
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const
{ return __alloc_; }
// 8.7.3, memory.resource.adaptor.mem
protected:
virtual void * do_allocate(size_t __bytes, size_t)
{
if (__bytes > __max_size()) {
__throw_length_error(
"std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)"
" 'bytes' exceeds maximum supported size");
}
size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;
return __alloc_.allocate(__s);
}
virtual void do_deallocate(void * __p, size_t __bytes, size_t)
{
_LIBCPP_ASSERT(__bytes <= __max_size(),
"do_deallocate called for size which exceeds the maximum allocation size");
size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;
__alloc_.deallocate((_ValueType*)__p, __s);
}
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT {
__resource_adaptor_imp const * __p
= dynamic_cast<__resource_adaptor_imp const *>(&__other);
return __p ? __alloc_ == __p->__alloc_ : false;
}
private:
_LIBCPP_INLINE_VISIBILITY
size_t __max_size() const _NOEXCEPT {
return numeric_limits<size_t>::max() - _MaxAlign;
}
};
template <class _Alloc>
using resource_adaptor = __resource_adaptor_imp<
typename allocator_traits<_Alloc>::template rebind_alloc<char>
>;
_LIBCPP_END_NAMESPACE_LFTS_PMR
_LIBCPP_POP_MACROS
#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */

View File

@ -0,0 +1,119 @@
// -*- C++ -*-
//===--------------------------- numeric ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
#define _LIBCPP_EXPERIMENTAL_NUMERIC
/*
experimental/numeric synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
// 13.1.2, Greatest common divisor
template<class M, class N>
constexpr common_type_t<M,N> gcd(M m, N n);
// 13.1.3, Least common multiple
template<class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n);
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <numeric>
#include <type_traits> // is_integral
#include <limits> // numeric_limits
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
#if _LIBCPP_STD_VER > 11
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs;
template <typename _Result, typename _Source>
struct __abs<_Result, _Source, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept
{
if (__t >= 0) return __t;
if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
return -__t;
}
};
template <typename _Result, typename _Source>
struct __abs<_Result, _Source, false> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept { return __t; }
};
template<class _Tp>
_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
inline _Tp __gcd(_Tp __m, _Tp __n)
{
static_assert((!is_signed<_Tp>::value), "" );
return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
}
template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
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>(_VSTD_LFTS_V2::__gcd(
static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
}
template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
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;
using _Rp = common_type_t<_Tp,_Up>;
_Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
_Rp __val2 = __abs<_Rp, _Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
}
_LIBCPP_END_NAMESPACE_LFTS_V2
#endif /* _LIBCPP_STD_VER > 11 */
_LIBCPP_POP_MACROS
#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
// -*- C++ -*-
//===------------------------------ ratio ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_RATIO
#define _LIBCPP_EXPERIMENTAL_RATIO
/**
experimental/ratio synopsis
C++1y
#include <ratio>
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
// See C++14 20.11.5, ratio comparison
template <class R1, class R2> constexpr bool ratio_equal_v
= ratio_equal<R1, R2>::value;
template <class R1, class R2> constexpr bool ratio_not_equal_v
= ratio_not_equal<R1, R2>::value;
template <class R1, class R2> constexpr bool ratio_less_v
= ratio_less<R1, R2>::value;
template <class R1, class R2> constexpr bool ratio_less_equal_v
= ratio_less_equal<R1, R2>::value;
template <class R1, class R2> constexpr bool ratio_greater_v
= ratio_greater<R1, R2>::value;
template <class R1, class R2> constexpr bool ratio_greater_equal_v
= ratio_greater_equal<R1, R2>::value;
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#if _LIBCPP_STD_VER > 11
#include <ratio>
_LIBCPP_BEGIN_NAMESPACE_LFTS
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
= ratio_equal<_R1, _R2>::value;
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v
= ratio_not_equal<_R1, _R2>::value;
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v
= ratio_less<_R1, _R2>::value;
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v
= ratio_less_equal<_R1, _R2>::value;
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
= ratio_greater<_R1, _R2>::value;
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
= ratio_greater_equal<_R1, _R2>::value;
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
_LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_STD_VER > 11 */
#endif // _LIBCPP_EXPERIMENTAL_RATIO

View File

@ -0,0 +1,62 @@
// -*- C++ -*-
//===----------------------------- regex ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_REGEX
#define _LIBCPP_EXPERIMENTAL_REGEX
/*
experimental/regex synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
namespace pmr {
template <class BidirectionalIterator>
using match_results =
std::match_results<BidirectionalIterator,
polymorphic_allocator<sub_match<BidirectionalIterator>>>;
typedef match_results<const char*> cmatch;
typedef match_results<const wchar_t*> wcmatch;
typedef match_results<string::const_iterator> smatch;
typedef match_results<wstring::const_iterator> wsmatch;
} // namespace pmr
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <regex>
#include <experimental/string>
#include <experimental/memory_resource>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
template <class _BiDirIter>
using match_results =
_VSTD::match_results<_BiDirIter,
polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>;
typedef match_results<const char*> cmatch;
typedef match_results<const wchar_t*> wcmatch;
typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
_LIBCPP_END_NAMESPACE_LFTS_PMR
#endif /* _LIBCPP_EXPERIMENTAL_REGEX */

Some files were not shown because too many files have changed in this diff Show More