mirror of
https://github.com/ziglang/zig.git
synced 2025-01-31 06:11:07 +00:00
libcxx headers 8.0.0rc3
This commit is contained in:
parent
bc8c4ec608
commit
5cecb5e479
273
libcxx/include/CMakeLists.txt
Normal file
273
libcxx/include/CMakeLists.txt
Normal file
@ -0,0 +1,273 @@
|
||||
set(files
|
||||
__bit_reference
|
||||
__bsd_locale_defaults.h
|
||||
__bsd_locale_fallbacks.h
|
||||
__errc
|
||||
__debug
|
||||
__functional_03
|
||||
__functional_base
|
||||
__functional_base_03
|
||||
__hash_table
|
||||
__libcpp_version
|
||||
__locale
|
||||
__mutex_base
|
||||
__node_handle
|
||||
__nullptr
|
||||
__split_buffer
|
||||
__sso_allocator
|
||||
__std_stream
|
||||
__string
|
||||
__threading_support
|
||||
__tree
|
||||
__tuple
|
||||
__undef_macros
|
||||
algorithm
|
||||
any
|
||||
array
|
||||
atomic
|
||||
bit
|
||||
bitset
|
||||
cassert
|
||||
ccomplex
|
||||
cctype
|
||||
cerrno
|
||||
cfenv
|
||||
cfloat
|
||||
charconv
|
||||
chrono
|
||||
cinttypes
|
||||
ciso646
|
||||
climits
|
||||
clocale
|
||||
cmath
|
||||
codecvt
|
||||
compare
|
||||
complex
|
||||
complex.h
|
||||
condition_variable
|
||||
csetjmp
|
||||
csignal
|
||||
cstdarg
|
||||
cstdbool
|
||||
cstddef
|
||||
cstdint
|
||||
cstdio
|
||||
cstdlib
|
||||
cstring
|
||||
ctgmath
|
||||
ctime
|
||||
ctype.h
|
||||
cwchar
|
||||
cwctype
|
||||
deque
|
||||
errno.h
|
||||
exception
|
||||
experimental/__config
|
||||
experimental/__memory
|
||||
experimental/algorithm
|
||||
experimental/any
|
||||
experimental/chrono
|
||||
experimental/coroutine
|
||||
experimental/deque
|
||||
experimental/filesystem
|
||||
experimental/forward_list
|
||||
experimental/functional
|
||||
experimental/iterator
|
||||
experimental/list
|
||||
experimental/map
|
||||
experimental/memory_resource
|
||||
experimental/numeric
|
||||
experimental/optional
|
||||
experimental/propagate_const
|
||||
experimental/ratio
|
||||
experimental/regex
|
||||
experimental/set
|
||||
experimental/simd
|
||||
experimental/string
|
||||
experimental/string_view
|
||||
experimental/system_error
|
||||
experimental/tuple
|
||||
experimental/type_traits
|
||||
experimental/unordered_map
|
||||
experimental/unordered_set
|
||||
experimental/utility
|
||||
experimental/vector
|
||||
ext/__hash
|
||||
ext/hash_map
|
||||
ext/hash_set
|
||||
filesystem
|
||||
float.h
|
||||
forward_list
|
||||
fstream
|
||||
functional
|
||||
future
|
||||
initializer_list
|
||||
inttypes.h
|
||||
iomanip
|
||||
ios
|
||||
iosfwd
|
||||
iostream
|
||||
istream
|
||||
iterator
|
||||
limits
|
||||
limits.h
|
||||
list
|
||||
locale
|
||||
locale.h
|
||||
map
|
||||
math.h
|
||||
memory
|
||||
module.modulemap
|
||||
mutex
|
||||
new
|
||||
numeric
|
||||
optional
|
||||
ostream
|
||||
queue
|
||||
random
|
||||
ratio
|
||||
regex
|
||||
scoped_allocator
|
||||
set
|
||||
setjmp.h
|
||||
shared_mutex
|
||||
span
|
||||
sstream
|
||||
stack
|
||||
stdbool.h
|
||||
stddef.h
|
||||
stdexcept
|
||||
stdint.h
|
||||
stdio.h
|
||||
stdlib.h
|
||||
streambuf
|
||||
string
|
||||
string.h
|
||||
string_view
|
||||
strstream
|
||||
system_error
|
||||
tgmath.h
|
||||
thread
|
||||
tuple
|
||||
type_traits
|
||||
typeindex
|
||||
typeinfo
|
||||
unordered_map
|
||||
unordered_set
|
||||
utility
|
||||
valarray
|
||||
variant
|
||||
vector
|
||||
version
|
||||
wchar.h
|
||||
wctype.h
|
||||
)
|
||||
|
||||
if(LIBCXX_INSTALL_SUPPORT_HEADERS)
|
||||
set(files
|
||||
${files}
|
||||
support/android/locale_bionic.h
|
||||
support/fuchsia/xlocale.h
|
||||
support/ibm/limits.h
|
||||
support/ibm/locale_mgmt_aix.h
|
||||
support/ibm/support.h
|
||||
support/ibm/xlocale.h
|
||||
support/musl/xlocale.h
|
||||
support/newlib/xlocale.h
|
||||
support/solaris/floatingpoint.h
|
||||
support/solaris/wchar.h
|
||||
support/solaris/xlocale.h
|
||||
support/win32/limits_msvc_win32.h
|
||||
support/win32/locale_win32.h
|
||||
support/xlocale/__nop_locale_mgmt.h
|
||||
support/xlocale/__posix_l_fallback.h
|
||||
support/xlocale/__strtonum_fallback.h
|
||||
support/xlocale/xlocale.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||
# Generate a custom __config header. The new header is created
|
||||
# by prepending __config_site to the current __config header.
|
||||
add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py
|
||||
${LIBCXX_BINARY_DIR}/__config_site
|
||||
${LIBCXX_SOURCE_DIR}/include/__config
|
||||
-o ${LIBCXX_BINARY_DIR}/__generated_config
|
||||
DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config
|
||||
${LIBCXX_BINARY_DIR}/__config_site
|
||||
)
|
||||
# Add a target that executes the generation commands.
|
||||
add_custom_target(cxx-generated-config ALL
|
||||
DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
|
||||
set(generated_config_deps cxx-generated-config)
|
||||
else()
|
||||
set(files
|
||||
${files}
|
||||
__config
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT LIBCXX_USING_INSTALLED_LLVM AND LIBCXX_HEADER_DIR)
|
||||
set(output_dir ${LIBCXX_HEADER_DIR}/include/c++/v1)
|
||||
|
||||
set(out_files)
|
||||
foreach(f ${files})
|
||||
set(src ${CMAKE_CURRENT_SOURCE_DIR}/${f})
|
||||
set(dst ${output_dir}/${f})
|
||||
add_custom_command(OUTPUT ${dst}
|
||||
DEPENDS ${src}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
|
||||
COMMENT "Copying CXX header ${f}")
|
||||
list(APPEND out_files ${dst})
|
||||
endforeach()
|
||||
|
||||
if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||
# Copy the generated header as __config into build directory.
|
||||
set(src ${LIBCXX_BINARY_DIR}/__generated_config)
|
||||
set(dst ${output_dir}/__config)
|
||||
add_custom_command(OUTPUT ${dst}
|
||||
DEPENDS ${src} ${generated_config_deps}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
|
||||
COMMENT "Copying CXX __config")
|
||||
list(APPEND out_files ${dst})
|
||||
endif()
|
||||
|
||||
add_custom_target(cxx-headers ALL DEPENDS ${out_files} ${LIBCXX_CXX_ABI_HEADER_TARGET})
|
||||
else()
|
||||
add_custom_target(cxx-headers)
|
||||
endif()
|
||||
set_target_properties(cxx-headers PROPERTIES FOLDER "Misc")
|
||||
|
||||
if (LIBCXX_INSTALL_HEADERS)
|
||||
foreach(file ${files})
|
||||
get_filename_component(dir ${file} DIRECTORY)
|
||||
install(FILES ${file}
|
||||
DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir}
|
||||
COMPONENT cxx-headers
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||
)
|
||||
endforeach()
|
||||
|
||||
if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||
# Install the generated header as __config.
|
||||
install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
|
||||
DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||
RENAME __config
|
||||
COMPONENT cxx-headers)
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_CONFIGURATION_TYPES)
|
||||
add_custom_target(install-cxx-headers
|
||||
DEPENDS cxx-headers ${generated_config_deps}
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-DCMAKE_INSTALL_COMPONENT=cxx-headers
|
||||
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
||||
# Stripping is a no-op for headers
|
||||
add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
|
||||
|
||||
add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
|
||||
add_custom_target(install-libcxx-headers-stripped DEPENDS install-cxx-headers-stripped)
|
||||
endif()
|
||||
endif()
|
1281
libcxx/include/__bit_reference
Normal file
1281
libcxx/include/__bit_reference
Normal file
File diff suppressed because it is too large
Load Diff
37
libcxx/include/__bsd_locale_defaults.h
Normal file
37
libcxx/include/__bsd_locale_defaults.h
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------- __bsd_locale_defaults.h -----------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// The BSDs have lots of *_l functions. We don't want to define those symbols
|
||||
// on other platforms though, for fear of conflicts with user code. So here,
|
||||
// we will define the mapping from an internal macro to the real BSD symbol.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
|
||||
#define _LIBCPP_BSD_LOCALE_DEFAULTS_H
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)
|
||||
#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc)
|
||||
#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc)
|
||||
#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc)
|
||||
#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc)
|
||||
#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc)
|
||||
#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l)
|
||||
#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l)
|
||||
#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l)
|
||||
#define __libcpp_localeconv_l(l) localeconv_l(l)
|
||||
#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l)
|
||||
#define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__)
|
||||
#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__)
|
||||
#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)
|
||||
|
||||
#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H
|
140
libcxx/include/__bsd_locale_fallbacks.h
Normal file
140
libcxx/include/__bsd_locale_fallbacks.h
Normal file
@ -0,0 +1,140 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------- __bsd_locale_fallbacks.h ----------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// The BSDs have lots of *_l functions. This file provides reimplementations
|
||||
// of those functions for non-BSD platforms.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return MB_CUR_MAX;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
wint_t __libcpp_btowc_l(int __c, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return btowc(__c);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __libcpp_wctob_l(wint_t __c, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return wctob(__c);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return wcrtomb(__s, __wc, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
|
||||
size_t __len, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbrtowc(__pwc, __s, __n, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbtowc(__pwc, __pmb, __max);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbrlen(__s, __n, __ps);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
lconv *__libcpp_localeconv_l(locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return localeconv();
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
|
||||
mbstate_t *__ps, locale_t __l)
|
||||
{
|
||||
__libcpp_locale_guard __current(__l);
|
||||
return mbsrtowcs(__dest, __src, __len, __ps);
|
||||
}
|
||||
|
||||
inline
|
||||
int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
__libcpp_locale_guard __current(__l);
|
||||
int __res = vsnprintf(__s, __n, __format, __va);
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
__libcpp_locale_guard __current(__l);
|
||||
int __res = vasprintf(__s, __format, __va);
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
__libcpp_locale_guard __current(__l);
|
||||
int __res = vsscanf(__s, __format, __va);
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
1443
libcxx/include/__config
Normal file
1443
libcxx/include/__config
Normal file
File diff suppressed because it is too large
Load Diff
35
libcxx/include/__config_site.in
Normal file
35
libcxx/include/__config_site.in
Normal file
@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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_CONFIG_SITE
|
||||
#define _LIBCPP_CONFIG_SITE
|
||||
|
||||
#cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@
|
||||
#cmakedefine _LIBCPP_ABI_UNSTABLE
|
||||
#cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
|
||||
#cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
|
||||
#cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT
|
||||
#cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
#cmakedefine _LIBCPP_HAS_NO_STDIN
|
||||
#cmakedefine _LIBCPP_HAS_NO_STDOUT
|
||||
#cmakedefine _LIBCPP_HAS_NO_THREADS
|
||||
#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
|
||||
#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_WIN32
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
|
||||
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
#cmakedefine _LIBCPP_NO_VCRUNTIME
|
||||
#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
|
||||
|
||||
@_LIBCPP_ABI_DEFINES@
|
||||
|
||||
#endif // _LIBCPP_CONFIG_SITE
|
302
libcxx/include/__debug
Normal file
302
libcxx/include/__debug
Normal file
@ -0,0 +1,302 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- __debug ----------------------------------===//
|
||||
//
|
||||
// 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_DEBUG_H
|
||||
#define _LIBCPP_DEBUG_H
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_HAS_NO_NULLPTR)
|
||||
# include <cstddef>
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# include <cstdlib>
|
||||
# include <cstdio>
|
||||
# include <cstddef>
|
||||
# include <exception>
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT)
|
||||
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \
|
||||
_VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
#ifndef _LIBCPP_DEBUG_ASSERT
|
||||
#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
|
||||
#endif
|
||||
#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_ASSERT
|
||||
# define _LIBCPP_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#ifndef _LIBCPP_DEBUG_ASSERT
|
||||
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
|
||||
#endif
|
||||
#ifndef _LIBCPP_DEBUG_MODE
|
||||
#define _LIBCPP_DEBUG_MODE(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL < 1
|
||||
class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception;
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
__libcpp_debug_info()
|
||||
: __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
|
||||
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
|
||||
const char* __file_;
|
||||
int __line_;
|
||||
const char* __pred_;
|
||||
const char* __msg_;
|
||||
};
|
||||
|
||||
/// __libcpp_debug_function_type - The type of the assertion failure handler.
|
||||
typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
|
||||
|
||||
/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
|
||||
/// fails.
|
||||
extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function;
|
||||
|
||||
/// __libcpp_abort_debug_function - A debug handler that aborts when called.
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
|
||||
void __libcpp_abort_debug_function(__libcpp_debug_info const&);
|
||||
|
||||
/// __libcpp_throw_debug_function - A debug handler that throws
|
||||
/// an instance of __libcpp_debug_exception when called.
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
|
||||
void __libcpp_throw_debug_function(__libcpp_debug_info const&);
|
||||
|
||||
/// __libcpp_set_debug_function - Set the debug handler to the specified
|
||||
/// function.
|
||||
_LIBCPP_FUNC_VIS
|
||||
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
|
||||
|
||||
// Setup the throwing debug handler during dynamic initialization.
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
|
||||
# if defined(_LIBCPP_NO_EXCEPTIONS)
|
||||
# error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are disabled.
|
||||
# endif
|
||||
static bool __init_dummy = __libcpp_set_debug_function(__libcpp_throw_debug_function);
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception : public exception {
|
||||
public:
|
||||
__libcpp_debug_exception() _NOEXCEPT;
|
||||
explicit __libcpp_debug_exception(__libcpp_debug_info const& __i);
|
||||
__libcpp_debug_exception(__libcpp_debug_exception const&);
|
||||
~__libcpp_debug_exception() _NOEXCEPT;
|
||||
const char* what() const _NOEXCEPT;
|
||||
private:
|
||||
struct __libcpp_debug_exception_imp;
|
||||
__libcpp_debug_exception_imp *__imp_;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
|
||||
struct _LIBCPP_TYPE_VIS __c_node;
|
||||
|
||||
struct _LIBCPP_TYPE_VIS __i_node
|
||||
{
|
||||
void* __i_;
|
||||
__i_node* __next_;
|
||||
__c_node* __c_;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__i_node(const __i_node&) = delete;
|
||||
__i_node& operator=(const __i_node&) = delete;
|
||||
#else
|
||||
private:
|
||||
__i_node(const __i_node&);
|
||||
__i_node& operator=(const __i_node&);
|
||||
public:
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__i_node(void* __i, __i_node* __next, __c_node* __c)
|
||||
: __i_(__i), __next_(__next), __c_(__c) {}
|
||||
~__i_node();
|
||||
};
|
||||
|
||||
struct _LIBCPP_TYPE_VIS __c_node
|
||||
{
|
||||
void* __c_;
|
||||
__c_node* __next_;
|
||||
__i_node** beg_;
|
||||
__i_node** end_;
|
||||
__i_node** cap_;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__c_node(const __c_node&) = delete;
|
||||
__c_node& operator=(const __c_node&) = delete;
|
||||
#else
|
||||
private:
|
||||
__c_node(const __c_node&);
|
||||
__c_node& operator=(const __c_node&);
|
||||
public:
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__c_node(void* __c, __c_node* __next)
|
||||
: __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
|
||||
virtual ~__c_node();
|
||||
|
||||
virtual bool __dereferenceable(const void*) const = 0;
|
||||
virtual bool __decrementable(const void*) const = 0;
|
||||
virtual bool __addable(const void*, ptrdiff_t) const = 0;
|
||||
virtual bool __subscriptable(const void*, ptrdiff_t) const = 0;
|
||||
|
||||
void __add(__i_node* __i);
|
||||
_LIBCPP_HIDDEN void __remove(__i_node* __i);
|
||||
};
|
||||
|
||||
template <class _Cont>
|
||||
struct _C_node
|
||||
: public __c_node
|
||||
{
|
||||
_C_node(void* __c, __c_node* __n)
|
||||
: __c_node(__c, __n) {}
|
||||
|
||||
virtual bool __dereferenceable(const void*) const;
|
||||
virtual bool __decrementable(const void*) const;
|
||||
virtual bool __addable(const void*, ptrdiff_t) const;
|
||||
virtual bool __subscriptable(const void*, ptrdiff_t) const;
|
||||
};
|
||||
|
||||
template <class _Cont>
|
||||
inline bool
|
||||
_C_node<_Cont>::__dereferenceable(const void* __i) const
|
||||
{
|
||||
typedef typename _Cont::const_iterator iterator;
|
||||
const iterator* __j = static_cast<const iterator*>(__i);
|
||||
_Cont* _Cp = static_cast<_Cont*>(__c_);
|
||||
return _Cp->__dereferenceable(__j);
|
||||
}
|
||||
|
||||
template <class _Cont>
|
||||
inline bool
|
||||
_C_node<_Cont>::__decrementable(const void* __i) const
|
||||
{
|
||||
typedef typename _Cont::const_iterator iterator;
|
||||
const iterator* __j = static_cast<const iterator*>(__i);
|
||||
_Cont* _Cp = static_cast<_Cont*>(__c_);
|
||||
return _Cp->__decrementable(__j);
|
||||
}
|
||||
|
||||
template <class _Cont>
|
||||
inline bool
|
||||
_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
|
||||
{
|
||||
typedef typename _Cont::const_iterator iterator;
|
||||
const iterator* __j = static_cast<const iterator*>(__i);
|
||||
_Cont* _Cp = static_cast<_Cont*>(__c_);
|
||||
return _Cp->__addable(__j, __n);
|
||||
}
|
||||
|
||||
template <class _Cont>
|
||||
inline bool
|
||||
_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const
|
||||
{
|
||||
typedef typename _Cont::const_iterator iterator;
|
||||
const iterator* __j = static_cast<const iterator*>(__i);
|
||||
_Cont* _Cp = static_cast<_Cont*>(__c_);
|
||||
return _Cp->__subscriptable(__j, __n);
|
||||
}
|
||||
|
||||
class _LIBCPP_TYPE_VIS __libcpp_db
|
||||
{
|
||||
__c_node** __cbeg_;
|
||||
__c_node** __cend_;
|
||||
size_t __csz_;
|
||||
__i_node** __ibeg_;
|
||||
__i_node** __iend_;
|
||||
size_t __isz_;
|
||||
|
||||
__libcpp_db();
|
||||
public:
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__libcpp_db(const __libcpp_db&) = delete;
|
||||
__libcpp_db& operator=(const __libcpp_db&) = delete;
|
||||
#else
|
||||
private:
|
||||
__libcpp_db(const __libcpp_db&);
|
||||
__libcpp_db& operator=(const __libcpp_db&);
|
||||
public:
|
||||
#endif
|
||||
~__libcpp_db();
|
||||
|
||||
class __db_c_iterator;
|
||||
class __db_c_const_iterator;
|
||||
class __db_i_iterator;
|
||||
class __db_i_const_iterator;
|
||||
|
||||
__db_c_const_iterator __c_end() const;
|
||||
__db_i_const_iterator __i_end() const;
|
||||
|
||||
template <class _Cont>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __insert_c(_Cont* __c)
|
||||
{
|
||||
__c_node* __n = __insert_c(static_cast<void*>(__c));
|
||||
::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_);
|
||||
}
|
||||
|
||||
void __insert_i(void* __i);
|
||||
__c_node* __insert_c(void* __c);
|
||||
void __erase_c(void* __c);
|
||||
|
||||
void __insert_ic(void* __i, const void* __c);
|
||||
void __iterator_copy(void* __i, const void* __i0);
|
||||
void __erase_i(void* __i);
|
||||
|
||||
void* __find_c_from_i(void* __i) const;
|
||||
void __invalidate_all(void* __c);
|
||||
__c_node* __find_c_and_lock(void* __c) const;
|
||||
__c_node* __find_c(void* __c) const;
|
||||
void unlock() const;
|
||||
|
||||
void swap(void* __c1, void* __c2);
|
||||
|
||||
|
||||
bool __dereferenceable(const void* __i) const;
|
||||
bool __decrementable(const void* __i) const;
|
||||
bool __addable(const void* __i, ptrdiff_t __n) const;
|
||||
bool __subscriptable(const void* __i, ptrdiff_t __n) const;
|
||||
bool __less_than_comparable(const void* __i, const void* __j) const;
|
||||
private:
|
||||
_LIBCPP_HIDDEN
|
||||
__i_node* __insert_iterator(void* __i);
|
||||
_LIBCPP_HIDDEN
|
||||
__i_node* __find_iterator(const void* __i) const;
|
||||
|
||||
friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
|
||||
};
|
||||
|
||||
_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
|
||||
_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
|
||||
|
||||
|
||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_DEBUG_H
|
||||
|
218
libcxx/include/__errc
Normal file
218
libcxx/include/__errc
Normal file
@ -0,0 +1,218 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- __errc ----------------------------------===//
|
||||
//
|
||||
// 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___ERRC
|
||||
#define _LIBCPP___ERRC
|
||||
|
||||
/*
|
||||
system_error synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
enum class errc
|
||||
{
|
||||
address_family_not_supported, // EAFNOSUPPORT
|
||||
address_in_use, // EADDRINUSE
|
||||
address_not_available, // EADDRNOTAVAIL
|
||||
already_connected, // EISCONN
|
||||
argument_list_too_long, // E2BIG
|
||||
argument_out_of_domain, // EDOM
|
||||
bad_address, // EFAULT
|
||||
bad_file_descriptor, // EBADF
|
||||
bad_message, // EBADMSG
|
||||
broken_pipe, // EPIPE
|
||||
connection_aborted, // ECONNABORTED
|
||||
connection_already_in_progress, // EALREADY
|
||||
connection_refused, // ECONNREFUSED
|
||||
connection_reset, // ECONNRESET
|
||||
cross_device_link, // EXDEV
|
||||
destination_address_required, // EDESTADDRREQ
|
||||
device_or_resource_busy, // EBUSY
|
||||
directory_not_empty, // ENOTEMPTY
|
||||
executable_format_error, // ENOEXEC
|
||||
file_exists, // EEXIST
|
||||
file_too_large, // EFBIG
|
||||
filename_too_long, // ENAMETOOLONG
|
||||
function_not_supported, // ENOSYS
|
||||
host_unreachable, // EHOSTUNREACH
|
||||
identifier_removed, // EIDRM
|
||||
illegal_byte_sequence, // EILSEQ
|
||||
inappropriate_io_control_operation, // ENOTTY
|
||||
interrupted, // EINTR
|
||||
invalid_argument, // EINVAL
|
||||
invalid_seek, // ESPIPE
|
||||
io_error, // EIO
|
||||
is_a_directory, // EISDIR
|
||||
message_size, // EMSGSIZE
|
||||
network_down, // ENETDOWN
|
||||
network_reset, // ENETRESET
|
||||
network_unreachable, // ENETUNREACH
|
||||
no_buffer_space, // ENOBUFS
|
||||
no_child_process, // ECHILD
|
||||
no_link, // ENOLINK
|
||||
no_lock_available, // ENOLCK
|
||||
no_message_available, // ENODATA
|
||||
no_message, // ENOMSG
|
||||
no_protocol_option, // ENOPROTOOPT
|
||||
no_space_on_device, // ENOSPC
|
||||
no_stream_resources, // ENOSR
|
||||
no_such_device_or_address, // ENXIO
|
||||
no_such_device, // ENODEV
|
||||
no_such_file_or_directory, // ENOENT
|
||||
no_such_process, // ESRCH
|
||||
not_a_directory, // ENOTDIR
|
||||
not_a_socket, // ENOTSOCK
|
||||
not_a_stream, // ENOSTR
|
||||
not_connected, // ENOTCONN
|
||||
not_enough_memory, // ENOMEM
|
||||
not_supported, // ENOTSUP
|
||||
operation_canceled, // ECANCELED
|
||||
operation_in_progress, // EINPROGRESS
|
||||
operation_not_permitted, // EPERM
|
||||
operation_not_supported, // EOPNOTSUPP
|
||||
operation_would_block, // EWOULDBLOCK
|
||||
owner_dead, // EOWNERDEAD
|
||||
permission_denied, // EACCES
|
||||
protocol_error, // EPROTO
|
||||
protocol_not_supported, // EPROTONOSUPPORT
|
||||
read_only_file_system, // EROFS
|
||||
resource_deadlock_would_occur, // EDEADLK
|
||||
resource_unavailable_try_again, // EAGAIN
|
||||
result_out_of_range, // ERANGE
|
||||
state_not_recoverable, // ENOTRECOVERABLE
|
||||
stream_timeout, // ETIME
|
||||
text_file_busy, // ETXTBSY
|
||||
timed_out, // ETIMEDOUT
|
||||
too_many_files_open_in_system, // ENFILE
|
||||
too_many_files_open, // EMFILE
|
||||
too_many_links, // EMLINK
|
||||
too_many_symbolic_link_levels, // ELOOP
|
||||
value_too_large, // EOVERFLOW
|
||||
wrong_protocol_type // EPROTOTYPE
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// Some error codes are not present on all platforms, so we provide equivalents
|
||||
// for them:
|
||||
|
||||
//enum class errc
|
||||
_LIBCPP_DECLARE_STRONG_ENUM(errc)
|
||||
{
|
||||
address_family_not_supported = EAFNOSUPPORT,
|
||||
address_in_use = EADDRINUSE,
|
||||
address_not_available = EADDRNOTAVAIL,
|
||||
already_connected = EISCONN,
|
||||
argument_list_too_long = E2BIG,
|
||||
argument_out_of_domain = EDOM,
|
||||
bad_address = EFAULT,
|
||||
bad_file_descriptor = EBADF,
|
||||
bad_message = EBADMSG,
|
||||
broken_pipe = EPIPE,
|
||||
connection_aborted = ECONNABORTED,
|
||||
connection_already_in_progress = EALREADY,
|
||||
connection_refused = ECONNREFUSED,
|
||||
connection_reset = ECONNRESET,
|
||||
cross_device_link = EXDEV,
|
||||
destination_address_required = EDESTADDRREQ,
|
||||
device_or_resource_busy = EBUSY,
|
||||
directory_not_empty = ENOTEMPTY,
|
||||
executable_format_error = ENOEXEC,
|
||||
file_exists = EEXIST,
|
||||
file_too_large = EFBIG,
|
||||
filename_too_long = ENAMETOOLONG,
|
||||
function_not_supported = ENOSYS,
|
||||
host_unreachable = EHOSTUNREACH,
|
||||
identifier_removed = EIDRM,
|
||||
illegal_byte_sequence = EILSEQ,
|
||||
inappropriate_io_control_operation = ENOTTY,
|
||||
interrupted = EINTR,
|
||||
invalid_argument = EINVAL,
|
||||
invalid_seek = ESPIPE,
|
||||
io_error = EIO,
|
||||
is_a_directory = EISDIR,
|
||||
message_size = EMSGSIZE,
|
||||
network_down = ENETDOWN,
|
||||
network_reset = ENETRESET,
|
||||
network_unreachable = ENETUNREACH,
|
||||
no_buffer_space = ENOBUFS,
|
||||
no_child_process = ECHILD,
|
||||
no_link = ENOLINK,
|
||||
no_lock_available = ENOLCK,
|
||||
#ifdef ENODATA
|
||||
no_message_available = ENODATA,
|
||||
#else
|
||||
no_message_available = ENOMSG,
|
||||
#endif
|
||||
no_message = ENOMSG,
|
||||
no_protocol_option = ENOPROTOOPT,
|
||||
no_space_on_device = ENOSPC,
|
||||
#ifdef ENOSR
|
||||
no_stream_resources = ENOSR,
|
||||
#else
|
||||
no_stream_resources = ENOMEM,
|
||||
#endif
|
||||
no_such_device_or_address = ENXIO,
|
||||
no_such_device = ENODEV,
|
||||
no_such_file_or_directory = ENOENT,
|
||||
no_such_process = ESRCH,
|
||||
not_a_directory = ENOTDIR,
|
||||
not_a_socket = ENOTSOCK,
|
||||
#ifdef ENOSTR
|
||||
not_a_stream = ENOSTR,
|
||||
#else
|
||||
not_a_stream = EINVAL,
|
||||
#endif
|
||||
not_connected = ENOTCONN,
|
||||
not_enough_memory = ENOMEM,
|
||||
not_supported = ENOTSUP,
|
||||
operation_canceled = ECANCELED,
|
||||
operation_in_progress = EINPROGRESS,
|
||||
operation_not_permitted = EPERM,
|
||||
operation_not_supported = EOPNOTSUPP,
|
||||
operation_would_block = EWOULDBLOCK,
|
||||
owner_dead = EOWNERDEAD,
|
||||
permission_denied = EACCES,
|
||||
protocol_error = EPROTO,
|
||||
protocol_not_supported = EPROTONOSUPPORT,
|
||||
read_only_file_system = EROFS,
|
||||
resource_deadlock_would_occur = EDEADLK,
|
||||
resource_unavailable_try_again = EAGAIN,
|
||||
result_out_of_range = ERANGE,
|
||||
state_not_recoverable = ENOTRECOVERABLE,
|
||||
#ifdef ETIME
|
||||
stream_timeout = ETIME,
|
||||
#else
|
||||
stream_timeout = ETIMEDOUT,
|
||||
#endif
|
||||
text_file_busy = ETXTBSY,
|
||||
timed_out = ETIMEDOUT,
|
||||
too_many_files_open_in_system = ENFILE,
|
||||
too_many_files_open = EMFILE,
|
||||
too_many_links = EMLINK,
|
||||
too_many_symbolic_link_levels = ELOOP,
|
||||
value_too_large = EOVERFLOW,
|
||||
wrong_protocol_type = EPROTOTYPE
|
||||
};
|
||||
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___ERRC
|
1592
libcxx/include/__functional_03
Normal file
1592
libcxx/include/__functional_03
Normal file
File diff suppressed because it is too large
Load Diff
653
libcxx/include/__functional_base
Normal file
653
libcxx/include/__functional_base
Normal file
@ -0,0 +1,653 @@
|
||||
// -*- 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_FUNCTIONAL_BASE
|
||||
#define _LIBCPP_FUNCTIONAL_BASE
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
#include <typeinfo>
|
||||
#include <exception>
|
||||
#include <new>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Arg1, class _Arg2, class _Result>
|
||||
struct _LIBCPP_TEMPLATE_VIS binary_function
|
||||
{
|
||||
typedef _Arg1 first_argument_type;
|
||||
typedef _Arg2 second_argument_type;
|
||||
typedef _Result result_type;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_result_type
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::result_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp = void>
|
||||
#else
|
||||
template <class _Tp>
|
||||
#endif
|
||||
struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool>
|
||||
{
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const
|
||||
{return __x < __y;}
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS less<void>
|
||||
{
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
_NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
|
||||
-> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
|
||||
{ return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
|
||||
typedef void is_transparent;
|
||||
};
|
||||
#endif
|
||||
|
||||
// __weak_result_type
|
||||
|
||||
template <class _Tp>
|
||||
struct __derives_from_unary_function
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
static __two __test(...);
|
||||
template <class _Ap, class _Rp>
|
||||
static unary_function<_Ap, _Rp>
|
||||
__test(const volatile unary_function<_Ap, _Rp>*);
|
||||
public:
|
||||
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
|
||||
typedef decltype(__test((_Tp*)0)) type;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __derives_from_binary_function
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
static __two __test(...);
|
||||
template <class _A1, class _A2, class _Rp>
|
||||
static binary_function<_A1, _A2, _Rp>
|
||||
__test(const volatile binary_function<_A1, _A2, _Rp>*);
|
||||
public:
|
||||
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
|
||||
typedef decltype(__test((_Tp*)0)) type;
|
||||
};
|
||||
|
||||
template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
|
||||
struct __maybe_derive_from_unary_function // bool is true
|
||||
: public __derives_from_unary_function<_Tp>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __maybe_derive_from_unary_function<_Tp, false>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
|
||||
struct __maybe_derive_from_binary_function // bool is true
|
||||
: public __derives_from_binary_function<_Tp>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __maybe_derive_from_binary_function<_Tp, false>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp, bool = __has_result_type<_Tp>::value>
|
||||
struct __weak_result_type_imp // bool is true
|
||||
: public __maybe_derive_from_unary_function<_Tp>,
|
||||
public __maybe_derive_from_binary_function<_Tp>
|
||||
{
|
||||
typedef typename _Tp::result_type result_type;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __weak_result_type_imp<_Tp, false>
|
||||
: public __maybe_derive_from_unary_function<_Tp>,
|
||||
public __maybe_derive_from_binary_function<_Tp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __weak_result_type
|
||||
: public __weak_result_type_imp<_Tp>
|
||||
{
|
||||
};
|
||||
|
||||
// 0 argument case
|
||||
|
||||
template <class _Rp>
|
||||
struct __weak_result_type<_Rp ()>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp>
|
||||
struct __weak_result_type<_Rp (&)()>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp>
|
||||
struct __weak_result_type<_Rp (*)()>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
// 1 argument case
|
||||
|
||||
template <class _Rp, class _A1>
|
||||
struct __weak_result_type<_Rp (_A1)>
|
||||
: public unary_function<_A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _A1>
|
||||
struct __weak_result_type<_Rp (&)(_A1)>
|
||||
: public unary_function<_A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _A1>
|
||||
struct __weak_result_type<_Rp (*)(_A1)>
|
||||
: public unary_function<_A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp>
|
||||
struct __weak_result_type<_Rp (_Cp::*)()>
|
||||
: public unary_function<_Cp*, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp>
|
||||
struct __weak_result_type<_Rp (_Cp::*)() const>
|
||||
: public unary_function<const _Cp*, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp>
|
||||
struct __weak_result_type<_Rp (_Cp::*)() volatile>
|
||||
: public unary_function<volatile _Cp*, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp>
|
||||
struct __weak_result_type<_Rp (_Cp::*)() const volatile>
|
||||
: public unary_function<const volatile _Cp*, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
// 2 argument case
|
||||
|
||||
template <class _Rp, class _A1, class _A2>
|
||||
struct __weak_result_type<_Rp (_A1, _A2)>
|
||||
: public binary_function<_A1, _A2, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _A1, class _A2>
|
||||
struct __weak_result_type<_Rp (*)(_A1, _A2)>
|
||||
: public binary_function<_A1, _A2, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _A1, class _A2>
|
||||
struct __weak_result_type<_Rp (&)(_A1, _A2)>
|
||||
: public binary_function<_A1, _A2, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1)>
|
||||
: public binary_function<_Cp*, _A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
|
||||
: public binary_function<const _Cp*, _A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
|
||||
: public binary_function<volatile _Cp*, _A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
|
||||
: public binary_function<const volatile _Cp*, _A1, _Rp>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
// 3 or more arguments
|
||||
|
||||
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
|
||||
struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
|
||||
struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
|
||||
struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
|
||||
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
|
||||
{
|
||||
typedef _Rp result_type;
|
||||
};
|
||||
|
||||
template <class _Tp, class ..._Args>
|
||||
struct __invoke_return
|
||||
{
|
||||
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
|
||||
};
|
||||
|
||||
#else // defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
#include <__functional_base_03>
|
||||
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
|
||||
template <class _Ret>
|
||||
struct __invoke_void_return_wrapper
|
||||
{
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class ..._Args>
|
||||
static _Ret __call(_Args&&... __args) {
|
||||
return __invoke(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
#else
|
||||
template <class _Fn>
|
||||
static _Ret __call(_Fn __f) {
|
||||
return __invoke(__f);
|
||||
}
|
||||
|
||||
template <class _Fn, class _A0>
|
||||
static _Ret __call(_Fn __f, _A0& __a0) {
|
||||
return __invoke(__f, __a0);
|
||||
}
|
||||
|
||||
template <class _Fn, class _A0, class _A1>
|
||||
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
|
||||
return __invoke(__f, __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _Fn, class _A0, class _A1, class _A2>
|
||||
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
|
||||
return __invoke(__f, __a0, __a1, __a2);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <>
|
||||
struct __invoke_void_return_wrapper<void>
|
||||
{
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class ..._Args>
|
||||
static void __call(_Args&&... __args) {
|
||||
__invoke(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
#else
|
||||
template <class _Fn>
|
||||
static void __call(_Fn __f) {
|
||||
__invoke(__f);
|
||||
}
|
||||
|
||||
template <class _Fn, class _A0>
|
||||
static void __call(_Fn __f, _A0& __a0) {
|
||||
__invoke(__f, __a0);
|
||||
}
|
||||
|
||||
template <class _Fn, class _A0, class _A1>
|
||||
static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
|
||||
__invoke(__f, __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _Fn, class _A0, class _A1, class _A2>
|
||||
static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
|
||||
__invoke(__f, __a0, __a1, __a2);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS reference_wrapper
|
||||
: public __weak_result_type<_Tp>
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef _Tp type;
|
||||
private:
|
||||
type* __f_;
|
||||
|
||||
public:
|
||||
// construct/copy/destroy
|
||||
_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
|
||||
: __f_(_VSTD::addressof(__f)) {}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
|
||||
#endif
|
||||
|
||||
// access
|
||||
_LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;}
|
||||
_LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
// invoke
|
||||
template <class... _ArgTypes>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_of<type&, _ArgTypes...>::type
|
||||
operator() (_ArgTypes&&... __args) const {
|
||||
return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
|
||||
}
|
||||
#else
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return<type>::type
|
||||
operator() () const {
|
||||
return __invoke(get());
|
||||
}
|
||||
|
||||
template <class _A0>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return0<type, _A0>::type
|
||||
operator() (_A0& __a0) const {
|
||||
return __invoke(get(), __a0);
|
||||
}
|
||||
|
||||
template <class _A0>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return0<type, _A0 const>::type
|
||||
operator() (_A0 const& __a0) const {
|
||||
return __invoke(get(), __a0);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return1<type, _A0, _A1>::type
|
||||
operator() (_A0& __a0, _A1& __a1) const {
|
||||
return __invoke(get(), __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return1<type, _A0 const, _A1>::type
|
||||
operator() (_A0 const& __a0, _A1& __a1) const {
|
||||
return __invoke(get(), __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return1<type, _A0, _A1 const>::type
|
||||
operator() (_A0& __a0, _A1 const& __a1) const {
|
||||
return __invoke(get(), __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return1<type, _A0 const, _A1 const>::type
|
||||
operator() (_A0 const& __a0, _A1 const& __a1) const {
|
||||
return __invoke(get(), __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0, _A1, _A2>::type
|
||||
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0 const, _A1, _A2>::type
|
||||
operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0, _A1 const, _A2>::type
|
||||
operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0, _A1, _A2 const>::type
|
||||
operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
|
||||
operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
|
||||
operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
|
||||
operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
|
||||
operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
|
||||
return __invoke(get(), __a0, __a1, __a2);
|
||||
}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
reference_wrapper<_Tp>
|
||||
ref(_Tp& __t) _NOEXCEPT
|
||||
{
|
||||
return reference_wrapper<_Tp>(__t);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
reference_wrapper<_Tp>
|
||||
ref(reference_wrapper<_Tp> __t) _NOEXCEPT
|
||||
{
|
||||
return ref(__t.get());
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
reference_wrapper<const _Tp>
|
||||
cref(const _Tp& __t) _NOEXCEPT
|
||||
{
|
||||
return reference_wrapper<const _Tp>(__t);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
reference_wrapper<const _Tp>
|
||||
cref(reference_wrapper<_Tp> __t) _NOEXCEPT
|
||||
{
|
||||
return cref(__t.get());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Tp> void ref(const _Tp&&) = delete;
|
||||
template <class _Tp> void cref(const _Tp&&) = delete;
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp, class, class = void>
|
||||
struct __is_transparent : false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __is_transparent<_Tp, _Up,
|
||||
typename __void_t<typename _Tp::is_transparent>::type>
|
||||
: true_type {};
|
||||
#endif
|
||||
|
||||
// allocator_arg_t
|
||||
|
||||
struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
|
||||
|
||||
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
|
||||
#else
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
#endif
|
||||
|
||||
// uses_allocator
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_allocator_type
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::allocator_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
|
||||
struct __uses_allocator
|
||||
: public integral_constant<bool,
|
||||
is_convertible<_Alloc, typename _Tp::allocator_type>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
struct __uses_allocator<_Tp, _Alloc, false>
|
||||
: public false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
struct _LIBCPP_TEMPLATE_VIS uses_allocator
|
||||
: public __uses_allocator<_Tp, _Alloc>
|
||||
{
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp, class _Alloc>
|
||||
_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
// allocator construction
|
||||
|
||||
template <class _Tp, class _Alloc, class ..._Args>
|
||||
struct __uses_alloc_ctor_imp
|
||||
{
|
||||
typedef typename __uncvref<_Alloc>::type _RawAlloc;
|
||||
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
|
||||
static const bool __ic =
|
||||
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
|
||||
static const int value = __ua ? 2 - __ic : 0;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Alloc, class ..._Args>
|
||||
struct __uses_alloc_ctor
|
||||
: integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
|
||||
{};
|
||||
|
||||
template <class _Tp, class _Allocator, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
|
||||
{
|
||||
new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
// FIXME: This should have a version which takes a non-const alloc.
|
||||
template <class _Tp, class _Allocator, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
|
||||
{
|
||||
new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
// FIXME: This should have a version which takes a non-const alloc.
|
||||
template <class _Tp, class _Allocator, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
|
||||
{
|
||||
new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_FUNCTIONAL_BASE
|
224
libcxx/include/__functional_base_03
Normal file
224
libcxx/include/__functional_base_03
Normal file
@ -0,0 +1,224 @@
|
||||
// -*- 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_FUNCTIONAL_BASE_03
|
||||
#define _LIBCPP_FUNCTIONAL_BASE_03
|
||||
|
||||
// manual variadic expansion for <functional>
|
||||
|
||||
// __invoke
|
||||
|
||||
template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
|
||||
struct __enable_invoke_imp;
|
||||
|
||||
template <class _Ret, class _T1>
|
||||
struct __enable_invoke_imp<_Ret, _T1, true, true> {
|
||||
typedef _Ret _Bullet1;
|
||||
typedef _Bullet1 type;
|
||||
};
|
||||
|
||||
template <class _Ret, class _T1>
|
||||
struct __enable_invoke_imp<_Ret, _T1, true, false> {
|
||||
typedef _Ret _Bullet2;
|
||||
typedef _Bullet2 type;
|
||||
};
|
||||
|
||||
template <class _Ret, class _T1>
|
||||
struct __enable_invoke_imp<_Ret, _T1, false, true> {
|
||||
typedef typename add_lvalue_reference<
|
||||
typename __apply_cv<_T1, _Ret>::type
|
||||
>::type _Bullet3;
|
||||
typedef _Bullet3 type;
|
||||
};
|
||||
|
||||
template <class _Ret, class _T1>
|
||||
struct __enable_invoke_imp<_Ret, _T1, false, false> {
|
||||
typedef typename add_lvalue_reference<
|
||||
typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Ret>::type
|
||||
>::type _Bullet4;
|
||||
typedef _Bullet4 type;
|
||||
};
|
||||
|
||||
template <class _Ret, class _T1>
|
||||
struct __enable_invoke_imp<_Ret, _T1*, false, false> {
|
||||
typedef typename add_lvalue_reference<
|
||||
typename __apply_cv<_T1, _Ret>::type
|
||||
>::type _Bullet4;
|
||||
typedef _Bullet4 type;
|
||||
};
|
||||
|
||||
template <class _Fn, class _T1,
|
||||
class _Traits = __member_pointer_traits<_Fn>,
|
||||
class _Ret = typename _Traits::_ReturnType,
|
||||
class _Class = typename _Traits::_ClassType>
|
||||
struct __enable_invoke : __enable_invoke_imp<
|
||||
_Ret, _T1,
|
||||
is_member_function_pointer<_Fn>::value,
|
||||
is_base_of<_Class, typename remove_reference<_T1>::type>::value>
|
||||
{
|
||||
};
|
||||
|
||||
__nat __invoke(__any, ...);
|
||||
|
||||
// first bullet
|
||||
|
||||
template <class _Fn, class _T1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet1
|
||||
__invoke(_Fn __f, _T1& __t1) {
|
||||
return (__t1.*__f)();
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1, class _A0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet1
|
||||
__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
|
||||
return (__t1.*__f)(__a0);
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1, class _A0, class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet1
|
||||
__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
|
||||
return (__t1.*__f)(__a0, __a1);
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1, class _A0, class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet1
|
||||
__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
|
||||
return (__t1.*__f)(__a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet2
|
||||
__invoke(_Fn __f, _T1& __t1) {
|
||||
return ((*__t1).*__f)();
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1, class _A0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet2
|
||||
__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
|
||||
return ((*__t1).*__f)(__a0);
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1, class _A0, class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet2
|
||||
__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
|
||||
return ((*__t1).*__f)(__a0, __a1);
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1, class _A0, class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet2
|
||||
__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
|
||||
return ((*__t1).*__f)(__a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet3
|
||||
__invoke(_Fn __f, _T1& __t1) {
|
||||
return __t1.*__f;
|
||||
}
|
||||
|
||||
template <class _Fn, class _T1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __enable_invoke<_Fn, _T1>::_Bullet4
|
||||
__invoke(_Fn __f, _T1& __t1) {
|
||||
return (*__t1).*__f;
|
||||
}
|
||||
|
||||
// fifth bullet
|
||||
|
||||
template <class _Fp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype(_VSTD::declval<_Fp&>()())
|
||||
__invoke(_Fp& __f)
|
||||
{
|
||||
return __f();
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>()))
|
||||
__invoke(_Fp& __f, _A0& __a0)
|
||||
{
|
||||
return __f(__a0);
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0, class _A1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>()))
|
||||
__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
|
||||
{
|
||||
return __f(__a0, __a1);
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0, class _A1, class _A2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>()))
|
||||
__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
|
||||
{
|
||||
return __f(__a0, __a1, __a2);
|
||||
}
|
||||
|
||||
template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
|
||||
struct __invoke_return
|
||||
{
|
||||
typedef typename __weak_result_type<_Fp>::result_type type;
|
||||
};
|
||||
|
||||
template <class _Fp>
|
||||
struct __invoke_return<_Fp, false>
|
||||
{
|
||||
typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _A0>
|
||||
struct __invoke_return0
|
||||
{
|
||||
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _Tp, class _A0>
|
||||
struct __invoke_return0<_Rp _Tp::*, _A0>
|
||||
{
|
||||
typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _A0, class _A1>
|
||||
struct __invoke_return1
|
||||
{
|
||||
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
|
||||
_VSTD::declval<_A1&>())) type;
|
||||
};
|
||||
|
||||
template <class _Rp, class _Class, class _A0, class _A1>
|
||||
struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
|
||||
typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _A0, class _A1, class _A2>
|
||||
struct __invoke_return2
|
||||
{
|
||||
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
|
||||
_VSTD::declval<_A1&>(),
|
||||
_VSTD::declval<_A2&>())) type;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Class, class _A0, class _A1, class _A2>
|
||||
struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
|
||||
typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
|
||||
};
|
||||
#endif // _LIBCPP_FUNCTIONAL_BASE_03
|
2913
libcxx/include/__hash_table
Normal file
2913
libcxx/include/__hash_table
Normal file
File diff suppressed because it is too large
Load Diff
1
libcxx/include/__libcpp_version
Normal file
1
libcxx/include/__libcpp_version
Normal file
@ -0,0 +1 @@
|
||||
8000
|
1523
libcxx/include/__locale
Normal file
1523
libcxx/include/__locale
Normal file
File diff suppressed because it is too large
Load Diff
440
libcxx/include/__mutex_base
Normal file
440
libcxx/include/__mutex_base
Normal file
@ -0,0 +1,440 @@
|
||||
// -*- 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___MUTEX_BASE
|
||||
#define _LIBCPP___MUTEX_BASE
|
||||
|
||||
#include <__config>
|
||||
#include <chrono>
|
||||
#include <system_error>
|
||||
#include <__threading_support>
|
||||
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
|
||||
# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
|
||||
# else
|
||||
# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
|
||||
# endif
|
||||
#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
|
||||
|
||||
class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
|
||||
{
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
|
||||
#else
|
||||
__libcpp_mutex_t __m_;
|
||||
#endif
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
constexpr mutex() = default;
|
||||
#else
|
||||
mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
|
||||
#endif
|
||||
~mutex();
|
||||
|
||||
private:
|
||||
mutex(const mutex&);// = delete;
|
||||
mutex& operator=(const mutex&);// = delete;
|
||||
|
||||
public:
|
||||
void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
|
||||
bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
|
||||
void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
|
||||
|
||||
typedef __libcpp_mutex_t* native_handle_type;
|
||||
_LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
|
||||
};
|
||||
|
||||
static_assert(is_nothrow_default_constructible<mutex>::value,
|
||||
"the default constructor for std::mutex must be nothrow");
|
||||
|
||||
struct _LIBCPP_TYPE_VIS defer_lock_t {};
|
||||
struct _LIBCPP_TYPE_VIS try_to_lock_t {};
|
||||
struct _LIBCPP_TYPE_VIS adopt_lock_t {};
|
||||
|
||||
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
|
||||
extern _LIBCPP_EXPORTED_FROM_ABI const defer_lock_t defer_lock;
|
||||
extern _LIBCPP_EXPORTED_FROM_ABI const try_to_lock_t try_to_lock;
|
||||
extern _LIBCPP_EXPORTED_FROM_ABI const adopt_lock_t adopt_lock;
|
||||
|
||||
#else
|
||||
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr defer_lock_t defer_lock = defer_lock_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr try_to_lock_t try_to_lock = try_to_lock_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
|
||||
|
||||
#endif
|
||||
|
||||
template <class _Mutex>
|
||||
class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
|
||||
lock_guard
|
||||
{
|
||||
public:
|
||||
typedef _Mutex mutex_type;
|
||||
|
||||
private:
|
||||
mutex_type& __m_;
|
||||
public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
|
||||
: __m_(__m) {__m_.lock();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
|
||||
: __m_(__m) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
|
||||
|
||||
private:
|
||||
lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE;
|
||||
lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE;
|
||||
};
|
||||
|
||||
template <class _Mutex>
|
||||
class _LIBCPP_TEMPLATE_VIS unique_lock
|
||||
{
|
||||
public:
|
||||
typedef _Mutex mutex_type;
|
||||
|
||||
private:
|
||||
mutex_type* __m_;
|
||||
bool __owns_;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit unique_lock(mutex_type& __m)
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(false) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, try_to_lock_t)
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, adopt_lock_t)
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(true) {}
|
||||
template <class _Clock, class _Duration>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
|
||||
template <class _Rep, class _Period>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
|
||||
: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~unique_lock()
|
||||
{
|
||||
if (__owns_)
|
||||
__m_->unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
unique_lock(unique_lock const&); // = delete;
|
||||
unique_lock& operator=(unique_lock const&); // = delete;
|
||||
|
||||
public:
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock(unique_lock&& __u) _NOEXCEPT
|
||||
: __m_(__u.__m_), __owns_(__u.__owns_)
|
||||
{__u.__m_ = nullptr; __u.__owns_ = false;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unique_lock& operator=(unique_lock&& __u) _NOEXCEPT
|
||||
{
|
||||
if (__owns_)
|
||||
__m_->unlock();
|
||||
__m_ = __u.__m_;
|
||||
__owns_ = __u.__owns_;
|
||||
__u.__m_ = nullptr;
|
||||
__u.__owns_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
void lock();
|
||||
bool try_lock();
|
||||
|
||||
template <class _Rep, class _Period>
|
||||
bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
|
||||
template <class _Clock, class _Duration>
|
||||
bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
|
||||
|
||||
void unlock();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(unique_lock& __u) _NOEXCEPT
|
||||
{
|
||||
_VSTD::swap(__m_, __u.__m_);
|
||||
_VSTD::swap(__owns_, __u.__owns_);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
mutex_type* release() _NOEXCEPT
|
||||
{
|
||||
mutex_type* __m = __m_;
|
||||
__m_ = nullptr;
|
||||
__owns_ = false;
|
||||
return __m;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool owns_lock() const _NOEXCEPT {return __owns_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT
|
||||
operator bool () const _NOEXCEPT {return __owns_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
mutex_type* mutex() const _NOEXCEPT {return __m_;}
|
||||
};
|
||||
|
||||
template <class _Mutex>
|
||||
void
|
||||
unique_lock<_Mutex>::lock()
|
||||
{
|
||||
if (__m_ == nullptr)
|
||||
__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
|
||||
if (__owns_)
|
||||
__throw_system_error(EDEADLK, "unique_lock::lock: already locked");
|
||||
__m_->lock();
|
||||
__owns_ = true;
|
||||
}
|
||||
|
||||
template <class _Mutex>
|
||||
bool
|
||||
unique_lock<_Mutex>::try_lock()
|
||||
{
|
||||
if (__m_ == nullptr)
|
||||
__throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
|
||||
if (__owns_)
|
||||
__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
|
||||
__owns_ = __m_->try_lock();
|
||||
return __owns_;
|
||||
}
|
||||
|
||||
template <class _Mutex>
|
||||
template <class _Rep, class _Period>
|
||||
bool
|
||||
unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d)
|
||||
{
|
||||
if (__m_ == nullptr)
|
||||
__throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
|
||||
if (__owns_)
|
||||
__throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked");
|
||||
__owns_ = __m_->try_lock_for(__d);
|
||||
return __owns_;
|
||||
}
|
||||
|
||||
template <class _Mutex>
|
||||
template <class _Clock, class _Duration>
|
||||
bool
|
||||
unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
if (__m_ == nullptr)
|
||||
__throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
|
||||
if (__owns_)
|
||||
__throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked");
|
||||
__owns_ = __m_->try_lock_until(__t);
|
||||
return __owns_;
|
||||
}
|
||||
|
||||
template <class _Mutex>
|
||||
void
|
||||
unique_lock<_Mutex>::unlock()
|
||||
{
|
||||
if (!__owns_)
|
||||
__throw_system_error(EPERM, "unique_lock::unlock: not locked");
|
||||
__m_->unlock();
|
||||
__owns_ = false;
|
||||
}
|
||||
|
||||
template <class _Mutex>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT
|
||||
{__x.swap(__y);}
|
||||
|
||||
//enum class cv_status
|
||||
_LIBCPP_DECLARE_STRONG_ENUM(cv_status)
|
||||
{
|
||||
no_timeout,
|
||||
timeout
|
||||
};
|
||||
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable
|
||||
{
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
|
||||
#else
|
||||
__libcpp_condvar_t __cv_;
|
||||
#endif
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
constexpr condition_variable() _NOEXCEPT = default;
|
||||
#else
|
||||
condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
|
||||
#endif
|
||||
~condition_variable();
|
||||
|
||||
private:
|
||||
condition_variable(const condition_variable&); // = delete;
|
||||
condition_variable& operator=(const condition_variable&); // = delete;
|
||||
|
||||
public:
|
||||
void notify_one() _NOEXCEPT;
|
||||
void notify_all() _NOEXCEPT;
|
||||
|
||||
void wait(unique_lock<mutex>& __lk) _NOEXCEPT;
|
||||
template <class _Predicate>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
void wait(unique_lock<mutex>& __lk, _Predicate __pred);
|
||||
|
||||
template <class _Clock, class _Duration>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
cv_status
|
||||
wait_until(unique_lock<mutex>& __lk,
|
||||
const chrono::time_point<_Clock, _Duration>& __t);
|
||||
|
||||
template <class _Clock, class _Duration, class _Predicate>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
bool
|
||||
wait_until(unique_lock<mutex>& __lk,
|
||||
const chrono::time_point<_Clock, _Duration>& __t,
|
||||
_Predicate __pred);
|
||||
|
||||
template <class _Rep, class _Period>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
cv_status
|
||||
wait_for(unique_lock<mutex>& __lk,
|
||||
const chrono::duration<_Rep, _Period>& __d);
|
||||
|
||||
template <class _Rep, class _Period, class _Predicate>
|
||||
bool
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_for(unique_lock<mutex>& __lk,
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred);
|
||||
|
||||
typedef __libcpp_condvar_t* native_handle_type;
|
||||
_LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;}
|
||||
|
||||
private:
|
||||
void __do_timed_wait(unique_lock<mutex>& __lk,
|
||||
chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
|
||||
};
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
template <class _To, class _Rep, class _Period>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
chrono::__is_duration<_To>::value,
|
||||
_To
|
||||
>::type
|
||||
__ceil(chrono::duration<_Rep, _Period> __d)
|
||||
{
|
||||
using namespace chrono;
|
||||
_To __r = duration_cast<_To>(__d);
|
||||
if (__r < __d)
|
||||
++__r;
|
||||
return __r;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
template <class _Predicate>
|
||||
void
|
||||
condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred)
|
||||
{
|
||||
while (!__pred())
|
||||
wait(__lk);
|
||||
}
|
||||
|
||||
template <class _Clock, class _Duration>
|
||||
cv_status
|
||||
condition_variable::wait_until(unique_lock<mutex>& __lk,
|
||||
const chrono::time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
using namespace chrono;
|
||||
wait_for(__lk, __t - _Clock::now());
|
||||
return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;
|
||||
}
|
||||
|
||||
template <class _Clock, class _Duration, class _Predicate>
|
||||
bool
|
||||
condition_variable::wait_until(unique_lock<mutex>& __lk,
|
||||
const chrono::time_point<_Clock, _Duration>& __t,
|
||||
_Predicate __pred)
|
||||
{
|
||||
while (!__pred())
|
||||
{
|
||||
if (wait_until(__lk, __t) == cv_status::timeout)
|
||||
return __pred();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Rep, class _Period>
|
||||
cv_status
|
||||
condition_variable::wait_for(unique_lock<mutex>& __lk,
|
||||
const chrono::duration<_Rep, _Period>& __d)
|
||||
{
|
||||
using namespace chrono;
|
||||
if (__d <= __d.zero())
|
||||
return cv_status::timeout;
|
||||
typedef time_point<system_clock, duration<long double, nano> > __sys_tpf;
|
||||
typedef time_point<system_clock, nanoseconds> __sys_tpi;
|
||||
__sys_tpf _Max = __sys_tpi::max();
|
||||
steady_clock::time_point __c_now = steady_clock::now();
|
||||
system_clock::time_point __s_now = system_clock::now();
|
||||
if (_Max - __d > __s_now)
|
||||
__do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d));
|
||||
else
|
||||
__do_timed_wait(__lk, __sys_tpi::max());
|
||||
return steady_clock::now() - __c_now < __d ? cv_status::no_timeout :
|
||||
cv_status::timeout;
|
||||
}
|
||||
|
||||
template <class _Rep, class _Period, class _Predicate>
|
||||
inline
|
||||
bool
|
||||
condition_variable::wait_for(unique_lock<mutex>& __lk,
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred)
|
||||
{
|
||||
return wait_until(__lk, chrono::steady_clock::now() + __d,
|
||||
_VSTD::move(__pred));
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___MUTEX_BASE
|
210
libcxx/include/__node_handle
Normal file
210
libcxx/include/__node_handle
Normal file
@ -0,0 +1,210 @@
|
||||
// -*- 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___NODE_HANDLE
|
||||
#define _LIBCPP___NODE_HANDLE
|
||||
|
||||
#include <__config>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
// Specialized in __tree & __hash_table for their _NodeType.
|
||||
template <class _NodeType, class _Alloc>
|
||||
struct __generic_container_node_destructor;
|
||||
|
||||
template <class _NodeType, class _Alloc,
|
||||
template <class, class> class _MapOrSetSpecifics>
|
||||
class _LIBCPP_TEMPLATE_VIS __basic_node_handle
|
||||
: public _MapOrSetSpecifics<
|
||||
_NodeType,
|
||||
__basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>
|
||||
{
|
||||
template <class _Tp, class _Compare, class _Allocator>
|
||||
friend class __tree;
|
||||
template <class _Tp, class _Hash, class _Equal, class _Allocator>
|
||||
friend class __hash_table;
|
||||
friend struct _MapOrSetSpecifics<
|
||||
_NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;
|
||||
|
||||
typedef allocator_traits<_Alloc> __alloc_traits;
|
||||
typedef typename __rebind_pointer<typename __alloc_traits::void_pointer,
|
||||
_NodeType>::type
|
||||
__node_pointer_type;
|
||||
|
||||
public:
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
private:
|
||||
__node_pointer_type __ptr_ = nullptr;
|
||||
optional<allocator_type> __alloc_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __release()
|
||||
{
|
||||
__ptr_ = nullptr;
|
||||
__alloc_ = _VSTD::nullopt;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destroy_node_pointer()
|
||||
{
|
||||
if (__ptr_ != nullptr)
|
||||
{
|
||||
typedef typename __allocator_traits_rebind<
|
||||
allocator_type, _NodeType>::type __node_alloc_type;
|
||||
__node_alloc_type __alloc(*__alloc_);
|
||||
__generic_container_node_destructor<_NodeType, __node_alloc_type>(
|
||||
__alloc, true)(__ptr_);
|
||||
__ptr_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__basic_node_handle(__node_pointer_type __ptr,
|
||||
allocator_type const& __alloc)
|
||||
: __ptr_(__ptr), __alloc_(__alloc)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__basic_node_handle() = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__basic_node_handle(__basic_node_handle&& __other) noexcept
|
||||
: __ptr_(__other.__ptr_),
|
||||
__alloc_(_VSTD::move(__other.__alloc_))
|
||||
{
|
||||
__other.__ptr_ = nullptr;
|
||||
__other.__alloc_ = _VSTD::nullopt;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__basic_node_handle& operator=(__basic_node_handle&& __other)
|
||||
{
|
||||
_LIBCPP_ASSERT(
|
||||
__alloc_ == _VSTD::nullopt ||
|
||||
__alloc_traits::propagate_on_container_move_assignment::value ||
|
||||
__alloc_ == __other.__alloc_,
|
||||
"node_type with incompatible allocator passed to "
|
||||
"node_type::operator=(node_type&&)");
|
||||
|
||||
__destroy_node_pointer();
|
||||
__ptr_ = __other.__ptr_;
|
||||
|
||||
if (__alloc_traits::propagate_on_container_move_assignment::value ||
|
||||
__alloc_ == _VSTD::nullopt)
|
||||
__alloc_ = _VSTD::move(__other.__alloc_);
|
||||
|
||||
__other.__ptr_ = nullptr;
|
||||
__other.__alloc_ = _VSTD::nullopt;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const { return *__alloc_; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit operator bool() const { return __ptr_ != nullptr; }
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const { return __ptr_ == nullptr; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(__basic_node_handle& __other) noexcept(
|
||||
__alloc_traits::propagate_on_container_swap::value ||
|
||||
__alloc_traits::is_always_equal::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(__ptr_, __other.__ptr_);
|
||||
if (__alloc_traits::propagate_on_container_swap::value ||
|
||||
__alloc_ == _VSTD::nullopt || __other.__alloc_ == _VSTD::nullopt)
|
||||
swap(__alloc_, __other.__alloc_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
friend void swap(__basic_node_handle& __a, __basic_node_handle& __b)
|
||||
noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~__basic_node_handle()
|
||||
{
|
||||
__destroy_node_pointer();
|
||||
}
|
||||
};
|
||||
|
||||
template <class _NodeType, class _Derived>
|
||||
struct __set_node_handle_specifics
|
||||
{
|
||||
typedef typename _NodeType::__node_value_type value_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type& value() const
|
||||
{
|
||||
return static_cast<_Derived const*>(this)->__ptr_->__value_;
|
||||
}
|
||||
};
|
||||
|
||||
template <class _NodeType, class _Derived>
|
||||
struct __map_node_handle_specifics
|
||||
{
|
||||
typedef typename _NodeType::__node_value_type::key_type key_type;
|
||||
typedef typename _NodeType::__node_value_type::mapped_type mapped_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_type& key() const
|
||||
{
|
||||
return static_cast<_Derived const*>(this)->
|
||||
__ptr_->__value_.__ref().first;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
mapped_type& mapped() const
|
||||
{
|
||||
return static_cast<_Derived const*>(this)->
|
||||
__ptr_->__value_.__ref().second;
|
||||
}
|
||||
};
|
||||
|
||||
template <class _NodeType, class _Alloc>
|
||||
using __set_node_handle =
|
||||
__basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>;
|
||||
|
||||
template <class _NodeType, class _Alloc>
|
||||
using __map_node_handle =
|
||||
__basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;
|
||||
|
||||
template <class _Iterator, class _NodeType>
|
||||
_LIBCPP_TEMPLATE_VIS
|
||||
struct __insert_return_type
|
||||
{
|
||||
_Iterator position;
|
||||
bool inserted;
|
||||
_NodeType node;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif
|
62
libcxx/include/__nullptr
Normal file
62
libcxx/include/__nullptr
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- __nullptr --------------------------------===//
|
||||
//
|
||||
// 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_NULLPTR
|
||||
#define _LIBCPP_NULLPTR
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_NULLPTR
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
struct _LIBCPP_TEMPLATE_VIS nullptr_t
|
||||
{
|
||||
void* __lx;
|
||||
|
||||
struct __nat {int __for_bool_;};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
operator _Tp* () const {return 0;}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator _Tp _Up::* () const {return 0;}
|
||||
|
||||
friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
|
||||
friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
|
||||
};
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
|
||||
|
||||
#define nullptr _VSTD::__get_nullptr_t()
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#else // _LIBCPP_HAS_NO_NULLPTR
|
||||
|
||||
namespace std
|
||||
{
|
||||
typedef decltype(nullptr) nullptr_t;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_NULLPTR
|
||||
|
||||
#endif // _LIBCPP_NULLPTR
|
637
libcxx/include/__split_buffer
Normal file
637
libcxx/include/__split_buffer
Normal file
@ -0,0 +1,637 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef _LIBCPP_SPLIT_BUFFER
|
||||
#define _LIBCPP_SPLIT_BUFFER
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <bool>
|
||||
class __split_buffer_common
|
||||
{
|
||||
protected:
|
||||
void __throw_length_error() const;
|
||||
void __throw_out_of_range() const;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Allocator = allocator<_Tp> >
|
||||
struct __split_buffer
|
||||
: private __split_buffer_common<true>
|
||||
{
|
||||
private:
|
||||
__split_buffer(const __split_buffer&);
|
||||
__split_buffer& operator=(const __split_buffer&);
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
typedef _Allocator allocator_type;
|
||||
typedef typename remove_reference<allocator_type>::type __alloc_rr;
|
||||
typedef allocator_traits<__alloc_rr> __alloc_traits;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
typedef pointer iterator;
|
||||
typedef const_pointer const_iterator;
|
||||
|
||||
pointer __first_;
|
||||
pointer __begin_;
|
||||
pointer __end_;
|
||||
__compressed_pair<pointer, allocator_type> __end_cap_;
|
||||
|
||||
typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
|
||||
typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
|
||||
_LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
|
||||
_LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__split_buffer()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __split_buffer(__alloc_rr& __a);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __split_buffer(const __alloc_rr& __a);
|
||||
__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
|
||||
~__split_buffer();
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__split_buffer(__split_buffer&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
|
||||
__split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
|
||||
__split_buffer& operator=(__split_buffer&& __c)
|
||||
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value) ||
|
||||
!__alloc_traits::propagate_on_container_move_assignment::value);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
|
||||
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
|
||||
_LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{__destruct_at_end(__begin_);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
|
||||
_LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
|
||||
_LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
|
||||
_LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
|
||||
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
|
||||
|
||||
void reserve(size_type __n);
|
||||
void shrink_to_fit() _NOEXCEPT;
|
||||
void push_front(const_reference __x);
|
||||
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
void push_front(value_type&& __x);
|
||||
void push_back(value_type&& __x);
|
||||
template <class... _Args>
|
||||
void emplace_back(_Args&&... __args);
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
|
||||
_LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
|
||||
|
||||
void __construct_at_end(size_type __n);
|
||||
void __construct_at_end(size_type __n, const_reference __x);
|
||||
template <class _InputIter>
|
||||
typename enable_if
|
||||
<
|
||||
__is_input_iterator<_InputIter>::value &&
|
||||
!__is_forward_iterator<_InputIter>::value,
|
||||
void
|
||||
>::type
|
||||
__construct_at_end(_InputIter __first, _InputIter __last);
|
||||
template <class _ForwardIterator>
|
||||
typename enable_if
|
||||
<
|
||||
__is_forward_iterator<_ForwardIterator>::value,
|
||||
void
|
||||
>::type
|
||||
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
|
||||
{__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_begin(pointer __new_begin, false_type);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_begin(pointer __new_begin, true_type);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(pointer __new_last) _NOEXCEPT
|
||||
{__destruct_at_end(__new_last, false_type());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
|
||||
|
||||
void swap(__split_buffer& __x)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
|
||||
__is_nothrow_swappable<__alloc_rr>::value);
|
||||
|
||||
bool __invariants() const;
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign_alloc(__split_buffer& __c, true_type)
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
|
||||
{
|
||||
__alloc() = _VSTD::move(__c.__alloc());
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
|
||||
{}
|
||||
};
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
bool
|
||||
__split_buffer<_Tp, _Allocator>::__invariants() const
|
||||
{
|
||||
if (__first_ == nullptr)
|
||||
{
|
||||
if (__begin_ != nullptr)
|
||||
return false;
|
||||
if (__end_ != nullptr)
|
||||
return false;
|
||||
if (__end_cap() != nullptr)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__begin_ < __first_)
|
||||
return false;
|
||||
if (__end_ < __begin_)
|
||||
return false;
|
||||
if (__end_cap() < __end_)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Default constructs __n objects starting at __end_
|
||||
// throws if construction throws
|
||||
// Precondition: __n > 0
|
||||
// Precondition: size() + __n <= capacity()
|
||||
// Postcondition: size() == size() + __n
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
|
||||
{
|
||||
__alloc_rr& __a = this->__alloc();
|
||||
do
|
||||
{
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
|
||||
++this->__end_;
|
||||
--__n;
|
||||
} while (__n > 0);
|
||||
}
|
||||
|
||||
// Copy constructs __n objects starting at __end_ from __x
|
||||
// throws if construction throws
|
||||
// Precondition: __n > 0
|
||||
// Precondition: size() + __n <= capacity()
|
||||
// Postcondition: size() == old size() + __n
|
||||
// Postcondition: [i] == __x for all i in [size() - __n, __n)
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
|
||||
{
|
||||
__alloc_rr& __a = this->__alloc();
|
||||
do
|
||||
{
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x);
|
||||
++this->__end_;
|
||||
--__n;
|
||||
} while (__n > 0);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
template <class _InputIter>
|
||||
typename enable_if
|
||||
<
|
||||
__is_input_iterator<_InputIter>::value &&
|
||||
!__is_forward_iterator<_InputIter>::value,
|
||||
void
|
||||
>::type
|
||||
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
|
||||
{
|
||||
__alloc_rr& __a = this->__alloc();
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
if (__end_ == __end_cap())
|
||||
{
|
||||
size_type __old_cap = __end_cap() - __first_;
|
||||
size_type __new_cap = _VSTD::max<size_type>(2 * __old_cap, 8);
|
||||
__split_buffer __buf(__new_cap, 0, __a);
|
||||
for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_)
|
||||
__alloc_traits::construct(__buf.__alloc(),
|
||||
_VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p));
|
||||
swap(__buf);
|
||||
}
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
|
||||
++this->__end_;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
template <class _ForwardIterator>
|
||||
typename enable_if
|
||||
<
|
||||
__is_forward_iterator<_ForwardIterator>::value,
|
||||
void
|
||||
>::type
|
||||
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
__alloc_rr& __a = this->__alloc();
|
||||
for (; __first != __last; ++__first)
|
||||
{
|
||||
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
|
||||
++this->__end_;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
|
||||
{
|
||||
while (__begin_ != __new_begin)
|
||||
__alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
|
||||
{
|
||||
__begin_ = __new_begin;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
|
||||
{
|
||||
while (__new_last != __end_)
|
||||
__alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
|
||||
{
|
||||
__end_ = __new_last;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
|
||||
: __end_cap_(nullptr, __a)
|
||||
{
|
||||
__first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
|
||||
__begin_ = __end_ = __first_ + __start;
|
||||
__end_cap() = __first_ + __cap;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
|
||||
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
|
||||
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__split_buffer<_Tp, _Allocator>::~__split_buffer()
|
||||
{
|
||||
clear();
|
||||
if (__first_)
|
||||
__alloc_traits::deallocate(__alloc(), __first_, capacity());
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
|
||||
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
|
||||
: __first_(_VSTD::move(__c.__first_)),
|
||||
__begin_(_VSTD::move(__c.__begin_)),
|
||||
__end_(_VSTD::move(__c.__end_)),
|
||||
__end_cap_(_VSTD::move(__c.__end_cap_))
|
||||
{
|
||||
__c.__first_ = nullptr;
|
||||
__c.__begin_ = nullptr;
|
||||
__c.__end_ = nullptr;
|
||||
__c.__end_cap() = nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
|
||||
: __end_cap_(__second_tag(), __a)
|
||||
{
|
||||
if (__a == __c.__alloc())
|
||||
{
|
||||
__first_ = __c.__first_;
|
||||
__begin_ = __c.__begin_;
|
||||
__end_ = __c.__end_;
|
||||
__end_cap() = __c.__end_cap();
|
||||
__c.__first_ = nullptr;
|
||||
__c.__begin_ = nullptr;
|
||||
__c.__end_ = nullptr;
|
||||
__c.__end_cap() = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __cap = __c.size();
|
||||
__first_ = __alloc_traits::allocate(__alloc(), __cap);
|
||||
__begin_ = __end_ = __first_;
|
||||
__end_cap() = __first_ + __cap;
|
||||
typedef move_iterator<iterator> _Ip;
|
||||
__construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__split_buffer<_Tp, _Allocator>&
|
||||
__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
|
||||
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value) ||
|
||||
!__alloc_traits::propagate_on_container_move_assignment::value)
|
||||
{
|
||||
clear();
|
||||
shrink_to_fit();
|
||||
__first_ = __c.__first_;
|
||||
__begin_ = __c.__begin_;
|
||||
__end_ = __c.__end_;
|
||||
__end_cap() = __c.__end_cap();
|
||||
__move_assign_alloc(__c,
|
||||
integral_constant<bool,
|
||||
__alloc_traits::propagate_on_container_move_assignment::value>());
|
||||
__c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
|
||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
|
||||
__is_nothrow_swappable<__alloc_rr>::value)
|
||||
{
|
||||
_VSTD::swap(__first_, __x.__first_);
|
||||
_VSTD::swap(__begin_, __x.__begin_);
|
||||
_VSTD::swap(__end_, __x.__end_);
|
||||
_VSTD::swap(__end_cap(), __x.__end_cap());
|
||||
__swap_allocator(__alloc(), __x.__alloc());
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
|
||||
{
|
||||
if (__n < capacity())
|
||||
{
|
||||
__split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
|
||||
{
|
||||
if (capacity() > size())
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
__t.__end_ = __t.__begin_ + (__end_ - __begin_);
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
|
||||
{
|
||||
if (__begin_ == __first_)
|
||||
{
|
||||
if (__end_ < __end_cap())
|
||||
{
|
||||
difference_type __d = __end_cap() - __end_;
|
||||
__d = (__d + 1) / 2;
|
||||
__begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
|
||||
__end_ += __d;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
|
||||
__split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
}
|
||||
}
|
||||
__alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x);
|
||||
--__begin_;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
|
||||
{
|
||||
if (__begin_ == __first_)
|
||||
{
|
||||
if (__end_ < __end_cap())
|
||||
{
|
||||
difference_type __d = __end_cap() - __end_;
|
||||
__d = (__d + 1) / 2;
|
||||
__begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
|
||||
__end_ += __d;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
|
||||
__split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
}
|
||||
}
|
||||
__alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1),
|
||||
_VSTD::move(__x));
|
||||
--__begin_;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
|
||||
{
|
||||
if (__end_ == __end_cap())
|
||||
{
|
||||
if (__begin_ > __first_)
|
||||
{
|
||||
difference_type __d = __begin_ - __first_;
|
||||
__d = (__d + 1) / 2;
|
||||
__end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
|
||||
__begin_ -= __d;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
|
||||
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
}
|
||||
}
|
||||
__alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x);
|
||||
++__end_;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
|
||||
{
|
||||
if (__end_ == __end_cap())
|
||||
{
|
||||
if (__begin_ > __first_)
|
||||
{
|
||||
difference_type __d = __begin_ - __first_;
|
||||
__d = (__d + 1) / 2;
|
||||
__end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
|
||||
__begin_ -= __d;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
|
||||
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
}
|
||||
}
|
||||
__alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_),
|
||||
_VSTD::move(__x));
|
||||
++__end_;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
template <class... _Args>
|
||||
void
|
||||
__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
|
||||
{
|
||||
if (__end_ == __end_cap())
|
||||
{
|
||||
if (__begin_ > __first_)
|
||||
{
|
||||
difference_type __d = __begin_ - __first_;
|
||||
__d = (__d + 1) / 2;
|
||||
__end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
|
||||
__begin_ -= __d;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
|
||||
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
|
||||
__t.__construct_at_end(move_iterator<pointer>(__begin_),
|
||||
move_iterator<pointer>(__end_));
|
||||
_VSTD::swap(__first_, __t.__first_);
|
||||
_VSTD::swap(__begin_, __t.__begin_);
|
||||
_VSTD::swap(__end_, __t.__end_);
|
||||
_VSTD::swap(__end_cap(), __t.__end_cap());
|
||||
}
|
||||
}
|
||||
__alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_),
|
||||
_VSTD::forward<_Args>(__args)...);
|
||||
++__end_;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_SPLIT_BUFFER
|
77
libcxx/include/__sso_allocator
Normal file
77
libcxx/include/__sso_allocator
Normal file
@ -0,0 +1,77 @@
|
||||
// -*- 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___SSO_ALLOCATOR
|
||||
#define _LIBCPP___SSO_ALLOCATOR
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
#include <new>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, size_t _Np> class _LIBCPP_HIDDEN __sso_allocator;
|
||||
|
||||
template <size_t _Np>
|
||||
class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
|
||||
{
|
||||
public:
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
};
|
||||
|
||||
template <class _Tp, size_t _Np>
|
||||
class _LIBCPP_HIDDEN __sso_allocator
|
||||
{
|
||||
typename aligned_storage<sizeof(_Tp) * _Np>::type buf_;
|
||||
bool __allocated_;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp value_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
|
||||
_LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
|
||||
template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
|
||||
: __allocated_(false) {}
|
||||
private:
|
||||
__sso_allocator& operator=(const __sso_allocator&);
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = 0)
|
||||
{
|
||||
if (!__allocated_ && __n <= _Np)
|
||||
{
|
||||
__allocated_ = true;
|
||||
return (pointer)&buf_;
|
||||
}
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n)
|
||||
{
|
||||
if (__p == (pointer)&buf_)
|
||||
__allocated_ = false;
|
||||
else
|
||||
_VSTD::__libcpp_deallocate(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___SSO_ALLOCATOR
|
362
libcxx/include/__std_stream
Normal file
362
libcxx/include/__std_stream
Normal file
@ -0,0 +1,362 @@
|
||||
// -*- 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___STD_STREAM
|
||||
#define _LIBCPP___STD_STREAM
|
||||
|
||||
#include <__config>
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <__locale>
|
||||
#include <cstdio>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
static const int __limit = 8;
|
||||
|
||||
// __stdinbuf
|
||||
|
||||
template <class _CharT>
|
||||
class _LIBCPP_HIDDEN __stdinbuf
|
||||
: public basic_streambuf<_CharT, char_traits<_CharT> >
|
||||
{
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
typedef typename traits_type::state_type state_type;
|
||||
|
||||
__stdinbuf(FILE* __fp, state_type* __st);
|
||||
|
||||
protected:
|
||||
virtual int_type underflow();
|
||||
virtual int_type uflow();
|
||||
virtual int_type pbackfail(int_type __c = traits_type::eof());
|
||||
virtual void imbue(const locale& __loc);
|
||||
|
||||
private:
|
||||
|
||||
FILE* __file_;
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type* __st_;
|
||||
int __encoding_;
|
||||
int_type __last_consumed_;
|
||||
bool __last_consumed_is_next_;
|
||||
bool __always_noconv_;
|
||||
|
||||
__stdinbuf(const __stdinbuf&);
|
||||
__stdinbuf& operator=(const __stdinbuf&);
|
||||
|
||||
int_type __getchar(bool __consume);
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
|
||||
: __file_(__fp),
|
||||
__st_(__st),
|
||||
__last_consumed_(traits_type::eof()),
|
||||
__last_consumed_is_next_(false)
|
||||
{
|
||||
imbue(this->getloc());
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
void
|
||||
__stdinbuf<_CharT>::imbue(const locale& __loc)
|
||||
{
|
||||
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
|
||||
__encoding_ = __cv_->encoding();
|
||||
__always_noconv_ = __cv_->always_noconv();
|
||||
if (__encoding_ > __limit)
|
||||
__throw_runtime_error("unsupported locale for standard input");
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::underflow()
|
||||
{
|
||||
return __getchar(false);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::uflow()
|
||||
{
|
||||
return __getchar(true);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::__getchar(bool __consume)
|
||||
{
|
||||
if (__last_consumed_is_next_)
|
||||
{
|
||||
int_type __result = __last_consumed_;
|
||||
if (__consume)
|
||||
{
|
||||
__last_consumed_ = traits_type::eof();
|
||||
__last_consumed_is_next_ = false;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
char __extbuf[__limit];
|
||||
int __nread = _VSTD::max(1, __encoding_);
|
||||
for (int __i = 0; __i < __nread; ++__i)
|
||||
{
|
||||
int __c = getc(__file_);
|
||||
if (__c == EOF)
|
||||
return traits_type::eof();
|
||||
__extbuf[__i] = static_cast<char>(__c);
|
||||
}
|
||||
char_type __1buf;
|
||||
if (__always_noconv_)
|
||||
__1buf = static_cast<char_type>(__extbuf[0]);
|
||||
else
|
||||
{
|
||||
const char* __enxt;
|
||||
char_type* __inxt;
|
||||
codecvt_base::result __r;
|
||||
do
|
||||
{
|
||||
state_type __sv_st = *__st_;
|
||||
__r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
|
||||
&__1buf, &__1buf + 1, __inxt);
|
||||
switch (__r)
|
||||
{
|
||||
case _VSTD::codecvt_base::ok:
|
||||
break;
|
||||
case codecvt_base::partial:
|
||||
*__st_ = __sv_st;
|
||||
if (__nread == sizeof(__extbuf))
|
||||
return traits_type::eof();
|
||||
{
|
||||
int __c = getc(__file_);
|
||||
if (__c == EOF)
|
||||
return traits_type::eof();
|
||||
__extbuf[__nread] = static_cast<char>(__c);
|
||||
}
|
||||
++__nread;
|
||||
break;
|
||||
case codecvt_base::error:
|
||||
return traits_type::eof();
|
||||
case _VSTD::codecvt_base::noconv:
|
||||
__1buf = static_cast<char_type>(__extbuf[0]);
|
||||
break;
|
||||
}
|
||||
} while (__r == _VSTD::codecvt_base::partial);
|
||||
}
|
||||
if (!__consume)
|
||||
{
|
||||
for (int __i = __nread; __i > 0;)
|
||||
{
|
||||
if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
else
|
||||
__last_consumed_ = traits_type::to_int_type(__1buf);
|
||||
return traits_type::to_int_type(__1buf);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::pbackfail(int_type __c)
|
||||
{
|
||||
if (traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
{
|
||||
if (!__last_consumed_is_next_)
|
||||
{
|
||||
__c = __last_consumed_;
|
||||
__last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
|
||||
traits_type::eof());
|
||||
}
|
||||
return __c;
|
||||
}
|
||||
if (__last_consumed_is_next_)
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
char* __enxt;
|
||||
const char_type __ci = traits_type::to_char_type(__last_consumed_);
|
||||
const char_type* __inxt;
|
||||
switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
|
||||
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
|
||||
{
|
||||
case _VSTD::codecvt_base::ok:
|
||||
break;
|
||||
case _VSTD::codecvt_base::noconv:
|
||||
__extbuf[0] = static_cast<char>(__last_consumed_);
|
||||
__enxt = __extbuf + 1;
|
||||
break;
|
||||
case codecvt_base::partial:
|
||||
case codecvt_base::error:
|
||||
return traits_type::eof();
|
||||
}
|
||||
while (__enxt > __extbuf)
|
||||
if (ungetc(*--__enxt, __file_) == EOF)
|
||||
return traits_type::eof();
|
||||
}
|
||||
__last_consumed_ = __c;
|
||||
__last_consumed_is_next_ = true;
|
||||
return __c;
|
||||
}
|
||||
|
||||
// __stdoutbuf
|
||||
|
||||
template <class _CharT>
|
||||
class _LIBCPP_HIDDEN __stdoutbuf
|
||||
: public basic_streambuf<_CharT, char_traits<_CharT> >
|
||||
{
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
typedef typename traits_type::state_type state_type;
|
||||
|
||||
__stdoutbuf(FILE* __fp, state_type* __st);
|
||||
|
||||
protected:
|
||||
virtual int_type overflow (int_type __c = traits_type::eof());
|
||||
virtual streamsize xsputn(const char_type* __s, streamsize __n);
|
||||
virtual int sync();
|
||||
virtual void imbue(const locale& __loc);
|
||||
|
||||
private:
|
||||
FILE* __file_;
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type* __st_;
|
||||
bool __always_noconv_;
|
||||
|
||||
__stdoutbuf(const __stdoutbuf&);
|
||||
__stdoutbuf& operator=(const __stdoutbuf&);
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
|
||||
: __file_(__fp),
|
||||
__cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
|
||||
__st_(__st),
|
||||
__always_noconv_(__cv_->always_noconv())
|
||||
{
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
typename __stdoutbuf<_CharT>::int_type
|
||||
__stdoutbuf<_CharT>::overflow(int_type __c)
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
char_type __1buf;
|
||||
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
{
|
||||
__1buf = traits_type::to_char_type(__c);
|
||||
if (__always_noconv_)
|
||||
{
|
||||
if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
|
||||
return traits_type::eof();
|
||||
}
|
||||
else
|
||||
{
|
||||
char* __extbe = __extbuf;
|
||||
codecvt_base::result __r;
|
||||
char_type* pbase = &__1buf;
|
||||
char_type* pptr = pbase + 1;
|
||||
do
|
||||
{
|
||||
const char_type* __e;
|
||||
__r = __cv_->out(*__st_, pbase, pptr, __e,
|
||||
__extbuf,
|
||||
__extbuf + sizeof(__extbuf),
|
||||
__extbe);
|
||||
if (__e == pbase)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::noconv)
|
||||
{
|
||||
if (fwrite(pbase, 1, 1, __file_) != 1)
|
||||
return traits_type::eof();
|
||||
}
|
||||
else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
|
||||
{
|
||||
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
|
||||
if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
pbase = const_cast<char_type*>(__e);
|
||||
}
|
||||
}
|
||||
else
|
||||
return traits_type::eof();
|
||||
} while (__r == codecvt_base::partial);
|
||||
}
|
||||
}
|
||||
return traits_type::not_eof(__c);
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
streamsize
|
||||
__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n)
|
||||
{
|
||||
if (__always_noconv_)
|
||||
return fwrite(__s, sizeof(char_type), __n, __file_);
|
||||
streamsize __i = 0;
|
||||
for (; __i < __n; ++__i, ++__s)
|
||||
if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
|
||||
break;
|
||||
return __i;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
int
|
||||
__stdoutbuf<_CharT>::sync()
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
codecvt_base::result __r;
|
||||
do
|
||||
{
|
||||
char* __extbe;
|
||||
__r = __cv_->unshift(*__st_, __extbuf,
|
||||
__extbuf + sizeof(__extbuf),
|
||||
__extbe);
|
||||
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
|
||||
if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
|
||||
return -1;
|
||||
} while (__r == codecvt_base::partial);
|
||||
if (__r == codecvt_base::error)
|
||||
return -1;
|
||||
if (fflush(__file_))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
void
|
||||
__stdoutbuf<_CharT>::imbue(const locale& __loc)
|
||||
{
|
||||
sync();
|
||||
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
|
||||
__always_noconv_ = __cv_->always_noconv();
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___STD_STREAM
|
974
libcxx/include/__string
Normal file
974
libcxx/include/__string
Normal file
@ -0,0 +1,974 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- __string ----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___STRING
|
||||
#define _LIBCPP___STRING
|
||||
|
||||
/*
|
||||
string synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <class charT>
|
||||
struct char_traits
|
||||
{
|
||||
typedef charT char_type;
|
||||
typedef ... int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
||||
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
||||
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
||||
|
||||
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
||||
static constexpr size_t length(const char_type* s);
|
||||
static constexpr const char_type*
|
||||
find(const char_type* s, size_t n, const char_type& a);
|
||||
static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
||||
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
||||
static char_type* assign(char_type* s, size_t n, char_type a);
|
||||
|
||||
static constexpr int_type not_eof(int_type c) noexcept;
|
||||
static constexpr char_type to_char_type(int_type c) noexcept;
|
||||
static constexpr int_type to_int_type(char_type c) noexcept;
|
||||
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
||||
static constexpr int_type eof() noexcept;
|
||||
};
|
||||
|
||||
template <> struct char_traits<char>;
|
||||
template <> struct char_traits<wchar_t>;
|
||||
template <> struct char_traits<char8_t>; // c++20
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <algorithm> // for search and min
|
||||
#include <cstdio> // For EOF.
|
||||
#include <memory> // for __murmur2_or_cityhash
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// char_traits
|
||||
|
||||
template <class _CharT>
|
||||
struct _LIBCPP_TEMPLATE_VIS char_traits
|
||||
{
|
||||
typedef _CharT char_type;
|
||||
typedef int int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int compare(const char_type* __s1, const char_type* __s2, size_t __n);
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t length(const char_type* __s);
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a);
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
template <class _CharT>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 int
|
||||
char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
{
|
||||
if (lt(*__s1, *__s2))
|
||||
return -1;
|
||||
if (lt(*__s2, *__s1))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t
|
||||
char_traits<_CharT>::length(const char_type* __s)
|
||||
{
|
||||
size_t __len = 0;
|
||||
for (; !eq(*__s, char_type(0)); ++__s)
|
||||
++__len;
|
||||
return __len;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT*
|
||||
char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{
|
||||
for (; __n; --__n)
|
||||
{
|
||||
if (eq(*__s, __a))
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
_CharT*
|
||||
char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
char_type* __r = __s1;
|
||||
if (__s1 < __s2)
|
||||
{
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
assign(*__s1, *__s2);
|
||||
}
|
||||
else if (__s2 < __s1)
|
||||
{
|
||||
__s1 += __n;
|
||||
__s2 += __n;
|
||||
for (; __n; --__n)
|
||||
assign(*--__s1, *--__s2);
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline
|
||||
_CharT*
|
||||
char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
char_type* __r = __s1;
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
assign(*__s1, *__s2);
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline
|
||||
_CharT*
|
||||
char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
|
||||
{
|
||||
char_type* __r = __s;
|
||||
for (; __n; --__n, ++__s)
|
||||
assign(*__s, __a);
|
||||
return __r;
|
||||
}
|
||||
|
||||
// char_traits<char>
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS char_traits<char>
|
||||
{
|
||||
typedef char char_type;
|
||||
typedef int int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return (unsigned char)__c1 < (unsigned char)__c2;}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);}
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
|
||||
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
|
||||
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
|
||||
}
|
||||
static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
|
||||
{return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type((unsigned char)__c);}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int
|
||||
char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return 0;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_memcmp(__s1, __s2, __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return memcmp(__s1, __s2, __n);
|
||||
#else
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
{
|
||||
if (lt(*__s1, *__s2))
|
||||
return -1;
|
||||
if (lt(*__s2, *__s1))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char*
|
||||
char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return nullptr;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_char_memchr(__s, to_int_type(__a), __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return (const char_type*) memchr(__s, to_int_type(__a), __n);
|
||||
#else
|
||||
for (; __n; --__n)
|
||||
{
|
||||
if (eq(*__s, __a))
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// char_traits<wchar_t>
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
|
||||
{
|
||||
typedef wchar_t char_type;
|
||||
typedef wint_t int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t length(const char_type* __s) _NOEXCEPT;
|
||||
static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
|
||||
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
|
||||
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
|
||||
}
|
||||
static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
|
||||
{return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(WEOF);}
|
||||
};
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int
|
||||
char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return 0;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_wmemcmp(__s1, __s2, __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return wmemcmp(__s1, __s2, __n);
|
||||
#else
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
{
|
||||
if (lt(*__s1, *__s2))
|
||||
return -1;
|
||||
if (lt(*__s2, *__s1))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t
|
||||
char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
|
||||
{
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_wcslen(__s);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return wcslen(__s);
|
||||
#else
|
||||
size_t __len = 0;
|
||||
for (; !eq(*__s, char_type(0)); ++__s)
|
||||
++__len;
|
||||
return __len;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const wchar_t*
|
||||
char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return nullptr;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_wmemchr(__s, __a, __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return wmemchr(__s, __a, __n);
|
||||
#else
|
||||
for (; __n; --__n)
|
||||
{
|
||||
if (eq(*__s, __a))
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef _LIBCPP_NO_HAS_CHAR8_T
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
|
||||
{
|
||||
typedef char8_t char_type;
|
||||
typedef unsigned int int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef u8streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
|
||||
{__c1 = __c2;}
|
||||
static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept
|
||||
{return __c1 == __c2;}
|
||||
static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static constexpr
|
||||
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
|
||||
static constexpr
|
||||
size_t length(const char_type* __s) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY static constexpr
|
||||
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
|
||||
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
|
||||
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
|
||||
}
|
||||
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
|
||||
{return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
|
||||
|
||||
static inline constexpr int_type not_eof(int_type __c) noexcept
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
static inline constexpr char_type to_char_type(int_type __c) noexcept
|
||||
{return char_type(__c);}
|
||||
static inline constexpr int_type to_int_type(char_type __c) noexcept
|
||||
{return int_type(__c);}
|
||||
static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept
|
||||
{return __c1 == __c2;}
|
||||
static inline constexpr int_type eof() noexcept
|
||||
{return int_type(EOF);}
|
||||
};
|
||||
|
||||
// TODO use '__builtin_strlen' if it ever supports char8_t ??
|
||||
inline constexpr
|
||||
size_t
|
||||
char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
|
||||
{
|
||||
size_t __len = 0;
|
||||
for (; !eq(*__s, char_type(0)); ++__s)
|
||||
++__len;
|
||||
return __len;
|
||||
}
|
||||
|
||||
inline constexpr
|
||||
int
|
||||
char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_memcmp(__s1, __s2, __n);
|
||||
#else
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
{
|
||||
if (lt(*__s1, *__s2))
|
||||
return -1;
|
||||
if (lt(*__s2, *__s1))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
|
||||
inline constexpr
|
||||
const char8_t*
|
||||
char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
for (; __n; --__n)
|
||||
{
|
||||
if (eq(*__s, __a))
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // #_LIBCPP_NO_HAS_CHAR8_T
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
|
||||
{
|
||||
typedef char16_t char_type;
|
||||
typedef uint_least16_t int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef u16streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t length(const char_type* __s) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(0xFFFF);}
|
||||
};
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int
|
||||
char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
{
|
||||
if (lt(*__s1, *__s2))
|
||||
return -1;
|
||||
if (lt(*__s2, *__s1))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t
|
||||
char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
|
||||
{
|
||||
size_t __len = 0;
|
||||
for (; !eq(*__s, char_type(0)); ++__s)
|
||||
++__len;
|
||||
return __len;
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char16_t*
|
||||
char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
for (; __n; --__n)
|
||||
{
|
||||
if (eq(*__s, __a))
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
char16_t*
|
||||
char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
char_type* __r = __s1;
|
||||
if (__s1 < __s2)
|
||||
{
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
assign(*__s1, *__s2);
|
||||
}
|
||||
else if (__s2 < __s1)
|
||||
{
|
||||
__s1 += __n;
|
||||
__s2 += __n;
|
||||
for (; __n; --__n)
|
||||
assign(*--__s1, *--__s2);
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
inline
|
||||
char16_t*
|
||||
char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
char_type* __r = __s1;
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
assign(*__s1, *__s2);
|
||||
return __r;
|
||||
}
|
||||
|
||||
inline
|
||||
char16_t*
|
||||
char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
|
||||
{
|
||||
char_type* __r = __s;
|
||||
for (; __n; --__n, ++__s)
|
||||
assign(*__s, __a);
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
|
||||
{
|
||||
typedef char32_t char_type;
|
||||
typedef uint_least32_t int_type;
|
||||
typedef streamoff off_type;
|
||||
typedef u32streampos pos_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
|
||||
{return __c1 < __c2;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t length(const char_type* __s) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
|
||||
|
||||
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
|
||||
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
|
||||
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
|
||||
{return char_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
|
||||
{return int_type(__c);}
|
||||
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
|
||||
{return __c1 == __c2;}
|
||||
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
|
||||
{return int_type(0xFFFFFFFF);}
|
||||
};
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
int
|
||||
char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
{
|
||||
if (lt(*__s1, *__s2))
|
||||
return -1;
|
||||
if (lt(*__s2, *__s1))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
size_t
|
||||
char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
|
||||
{
|
||||
size_t __len = 0;
|
||||
for (; !eq(*__s, char_type(0)); ++__s)
|
||||
++__len;
|
||||
return __len;
|
||||
}
|
||||
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const char32_t*
|
||||
char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
for (; __n; --__n)
|
||||
{
|
||||
if (eq(*__s, __a))
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline
|
||||
char32_t*
|
||||
char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
char_type* __r = __s1;
|
||||
if (__s1 < __s2)
|
||||
{
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
assign(*__s1, *__s2);
|
||||
}
|
||||
else if (__s2 < __s1)
|
||||
{
|
||||
__s1 += __n;
|
||||
__s2 += __n;
|
||||
for (; __n; --__n)
|
||||
assign(*--__s1, *--__s2);
|
||||
}
|
||||
return __r;
|
||||
}
|
||||
|
||||
inline
|
||||
char32_t*
|
||||
char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
|
||||
char_type* __r = __s1;
|
||||
for (; __n; --__n, ++__s1, ++__s2)
|
||||
assign(*__s1, *__s2);
|
||||
return __r;
|
||||
}
|
||||
|
||||
inline
|
||||
char32_t*
|
||||
char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
|
||||
{
|
||||
char_type* __r = __s;
|
||||
for (; __n; --__n, ++__s)
|
||||
assign(*__s, __a);
|
||||
return __r;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
|
||||
// helper fns for basic_string and string_view
|
||||
|
||||
// __str_find
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
if (__pos >= __sz)
|
||||
return __npos;
|
||||
const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
|
||||
if (__r == 0)
|
||||
return __npos;
|
||||
return static_cast<_SizeT>(__r - __p);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
|
||||
__search_substring(const _CharT *__first1, const _CharT *__last1,
|
||||
const _CharT *__first2, const _CharT *__last2) {
|
||||
// Take advantage of knowing source and pattern lengths.
|
||||
// Stop short when source is smaller than pattern.
|
||||
const ptrdiff_t __len2 = __last2 - __first2;
|
||||
if (__len2 == 0)
|
||||
return __first1;
|
||||
|
||||
ptrdiff_t __len1 = __last1 - __first1;
|
||||
if (__len1 < __len2)
|
||||
return __last1;
|
||||
|
||||
// First element of __first2 is loop invariant.
|
||||
_CharT __f2 = *__first2;
|
||||
while (true) {
|
||||
__len1 = __last1 - __first1;
|
||||
// Check whether __first1 still has at least __len2 bytes.
|
||||
if (__len1 < __len2)
|
||||
return __last1;
|
||||
|
||||
// Find __f2 the first byte matching in __first1.
|
||||
__first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
|
||||
if (__first1 == 0)
|
||||
return __last1;
|
||||
|
||||
// It is faster to compare from the first byte of __first1 even if we
|
||||
// already know that it matches the first byte of __first2: this is because
|
||||
// __first2 is most likely aligned, as it is user's "pattern" string, and
|
||||
// __first1 + 1 is most likely not aligned, as the match is in the middle of
|
||||
// the string.
|
||||
if (_Traits::compare(__first1, __first2, __len2) == 0)
|
||||
return __first1;
|
||||
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
if (__pos > __sz)
|
||||
return __npos;
|
||||
|
||||
if (__n == 0) // There is nothing to search, just return __pos.
|
||||
return __pos;
|
||||
|
||||
const _CharT *__r = __search_substring<_CharT, _Traits>(
|
||||
__p + __pos, __p + __sz, __s, __s + __n);
|
||||
|
||||
if (__r == __p + __sz)
|
||||
return __npos;
|
||||
return static_cast<_SizeT>(__r - __p);
|
||||
}
|
||||
|
||||
|
||||
// __str_rfind
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_rfind(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
if (__sz < 1)
|
||||
return __npos;
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
for (const _CharT* __ps = __p + __pos; __ps != __p;)
|
||||
{
|
||||
if (_Traits::eq(*--__ps, __c))
|
||||
return static_cast<_SizeT>(__ps - __p);
|
||||
}
|
||||
return __npos;
|
||||
}
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_rfind(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
__pos = _VSTD::min(__pos, __sz);
|
||||
if (__n < __sz - __pos)
|
||||
__pos += __n;
|
||||
else
|
||||
__pos = __sz;
|
||||
const _CharT* __r = _VSTD::__find_end(
|
||||
__p, __p + __pos, __s, __s + __n, _Traits::eq,
|
||||
random_access_iterator_tag(), random_access_iterator_tag());
|
||||
if (__n > 0 && __r == __p + __pos)
|
||||
return __npos;
|
||||
return static_cast<_SizeT>(__r - __p);
|
||||
}
|
||||
|
||||
// __str_find_first_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_first_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
if (__pos >= __sz || __n == 0)
|
||||
return __npos;
|
||||
const _CharT* __r = _VSTD::__find_first_of_ce
|
||||
(__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq );
|
||||
if (__r == __p + __sz)
|
||||
return __npos;
|
||||
return static_cast<_SizeT>(__r - __p);
|
||||
}
|
||||
|
||||
|
||||
// __str_find_last_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_last_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
if (__n != 0)
|
||||
{
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
for (const _CharT* __ps = __p + __pos; __ps != __p;)
|
||||
{
|
||||
const _CharT* __r = _Traits::find(__s, __n, *--__ps);
|
||||
if (__r)
|
||||
return static_cast<_SizeT>(__ps - __p);
|
||||
}
|
||||
}
|
||||
return __npos;
|
||||
}
|
||||
|
||||
|
||||
// __str_find_first_not_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
if (__pos < __sz)
|
||||
{
|
||||
const _CharT* __pe = __p + __sz;
|
||||
for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
|
||||
if (_Traits::find(__s, __n, *__ps) == 0)
|
||||
return static_cast<_SizeT>(__ps - __p);
|
||||
}
|
||||
return __npos;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
if (__pos < __sz)
|
||||
{
|
||||
const _CharT* __pe = __p + __sz;
|
||||
for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
|
||||
if (!_Traits::eq(*__ps, __c))
|
||||
return static_cast<_SizeT>(__ps - __p);
|
||||
}
|
||||
return __npos;
|
||||
}
|
||||
|
||||
|
||||
// __str_find_last_not_of
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
|
||||
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
|
||||
{
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
for (const _CharT* __ps = __p + __pos; __ps != __p;)
|
||||
if (_Traits::find(__s, __n, *--__ps) == 0)
|
||||
return static_cast<_SizeT>(__ps - __p);
|
||||
return __npos;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
|
||||
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
|
||||
_CharT __c, _SizeT __pos) _NOEXCEPT
|
||||
{
|
||||
if (__pos < __sz)
|
||||
++__pos;
|
||||
else
|
||||
__pos = __sz;
|
||||
for (const _CharT* __ps = __p + __pos; __ps != __p;)
|
||||
if (!_Traits::eq(*--__ps, __c))
|
||||
return static_cast<_SizeT>(__ps - __p);
|
||||
return __npos;
|
||||
}
|
||||
|
||||
template<class _Ptr>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
size_t __do_string_hash(_Ptr __p, _Ptr __e)
|
||||
{
|
||||
typedef typename iterator_traits<_Ptr>::value_type value_type;
|
||||
return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
|
||||
}
|
||||
|
||||
template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
|
||||
struct __quoted_output_proxy
|
||||
{
|
||||
_Iter __first;
|
||||
_Iter __last;
|
||||
_CharT __delim;
|
||||
_CharT __escape;
|
||||
|
||||
__quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
|
||||
: __first(__f), __last(__l), __delim(__d), __escape(__e) {}
|
||||
// This would be a nice place for a string_ref
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___STRING
|
402
libcxx/include/__threading_support
Normal file
402
libcxx/include/__threading_support
Normal file
@ -0,0 +1,402 @@
|
||||
// -*- 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_THREADING_SUPPORT
|
||||
#define _LIBCPP_THREADING_SUPPORT
|
||||
|
||||
#include <__config>
|
||||
#include <chrono>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
|
||||
# include <__external_threading>
|
||||
#elif !defined(_LIBCPP_HAS_NO_THREADS)
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
# include <pthread.h>
|
||||
# include <sched.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_HAS_THREAD_API_WIN32)
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
|
||||
#else
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis)
|
||||
#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis))
|
||||
#else
|
||||
#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
// Mutex
|
||||
typedef pthread_mutex_t __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
|
||||
typedef pthread_mutex_t __libcpp_recursive_mutex_t;
|
||||
|
||||
// Condition Variable
|
||||
typedef pthread_cond_t __libcpp_condvar_t;
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
|
||||
|
||||
// Execute once
|
||||
typedef pthread_once_t __libcpp_exec_once_flag;
|
||||
#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
|
||||
|
||||
// Thread id
|
||||
typedef pthread_t __libcpp_thread_id;
|
||||
|
||||
// Thread
|
||||
#define _LIBCPP_NULL_THREAD 0U
|
||||
|
||||
typedef pthread_t __libcpp_thread_t;
|
||||
|
||||
// Thread Local Storage
|
||||
typedef pthread_key_t __libcpp_tls_key;
|
||||
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC
|
||||
#else
|
||||
// Mutex
|
||||
typedef void* __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER 0
|
||||
|
||||
#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
|
||||
typedef void* __libcpp_recursive_mutex_t[6];
|
||||
#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
|
||||
typedef void* __libcpp_recursive_mutex_t[5];
|
||||
#else
|
||||
# error Unsupported architecture
|
||||
#endif
|
||||
|
||||
// Condition Variable
|
||||
typedef void* __libcpp_condvar_t;
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER 0
|
||||
|
||||
// Execute Once
|
||||
typedef void* __libcpp_exec_once_flag;
|
||||
#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
|
||||
|
||||
// Thread ID
|
||||
typedef long __libcpp_thread_id;
|
||||
|
||||
// Thread
|
||||
#define _LIBCPP_NULL_THREAD 0U
|
||||
|
||||
typedef void* __libcpp_thread_t;
|
||||
|
||||
// Thread Local Storage
|
||||
typedef long __libcpp_tls_key;
|
||||
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
|
||||
#endif
|
||||
|
||||
// Mutex
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
|
||||
|
||||
// Condition variable
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
||||
timespec *__ts);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
|
||||
|
||||
// Execute once
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
|
||||
void (*init_routine)(void));
|
||||
|
||||
// Thread id
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
|
||||
|
||||
// Thread
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
||||
void *__arg);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id();
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_thread_join(__libcpp_thread_t *__t);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_thread_detach(__libcpp_thread_t *__t);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
void __libcpp_thread_yield();
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns);
|
||||
|
||||
// Thread local storage
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_tls_create(__libcpp_tls_key* __key,
|
||||
void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*));
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
void *__libcpp_tls_get(__libcpp_tls_key __key);
|
||||
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
|
||||
|
||||
#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \
|
||||
defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int __ec = pthread_mutexattr_init(&attr);
|
||||
if (__ec)
|
||||
return __ec;
|
||||
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (__ec) {
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return __ec;
|
||||
}
|
||||
__ec = pthread_mutex_init(__m, &attr);
|
||||
if (__ec) {
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return __ec;
|
||||
}
|
||||
__ec = pthread_mutexattr_destroy(&attr);
|
||||
if (__ec) {
|
||||
pthread_mutex_destroy(__m);
|
||||
return __ec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_lock(__m);
|
||||
}
|
||||
|
||||
bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_trylock(__m) == 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_unlock(__m);
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_destroy(__m);
|
||||
}
|
||||
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_lock(__m);
|
||||
}
|
||||
|
||||
bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_trylock(__m) == 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_unlock(__m);
|
||||
}
|
||||
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_mutex_destroy(__m);
|
||||
}
|
||||
|
||||
// Condition Variable
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return pthread_cond_signal(__cv);
|
||||
}
|
||||
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return pthread_cond_broadcast(__cv);
|
||||
}
|
||||
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
|
||||
{
|
||||
return pthread_cond_wait(__cv, __m);
|
||||
}
|
||||
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
||||
timespec *__ts)
|
||||
{
|
||||
return pthread_cond_timedwait(__cv, __m, __ts);
|
||||
}
|
||||
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
return pthread_cond_destroy(__cv);
|
||||
}
|
||||
|
||||
// Execute once
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
|
||||
void (*init_routine)(void)) {
|
||||
return pthread_once(flag, init_routine);
|
||||
}
|
||||
|
||||
// Thread id
|
||||
// Returns non-zero if the thread ids are equal, otherwise 0
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return pthread_equal(t1, t2) != 0;
|
||||
}
|
||||
|
||||
// Returns non-zero if t1 < t2, otherwise 0
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
|
||||
{
|
||||
return t1 < t2;
|
||||
}
|
||||
|
||||
// Thread
|
||||
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
|
||||
return *__t == 0;
|
||||
}
|
||||
|
||||
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
||||
void *__arg)
|
||||
{
|
||||
return pthread_create(__t, 0, __func, __arg);
|
||||
}
|
||||
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id()
|
||||
{
|
||||
return pthread_self();
|
||||
}
|
||||
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
|
||||
{
|
||||
return *__t;
|
||||
}
|
||||
|
||||
int __libcpp_thread_join(__libcpp_thread_t *__t)
|
||||
{
|
||||
return pthread_join(*__t, 0);
|
||||
}
|
||||
|
||||
int __libcpp_thread_detach(__libcpp_thread_t *__t)
|
||||
{
|
||||
return pthread_detach(*__t);
|
||||
}
|
||||
|
||||
void __libcpp_thread_yield()
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
||||
{
|
||||
using namespace chrono;
|
||||
seconds __s = duration_cast<seconds>(__ns);
|
||||
timespec __ts;
|
||||
typedef decltype(__ts.tv_sec) ts_sec;
|
||||
_LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits<ts_sec>::max();
|
||||
|
||||
if (__s.count() < __ts_sec_max)
|
||||
{
|
||||
__ts.tv_sec = static_cast<ts_sec>(__s.count());
|
||||
__ts.tv_nsec = static_cast<decltype(__ts.tv_nsec)>((__ns - __s).count());
|
||||
}
|
||||
else
|
||||
{
|
||||
__ts.tv_sec = __ts_sec_max;
|
||||
__ts.tv_nsec = 999999999; // (10^9 - 1)
|
||||
}
|
||||
|
||||
while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR);
|
||||
}
|
||||
|
||||
// Thread local storage
|
||||
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
|
||||
{
|
||||
return pthread_key_create(__key, __at_exit);
|
||||
}
|
||||
|
||||
void *__libcpp_tls_get(__libcpp_tls_key __key)
|
||||
{
|
||||
return pthread_getspecific(__key);
|
||||
}
|
||||
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
{
|
||||
return pthread_setspecific(__key, __p);
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_THREADING_SUPPORT
|
2879
libcxx/include/__tree
Normal file
2879
libcxx/include/__tree
Normal file
File diff suppressed because it is too large
Load Diff
556
libcxx/include/__tuple
Normal file
556
libcxx/include/__tuple
Normal file
@ -0,0 +1,556 @@
|
||||
// -*- 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___TUPLE
|
||||
#define _LIBCPP___TUPLE
|
||||
|
||||
#include <__config>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
|
||||
|
||||
#if !defined(_LIBCPP_CXX03_LANG)
|
||||
template <class _Tp, class...>
|
||||
using __enable_if_tuple_size_imp = _Tp;
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
|
||||
const _Tp,
|
||||
typename enable_if<!is_volatile<_Tp>::value>::type,
|
||||
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
|
||||
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
|
||||
volatile _Tp,
|
||||
typename enable_if<!is_const<_Tp>::value>::type,
|
||||
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
|
||||
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
|
||||
const volatile _Tp,
|
||||
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
|
||||
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
|
||||
|
||||
#else
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
|
||||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
|
||||
#endif
|
||||
|
||||
template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
|
||||
|
||||
template <size_t _Ip, class _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
|
||||
{
|
||||
public:
|
||||
typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
|
||||
{
|
||||
public:
|
||||
typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
|
||||
{
|
||||
public:
|
||||
typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
|
||||
};
|
||||
|
||||
template <class _Tp> struct __tuple_like : false_type {};
|
||||
|
||||
template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
|
||||
template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
|
||||
template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
|
||||
|
||||
// tuple specializations
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <size_t...> struct __tuple_indices {};
|
||||
|
||||
template <class _IdxType, _IdxType... _Values>
|
||||
struct __integer_sequence {
|
||||
template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
|
||||
using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
|
||||
|
||||
template <size_t _Sp>
|
||||
using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
|
||||
};
|
||||
|
||||
#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
|
||||
namespace __detail {
|
||||
|
||||
template<typename _Tp, size_t ..._Extra> struct __repeat;
|
||||
template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
|
||||
typedef __integer_sequence<_Tp,
|
||||
_Np...,
|
||||
sizeof...(_Np) + _Np...,
|
||||
2 * sizeof...(_Np) + _Np...,
|
||||
3 * sizeof...(_Np) + _Np...,
|
||||
4 * sizeof...(_Np) + _Np...,
|
||||
5 * sizeof...(_Np) + _Np...,
|
||||
6 * sizeof...(_Np) + _Np...,
|
||||
7 * sizeof...(_Np) + _Np...,
|
||||
_Extra...> type;
|
||||
};
|
||||
|
||||
template<size_t _Np> struct __parity;
|
||||
template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
|
||||
|
||||
template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
|
||||
template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
|
||||
template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
|
||||
template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
|
||||
template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
|
||||
template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
|
||||
template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
|
||||
template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
|
||||
|
||||
template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
|
||||
template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
|
||||
template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
|
||||
|
||||
#if __has_builtin(__make_integer_seq)
|
||||
template <size_t _Ep, size_t _Sp>
|
||||
using __make_indices_imp =
|
||||
typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
|
||||
__to_tuple_indices<_Sp>;
|
||||
#else
|
||||
template <size_t _Ep, size_t _Sp>
|
||||
using __make_indices_imp =
|
||||
typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
|
||||
|
||||
#endif
|
||||
|
||||
template <size_t _Ep, size_t _Sp = 0>
|
||||
struct __make_tuple_indices
|
||||
{
|
||||
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
|
||||
typedef __make_indices_imp<_Ep, _Sp> type;
|
||||
};
|
||||
|
||||
|
||||
template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
|
||||
|
||||
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
|
||||
|
||||
template <class ..._Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
|
||||
: public integral_constant<size_t, sizeof...(_Tp)>
|
||||
{
|
||||
};
|
||||
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename tuple_element<_Ip, tuple<_Tp...> >::type&
|
||||
get(tuple<_Tp...>&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
|
||||
get(const tuple<_Tp...>&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
|
||||
get(tuple<_Tp...>&&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
|
||||
get(const tuple<_Tp...>&&) _NOEXCEPT;
|
||||
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
// pair specializations
|
||||
|
||||
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
|
||||
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
|
||||
get(pair<_T1, _T2>&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
|
||||
get(const pair<_T1, _T2>&) _NOEXCEPT;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
|
||||
get(pair<_T1, _T2>&&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
|
||||
get(const pair<_T1, _T2>&&) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
// array specializations
|
||||
|
||||
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
|
||||
|
||||
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&
|
||||
get(array<_Tp, _Size>&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
get(const array<_Tp, _Size>&) _NOEXCEPT;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&&
|
||||
get(array<_Tp, _Size>&&) _NOEXCEPT;
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&&
|
||||
get(const array<_Tp, _Size>&&) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
// __tuple_types
|
||||
|
||||
template <class ..._Tp> struct __tuple_types {};
|
||||
|
||||
#if !__has_builtin(__type_pack_element)
|
||||
|
||||
namespace __indexer_detail {
|
||||
|
||||
template <size_t _Idx, class _Tp>
|
||||
struct __indexed { using type = _Tp; };
|
||||
|
||||
template <class _Types, class _Indexes> struct __indexer;
|
||||
|
||||
template <class ..._Types, size_t ..._Idx>
|
||||
struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
|
||||
: __indexed<_Idx, _Types>...
|
||||
{};
|
||||
|
||||
template <size_t _Idx, class _Tp>
|
||||
__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
|
||||
|
||||
} // namespace __indexer_detail
|
||||
|
||||
template <size_t _Idx, class ..._Types>
|
||||
using __type_pack_element = typename decltype(
|
||||
__indexer_detail::__at_index<_Idx>(
|
||||
__indexer_detail::__indexer<
|
||||
__tuple_types<_Types...>,
|
||||
typename __make_tuple_indices<sizeof...(_Types)>::type
|
||||
>{})
|
||||
)::type;
|
||||
#endif
|
||||
|
||||
template <size_t _Ip, class ..._Types>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
|
||||
{
|
||||
public:
|
||||
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
|
||||
typedef __type_pack_element<_Ip, _Types...> type;
|
||||
};
|
||||
|
||||
|
||||
template <class ..._Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
|
||||
: public integral_constant<size_t, sizeof...(_Tp)>
|
||||
{
|
||||
};
|
||||
|
||||
template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
|
||||
|
||||
template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
|
||||
struct __apply_cv_mf;
|
||||
template <>
|
||||
struct __apply_cv_mf<false, false, false> {
|
||||
template <class _Tp> using __apply = _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<false, true, false> {
|
||||
template <class _Tp> using __apply = const _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<false, false, true> {
|
||||
template <class _Tp> using __apply = volatile _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<false, true, true> {
|
||||
template <class _Tp> using __apply = const volatile _Tp;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, false, false> {
|
||||
template <class _Tp> using __apply = _Tp&;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, true, false> {
|
||||
template <class _Tp> using __apply = const _Tp&;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, false, true> {
|
||||
template <class _Tp> using __apply = volatile _Tp&;
|
||||
};
|
||||
template <>
|
||||
struct __apply_cv_mf<true, true, true> {
|
||||
template <class _Tp> using __apply = const volatile _Tp&;
|
||||
};
|
||||
template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
|
||||
using __apply_cv_t = __apply_cv_mf<
|
||||
is_lvalue_reference<_Tp>::value,
|
||||
is_const<_RawTp>::value,
|
||||
is_volatile<_RawTp>::value>;
|
||||
|
||||
// __make_tuple_types
|
||||
|
||||
// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
|
||||
// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
|
||||
// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
|
||||
// lvalue_reference type, then __tuple_types<_Types&...> is the result.
|
||||
|
||||
template <class _TupleTypes, class _TupleIndices>
|
||||
struct __make_tuple_types_flat;
|
||||
|
||||
template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
|
||||
struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
|
||||
// Specialization for pair, tuple, and __tuple_types
|
||||
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
|
||||
using __apply_quals = __tuple_types<
|
||||
typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
|
||||
>;
|
||||
};
|
||||
|
||||
template <class _Vt, size_t _Np, size_t ..._Idx>
|
||||
struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
|
||||
template <size_t>
|
||||
using __value_type = _Vt;
|
||||
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
|
||||
using __apply_quals = __tuple_types<
|
||||
typename _ApplyFn::template __apply<__value_type<_Idx>>...
|
||||
>;
|
||||
};
|
||||
|
||||
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
|
||||
size_t _Sp = 0,
|
||||
bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
|
||||
struct __make_tuple_types
|
||||
{
|
||||
static_assert(_Sp <= _Ep, "__make_tuple_types input error");
|
||||
using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
|
||||
using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
|
||||
using type = typename _Maker::template __apply_quals<_Tp>;
|
||||
};
|
||||
|
||||
template <class ..._Types, size_t _Ep>
|
||||
struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
|
||||
typedef __tuple_types<_Types...> type;
|
||||
};
|
||||
|
||||
template <class ..._Types, size_t _Ep>
|
||||
struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
|
||||
typedef __tuple_types<_Types...> type;
|
||||
};
|
||||
|
||||
template <bool ..._Preds>
|
||||
struct __all_dummy;
|
||||
|
||||
template <bool ..._Pred>
|
||||
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
|
||||
|
||||
struct __tuple_sfinae_base {
|
||||
template <template <class, class...> class _Trait,
|
||||
class ..._LArgs, class ..._RArgs>
|
||||
static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
|
||||
-> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
|
||||
template <template <class...> class>
|
||||
static auto __do_test(...) -> false_type;
|
||||
|
||||
template <class _FromArgs, class _ToArgs>
|
||||
using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
|
||||
template <class _FromArgs, class _ToArgs>
|
||||
using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
|
||||
template <class _FromArgs, class _ToArgs>
|
||||
using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
|
||||
};
|
||||
|
||||
// __tuple_convertible
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_convertible
|
||||
: public false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_convertible<_Tp, _Up, true, true>
|
||||
: public __tuple_sfinae_base::__convertible<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
// __tuple_constructible
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_constructible
|
||||
: public false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_constructible<_Tp, _Up, true, true>
|
||||
: public __tuple_sfinae_base::__constructible<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up>::type
|
||||
>
|
||||
{};
|
||||
|
||||
// __tuple_assignable
|
||||
|
||||
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
|
||||
bool = __tuple_like<_Up>::value>
|
||||
struct __tuple_assignable
|
||||
: public false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __tuple_assignable<_Tp, _Up, true, true>
|
||||
: public __tuple_sfinae_base::__assignable<
|
||||
typename __make_tuple_types<_Tp>::type
|
||||
, typename __make_tuple_types<_Up&>::type
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
|
||||
{
|
||||
public:
|
||||
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <size_t _Ip, class ..._Tp>
|
||||
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
|
||||
#endif
|
||||
|
||||
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
|
||||
struct __tuple_like_with_size_imp : false_type {};
|
||||
|
||||
template <class _SizeTrait, size_t _Expected>
|
||||
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
|
||||
: integral_constant<bool, _SizeTrait::value == _Expected> {};
|
||||
|
||||
template <class _Tuple, size_t _ExpectedSize,
|
||||
class _RawTuple = typename __uncvref<_Tuple>::type>
|
||||
using __tuple_like_with_size = __tuple_like_with_size_imp<
|
||||
__tuple_like<_RawTuple>::value,
|
||||
tuple_size<_RawTuple>, _ExpectedSize
|
||||
>;
|
||||
|
||||
struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
|
||||
template <class ...>
|
||||
static constexpr bool __enable_default() { return false; }
|
||||
template <class ...>
|
||||
static constexpr bool __enable_explicit() { return false; }
|
||||
template <class ...>
|
||||
static constexpr bool __enable_implicit() { return false; }
|
||||
template <class ...>
|
||||
static constexpr bool __enable_assign() { return false; }
|
||||
};
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
template <bool _CanCopy, bool _CanMove>
|
||||
struct __sfinae_ctor_base {};
|
||||
template <>
|
||||
struct __sfinae_ctor_base<false, false> {
|
||||
__sfinae_ctor_base() = default;
|
||||
__sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
|
||||
__sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
|
||||
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
|
||||
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
|
||||
};
|
||||
template <>
|
||||
struct __sfinae_ctor_base<true, false> {
|
||||
__sfinae_ctor_base() = default;
|
||||
__sfinae_ctor_base(__sfinae_ctor_base const&) = default;
|
||||
__sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
|
||||
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
|
||||
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
|
||||
};
|
||||
template <>
|
||||
struct __sfinae_ctor_base<false, true> {
|
||||
__sfinae_ctor_base() = default;
|
||||
__sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
|
||||
__sfinae_ctor_base(__sfinae_ctor_base &&) = default;
|
||||
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
|
||||
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
|
||||
};
|
||||
|
||||
template <bool _CanCopy, bool _CanMove>
|
||||
struct __sfinae_assign_base {};
|
||||
template <>
|
||||
struct __sfinae_assign_base<false, false> {
|
||||
__sfinae_assign_base() = default;
|
||||
__sfinae_assign_base(__sfinae_assign_base const&) = default;
|
||||
__sfinae_assign_base(__sfinae_assign_base &&) = default;
|
||||
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
|
||||
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
|
||||
};
|
||||
template <>
|
||||
struct __sfinae_assign_base<true, false> {
|
||||
__sfinae_assign_base() = default;
|
||||
__sfinae_assign_base(__sfinae_assign_base const&) = default;
|
||||
__sfinae_assign_base(__sfinae_assign_base &&) = default;
|
||||
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
|
||||
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
|
||||
};
|
||||
template <>
|
||||
struct __sfinae_assign_base<false, true> {
|
||||
__sfinae_assign_base() = default;
|
||||
__sfinae_assign_base(__sfinae_assign_base const&) = default;
|
||||
__sfinae_assign_base(__sfinae_assign_base &&) = default;
|
||||
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
|
||||
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
|
||||
};
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___TUPLE
|
34
libcxx/include/__undef_macros
Normal file
34
libcxx/include/__undef_macros
Normal file
@ -0,0 +1,34 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------ __undef_macros ------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifdef min
|
||||
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
||||
#if defined(_LIBCPP_WARNING)
|
||||
_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
|
||||
"before any Windows header. #undefing min")
|
||||
#else
|
||||
#warning: macro min is incompatible with C++. #undefing min
|
||||
#endif
|
||||
#endif
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#ifdef max
|
||||
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
||||
#if defined(_LIBCPP_WARNING)
|
||||
_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
|
||||
"before any Windows header. #undefing max")
|
||||
#else
|
||||
#warning: macro max is incompatible with C++. #undefing max
|
||||
#endif
|
||||
#endif
|
||||
#undef max
|
||||
#endif
|
5710
libcxx/include/algorithm
Normal file
5710
libcxx/include/algorithm
Normal file
File diff suppressed because it is too large
Load Diff
672
libcxx/include/any
Normal file
672
libcxx/include/any
Normal file
@ -0,0 +1,672 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------------ any -----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_ANY
|
||||
#define _LIBCPP_ANY
|
||||
|
||||
/*
|
||||
any synopsis
|
||||
|
||||
namespace std {
|
||||
|
||||
class bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const noexcept;
|
||||
};
|
||||
|
||||
class any
|
||||
{
|
||||
public:
|
||||
|
||||
// 6.3.1 any construct/destruct
|
||||
any() noexcept;
|
||||
|
||||
any(const any& other);
|
||||
any(any&& other) noexcept;
|
||||
|
||||
template <class ValueType>
|
||||
any(ValueType&& value);
|
||||
|
||||
~any();
|
||||
|
||||
// 6.3.2 any assignments
|
||||
any& operator=(const any& rhs);
|
||||
any& operator=(any&& rhs) noexcept;
|
||||
|
||||
template <class ValueType>
|
||||
any& operator=(ValueType&& rhs);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
template <class ValueType, class... Args>
|
||||
decay_t<ValueType>& emplace(Args&&... args);
|
||||
template <class ValueType, class U, class... Args>
|
||||
decay_t<ValueType>& emplace(initializer_list<U>, Args&&...);
|
||||
void reset() noexcept;
|
||||
void swap(any& rhs) noexcept;
|
||||
|
||||
// 6.3.4 any observers
|
||||
bool has_value() const noexcept;
|
||||
const type_info& type() const noexcept;
|
||||
};
|
||||
|
||||
// 6.4 Non-member functions
|
||||
void swap(any& x, any& y) noexcept;
|
||||
|
||||
template <class T, class ...Args>
|
||||
any make_any(Args&& ...args);
|
||||
template <class T, class U, class ...Args>
|
||||
any make_any(initializer_list<U>, Args&& ...args);
|
||||
|
||||
template<class ValueType>
|
||||
ValueType any_cast(const any& operand);
|
||||
template<class ValueType>
|
||||
ValueType any_cast(any& operand);
|
||||
template<class ValueType>
|
||||
ValueType any_cast(any&& operand);
|
||||
|
||||
template<class ValueType>
|
||||
const ValueType* any_cast(const any* operand) noexcept;
|
||||
template<class ValueType>
|
||||
ValueType* any_cast(any* operand) noexcept;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include <cstdlib>
|
||||
#include <version>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
void __throw_bad_any_cast()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_any_cast();
|
||||
#else
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Forward declarations
|
||||
class _LIBCPP_TEMPLATE_VIS any;
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
add_pointer_t<add_const_t<_ValueType>>
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
|
||||
|
||||
namespace __any_imp
|
||||
{
|
||||
using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
|
||||
|
||||
template <class _Tp>
|
||||
using _IsSmallObject = integral_constant<bool
|
||||
, sizeof(_Tp) <= sizeof(_Buffer)
|
||||
&& alignment_of<_Buffer>::value
|
||||
% alignment_of<_Tp>::value == 0
|
||||
&& is_nothrow_move_constructible<_Tp>::value
|
||||
>;
|
||||
|
||||
enum class _Action {
|
||||
_Destroy,
|
||||
_Copy,
|
||||
_Move,
|
||||
_Get,
|
||||
_TypeInfo
|
||||
};
|
||||
|
||||
template <class _Tp> struct _SmallHandler;
|
||||
template <class _Tp> struct _LargeHandler;
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { static constexpr int __id = 0; };
|
||||
template <class _Tp> constexpr int __unique_typeinfo<_Tp>::__id;
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr const void* __get_fallback_typeid() {
|
||||
return &__unique_typeinfo<decay_t<_Tp>>::__id;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool __compare_typeid(type_info const* __id, const void* __fallback_id)
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
if (__id && *__id == typeid(_Tp))
|
||||
return true;
|
||||
#endif
|
||||
if (!__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
using _Handler = conditional_t<
|
||||
_IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;
|
||||
|
||||
} // namespace __any_imp
|
||||
|
||||
class _LIBCPP_TEMPLATE_VIS any
|
||||
{
|
||||
public:
|
||||
// construct/destruct
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr any() _NOEXCEPT : __h(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(any const & __other) : __h(nullptr)
|
||||
{
|
||||
if (__other.__h) __other.__call(_Action::_Copy, this);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(any && __other) _NOEXCEPT : __h(nullptr)
|
||||
{
|
||||
if (__other.__h) __other.__call(_Action::_Move, this);
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class _Tp = decay_t<_ValueType>
|
||||
, class = enable_if_t<
|
||||
!is_same<_Tp, any>::value &&
|
||||
!__is_inplace_type<_ValueType>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(_ValueType && __value);
|
||||
|
||||
template <class _ValueType, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value
|
||||
>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit any(in_place_type_t<_ValueType>, _Args&&... __args);
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~any() { this->reset(); }
|
||||
|
||||
// assignments
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any const & __rhs) {
|
||||
any(__rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any && __rhs) _NOEXCEPT {
|
||||
any(_VSTD::move(__rhs)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class _Tp = decay_t<_ValueType>
|
||||
, class = enable_if_t<
|
||||
!is_same<_Tp, any>::value
|
||||
&& is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(_ValueType && __rhs);
|
||||
|
||||
template <class _ValueType, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& emplace(_Args&&... args);
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args,
|
||||
class _Tp = decay_t<_ValueType>,
|
||||
class = enable_if_t<
|
||||
is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
|
||||
is_copy_constructible<_Tp>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& emplace(initializer_list<_Up>, _Args&&...);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __rhs) _NOEXCEPT;
|
||||
|
||||
// 6.3.4 any observers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool has_value() const _NOEXCEPT { return __h != nullptr; }
|
||||
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const type_info & type() const _NOEXCEPT {
|
||||
if (__h) {
|
||||
return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
|
||||
} else {
|
||||
return typeid(void);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef __any_imp::_Action _Action;
|
||||
using _HandleFuncPtr = void* (*)(_Action, any const *, any *, const type_info *,
|
||||
const void* __fallback_info);
|
||||
|
||||
union _Storage {
|
||||
constexpr _Storage() : __ptr(nullptr) {}
|
||||
void * __ptr;
|
||||
__any_imp::_Buffer __buf;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr,
|
||||
const void* __fallback_info = nullptr) const
|
||||
{
|
||||
return __h(__a, this, __other, __info, __fallback_info);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void * __call(_Action __a, any * __other = nullptr,
|
||||
type_info const * __info = nullptr,
|
||||
const void* __fallback_info = nullptr)
|
||||
{
|
||||
return __h(__a, this, __other, __info, __fallback_info);
|
||||
}
|
||||
|
||||
template <class>
|
||||
friend struct __any_imp::_SmallHandler;
|
||||
template <class>
|
||||
friend struct __any_imp::_LargeHandler;
|
||||
|
||||
template <class _ValueType>
|
||||
friend add_pointer_t<add_const_t<_ValueType>>
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
friend add_pointer_t<_ValueType>
|
||||
any_cast(any *) _NOEXCEPT;
|
||||
|
||||
_HandleFuncPtr __h = nullptr;
|
||||
_Storage __s;
|
||||
};
|
||||
|
||||
namespace __any_imp
|
||||
{
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS _SmallHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this, any * __other,
|
||||
type_info const * __info, const void* __fallback_info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<any &>(*__this));
|
||||
return nullptr;
|
||||
case _Action::_Copy:
|
||||
__copy(*__this, *__other);
|
||||
return nullptr;
|
||||
case _Action::_Move:
|
||||
__move(const_cast<any &>(*__this), *__other);
|
||||
return nullptr;
|
||||
case _Action::_Get:
|
||||
return __get(const_cast<any &>(*__this), __info, __fallback_info);
|
||||
case _Action::_TypeInfo:
|
||||
return __type_info();
|
||||
}
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _Tp& __create(any & __dest, _Args&&... __args) {
|
||||
_Tp* __ret = ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
|
||||
__dest.__h = &_SmallHandler::__handle;
|
||||
return *__ret;
|
||||
}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(any & __this) {
|
||||
_Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
|
||||
__value.~_Tp();
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __copy(any const & __this, any & __dest) {
|
||||
_SmallHandler::__create(__dest, *static_cast<_Tp const *>(
|
||||
static_cast<void const *>(&__this.__s.__buf)));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __move(any & __this, any & __dest) {
|
||||
_SmallHandler::__create(__dest, _VSTD::move(
|
||||
*static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
|
||||
__destroy(__this);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __get(any & __this,
|
||||
type_info const * __info,
|
||||
const void* __fallback_id)
|
||||
{
|
||||
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
|
||||
return static_cast<void*>(&__this.__s.__buf);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __type_info()
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS _LargeHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this,
|
||||
any * __other, type_info const * __info,
|
||||
void const* __fallback_info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<any &>(*__this));
|
||||
return nullptr;
|
||||
case _Action::_Copy:
|
||||
__copy(*__this, *__other);
|
||||
return nullptr;
|
||||
case _Action::_Move:
|
||||
__move(const_cast<any &>(*__this), *__other);
|
||||
return nullptr;
|
||||
case _Action::_Get:
|
||||
return __get(const_cast<any &>(*__this), __info, __fallback_info);
|
||||
case _Action::_TypeInfo:
|
||||
return __type_info();
|
||||
}
|
||||
}
|
||||
|
||||
template <class ..._Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static _Tp& __create(any & __dest, _Args&&... __args) {
|
||||
typedef allocator<_Tp> _Alloc;
|
||||
typedef __allocator_destructor<_Alloc> _Dp;
|
||||
_Alloc __a;
|
||||
unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
|
||||
_Tp* __ret = ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
|
||||
__dest.__s.__ptr = __hold.release();
|
||||
__dest.__h = &_LargeHandler::__handle;
|
||||
return *__ret;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(any & __this){
|
||||
delete static_cast<_Tp*>(__this.__s.__ptr);
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __copy(any const & __this, any & __dest) {
|
||||
_LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __move(any & __this, any & __dest) {
|
||||
__dest.__s.__ptr = __this.__s.__ptr;
|
||||
__dest.__h = &_LargeHandler::__handle;
|
||||
__this.__h = nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __get(any & __this, type_info const * __info,
|
||||
void const* __fallback_info)
|
||||
{
|
||||
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
|
||||
return static_cast<void*>(__this.__s.__ptr);
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __type_info()
|
||||
{
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace __any_imp
|
||||
|
||||
|
||||
template <class _ValueType, class _Tp, class>
|
||||
any::any(_ValueType && __v) : __h(nullptr)
|
||||
{
|
||||
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
|
||||
}
|
||||
|
||||
template <class _ValueType, class ..._Args, class _Tp, class>
|
||||
any::any(in_place_type_t<_ValueType>, _Args&&... __args) {
|
||||
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
|
||||
};
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
|
||||
any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) {
|
||||
__any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType, class, class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
any & any::operator=(_ValueType && __v)
|
||||
{
|
||||
any(_VSTD::forward<_ValueType>(__v)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _ValueType, class ..._Args, class _Tp, class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& any::emplace(_Args&&... __args) {
|
||||
reset();
|
||||
return __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
|
||||
reset();
|
||||
return __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void any::swap(any & __rhs) _NOEXCEPT
|
||||
{
|
||||
if (this == &__rhs)
|
||||
return;
|
||||
if (__h && __rhs.__h) {
|
||||
any __tmp;
|
||||
__rhs.__call(_Action::_Move, &__tmp);
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
__tmp.__call(_Action::_Move, this);
|
||||
}
|
||||
else if (__h) {
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
}
|
||||
else if (__rhs.__h) {
|
||||
__rhs.__call(_Action::_Move, this);
|
||||
}
|
||||
}
|
||||
|
||||
// 6.4 Non-member functions
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __lhs, any & __rhs) _NOEXCEPT
|
||||
{
|
||||
__lhs.swap(__rhs);
|
||||
}
|
||||
|
||||
template <class _Tp, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
any make_any(_Args&&... __args) {
|
||||
return any(in_place_type<_Tp>, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up, class ..._Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
any make_any(initializer_list<_Up> __il, _Args&&... __args) {
|
||||
return any(in_place_type<_Tp>, __il, _VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any const & __v)
|
||||
{
|
||||
using _RawValueType = __uncvref_t<_ValueType>;
|
||||
static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
|
||||
"ValueType is required to be a const lvalue reference "
|
||||
"or a CopyConstructible type");
|
||||
auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return static_cast<_ValueType>(*__tmp);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any & __v)
|
||||
{
|
||||
using _RawValueType = __uncvref_t<_ValueType>;
|
||||
static_assert(is_constructible<_ValueType, _RawValueType &>::value,
|
||||
"ValueType is required to be an lvalue reference "
|
||||
"or a CopyConstructible type");
|
||||
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return static_cast<_ValueType>(*__tmp);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
_ValueType any_cast(any && __v)
|
||||
{
|
||||
using _RawValueType = __uncvref_t<_ValueType>;
|
||||
static_assert(is_constructible<_ValueType, _RawValueType>::value,
|
||||
"ValueType is required to be an rvalue reference "
|
||||
"or a CopyConstructible type");
|
||||
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
|
||||
if (__tmp == nullptr)
|
||||
__throw_bad_any_cast();
|
||||
return static_cast<_ValueType>(_VSTD::move(*__tmp));
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
add_pointer_t<add_const_t<_ValueType>>
|
||||
any_cast(any const * __any) _NOEXCEPT
|
||||
{
|
||||
static_assert(!is_reference<_ValueType>::value,
|
||||
"_ValueType may not be a reference.");
|
||||
return _VSTD::any_cast<_ValueType>(const_cast<any *>(__any));
|
||||
}
|
||||
|
||||
template <class _RetType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_RetType __pointer_or_func_cast(void* __p, /*IsFunction*/false_type) noexcept {
|
||||
return static_cast<_RetType>(__p);
|
||||
}
|
||||
|
||||
template <class _RetType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
add_pointer_t<_ValueType>
|
||||
any_cast(any * __any) _NOEXCEPT
|
||||
{
|
||||
using __any_imp::_Action;
|
||||
static_assert(!is_reference<_ValueType>::value,
|
||||
"_ValueType may not be a reference.");
|
||||
typedef typename add_pointer<_ValueType>::type _ReturnType;
|
||||
if (__any && __any->__h) {
|
||||
void *__p = __any->__call(_Action::_Get, nullptr,
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
&typeid(_ValueType),
|
||||
#else
|
||||
nullptr,
|
||||
#endif
|
||||
__any_imp::__get_fallback_typeid<_ValueType>());
|
||||
return _VSTD::__pointer_or_func_cast<_ReturnType>(
|
||||
__p, is_function<_ValueType>{});
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ANY
|
486
libcxx/include/array
Normal file
486
libcxx/include/array
Normal file
@ -0,0 +1,486 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- array -----------------------------------===//
|
||||
//
|
||||
// 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_ARRAY
|
||||
#define _LIBCPP_ARRAY
|
||||
|
||||
/*
|
||||
array synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <class T, size_t N >
|
||||
struct array
|
||||
{
|
||||
// types:
|
||||
typedef T & reference;
|
||||
typedef const T & const_reference;
|
||||
typedef implementation defined iterator;
|
||||
typedef implementation defined const_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
void fill(const T& u);
|
||||
void swap(array& a) noexcept(is_nothrow_swappable_v<T>);
|
||||
|
||||
// iterators:
|
||||
iterator begin() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
|
||||
reverse_iterator rbegin() noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
reverse_iterator rend() noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
// capacity:
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type max_size() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// element access:
|
||||
reference operator[](size_type n);
|
||||
const_reference operator[](size_type n) const; // constexpr in C++14
|
||||
const_reference at(size_type n) const; // constexpr in C++14
|
||||
reference at(size_type n);
|
||||
|
||||
reference front();
|
||||
const_reference front() const; // constexpr in C++14
|
||||
reference back();
|
||||
const_reference back() const; // constexpr in C++14
|
||||
|
||||
T* data() noexcept;
|
||||
const T* data() const noexcept;
|
||||
};
|
||||
|
||||
template <class T, class... U>
|
||||
array(T, U...) -> array<T, 1 + sizeof...(U)>;
|
||||
|
||||
template <class T, size_t N>
|
||||
bool operator==(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator!=(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator<(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator>(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator<=(const array<T,N>& x, const array<T,N>& y);
|
||||
template <class T, size_t N>
|
||||
bool operator>=(const array<T,N>& x, const array<T,N>& y);
|
||||
|
||||
template <class T, size_t N >
|
||||
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
|
||||
|
||||
template <class T> struct tuple_size;
|
||||
template <size_t I, class T> class tuple_element;
|
||||
template <class T, size_t N> struct tuple_size<array<T, N>>;
|
||||
template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
|
||||
template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
|
||||
template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
|
||||
template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
|
||||
template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <__tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for _LIBCPP_UNREACHABLE
|
||||
#include <version>
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS array
|
||||
{
|
||||
// types:
|
||||
typedef array __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;
|
||||
|
||||
_Tp __elems_[_Size];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
|
||||
_VSTD::fill_n(__elems_, _Size, __u);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
|
||||
std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator end() _NOEXCEPT {return iterator(data() + _Size);}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator cbegin() const _NOEXCEPT {return begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator cend() const _NOEXCEPT {return end();}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
// capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reference operator[](size_type __n) {return __elems_[__n];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const_reference operator[](size_type __n) const {return __elems_[__n];}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n);
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size - 1];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size - 1];}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
value_type* data() _NOEXCEPT {return __elems_;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const value_type* data() const _NOEXCEPT {return __elems_;}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
typename array<_Tp, _Size>::reference
|
||||
array<_Tp, _Size>::at(size_type __n)
|
||||
{
|
||||
if (__n >= _Size)
|
||||
__throw_out_of_range("array::at");
|
||||
|
||||
return __elems_[__n];
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
typename array<_Tp, _Size>::const_reference
|
||||
array<_Tp, _Size>::at(size_type __n) const
|
||||
{
|
||||
if (__n >= _Size)
|
||||
__throw_out_of_range("array::at");
|
||||
return __elems_[__n];
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
|
||||
{
|
||||
// types:
|
||||
typedef array __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;
|
||||
|
||||
typedef typename conditional<is_const<_Tp>::value, const char,
|
||||
char>::type _CharType;
|
||||
|
||||
struct _ArrayInStructT { _Tp __data_[1]; };
|
||||
_ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot fill zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array&) _NOEXCEPT {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot swap zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT {return begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT {return end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
// capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator[](size_type) {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const_reference operator[](size_type) const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference at(size_type) {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type) const {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference front() {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference back() {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}
|
||||
};
|
||||
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _Tp, class... _Args,
|
||||
class = typename enable_if<(is_same_v<_Tp, _Args> && ...), void>::type
|
||||
>
|
||||
array(_Tp, _Args...)
|
||||
-> array<_Tp, 1 + sizeof...(_Args)>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
|
||||
operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
_Size == 0 ||
|
||||
__is_swappable<_Tp>::value,
|
||||
void
|
||||
>::type
|
||||
swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
|
||||
_NOEXCEPT_(noexcept(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
|
||||
: public integral_constant<size_t, _Size> {};
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
|
||||
public:
|
||||
typedef _Tp type;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&
|
||||
get(array<_Tp, _Size>& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
|
||||
return __a.__elems_[_Ip];
|
||||
}
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&
|
||||
get(const array<_Tp, _Size>& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
|
||||
return __a.__elems_[_Ip];
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
_Tp&&
|
||||
get(array<_Tp, _Size>&& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
|
||||
return _VSTD::move(__a.__elems_[_Ip]);
|
||||
}
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const _Tp&&
|
||||
get(const array<_Tp, _Size>&& __a) _NOEXCEPT
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
|
||||
return _VSTD::move(__a.__elems_[_Ip]);
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_ARRAY
|
1888
libcxx/include/atomic
Normal file
1888
libcxx/include/atomic
Normal file
File diff suppressed because it is too large
Load Diff
158
libcxx/include/bit
Normal file
158
libcxx/include/bit
Normal file
@ -0,0 +1,158 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------------ bit ----------------------------------===//
|
||||
//
|
||||
// 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_BIT
|
||||
#define _LIBCPP_BIT
|
||||
|
||||
/*
|
||||
bit synopsis
|
||||
|
||||
namespace std {
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <version>
|
||||
|
||||
#if defined(__IBMCPP__)
|
||||
#include "support/ibm/support.h"
|
||||
#endif
|
||||
#if defined(_LIBCPP_COMPILER_MSVC)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_COMPILER_MSVC
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __ctz(unsigned __x) { return __builtin_ctz(__x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __ctz(unsigned long __x) { return __builtin_ctzl(__x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __ctz(unsigned long long __x) { return __builtin_ctzll(__x); }
|
||||
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __clz(unsigned __x) { return __builtin_clz(__x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __clz(unsigned long __x) { return __builtin_clzl(__x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __clz(unsigned long long __x) { return __builtin_clzll(__x); }
|
||||
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __popcount(unsigned __x) { return __builtin_popcount(__x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __popcount(unsigned long __x) { return __builtin_popcountl(__x); }
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __popcount(unsigned long long __x) { return __builtin_popcountll(__x); }
|
||||
|
||||
#else // _LIBCPP_COMPILER_MSVC
|
||||
|
||||
// Precondition: __x != 0
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __ctz(unsigned __x) {
|
||||
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
|
||||
static_assert(sizeof(unsigned long) == 4, "");
|
||||
unsigned long __where;
|
||||
if (_BitScanForward(&__where, __x))
|
||||
return static_cast<int>(__where);
|
||||
return 32;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __ctz(unsigned long __x) {
|
||||
static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
|
||||
return __ctz(static_cast<unsigned>(__x));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __ctz(unsigned long long __x) {
|
||||
unsigned long __where;
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
(defined(_M_AMD64) || defined(__x86_64__))
|
||||
if (_BitScanForward64(&__where, __x))
|
||||
return static_cast<int>(__where);
|
||||
#else
|
||||
// Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
|
||||
if (_BitScanForward(&__where, static_cast<unsigned long>(__x)))
|
||||
return static_cast<int>(__where);
|
||||
if (_BitScanForward(&__where, static_cast<unsigned long>(__x >> 32)))
|
||||
return static_cast<int>(__where + 32);
|
||||
#endif
|
||||
return 64;
|
||||
}
|
||||
|
||||
// Precondition: __x != 0
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __clz(unsigned __x) {
|
||||
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
|
||||
static_assert(sizeof(unsigned long) == 4, "");
|
||||
unsigned long __where;
|
||||
if (_BitScanReverse(&__where, __x))
|
||||
return static_cast<int>(31 - __where);
|
||||
return 32; // Undefined Behavior.
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __clz(unsigned long __x) {
|
||||
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
|
||||
return __clz(static_cast<unsigned>(__x));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
int __clz(unsigned long long __x) {
|
||||
unsigned long __where;
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
if (_BitScanReverse64(&__where, __x))
|
||||
return static_cast<int>(63 - __where);
|
||||
#else
|
||||
// Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls.
|
||||
if (_BitScanReverse(&__where, static_cast<unsigned long>(__x >> 32)))
|
||||
return static_cast<int>(63 - (__where + 32));
|
||||
if (_BitScanReverse(&__where, static_cast<unsigned long>(__x)))
|
||||
return static_cast<int>(63 - __where);
|
||||
#endif
|
||||
return 64; // Undefined Behavior.
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __popcount(unsigned __x) {
|
||||
static_assert(sizeof(unsigned) == 4, "");
|
||||
return __popcnt(__x);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __popcount(unsigned long __x) {
|
||||
static_assert(sizeof(unsigned long) == 4, "");
|
||||
return __popcnt(__x);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY int __popcount(unsigned long long __x) {
|
||||
static_assert(sizeof(unsigned long long) == 8, "");
|
||||
return __popcnt64(__x);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_COMPILER_MSVC
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_BIT
|
1110
libcxx/include/bitset
Normal file
1110
libcxx/include/bitset
Normal file
File diff suppressed because it is too large
Load Diff
25
libcxx/include/cassert
Normal file
25
libcxx/include/cassert
Normal file
@ -0,0 +1,25 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- cassert -----------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/*
|
||||
cassert synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
assert
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <assert.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
29
libcxx/include/ccomplex
Normal file
29
libcxx/include/ccomplex
Normal file
@ -0,0 +1,29 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- ccomplex ---------------------------------===//
|
||||
//
|
||||
// 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_CCOMPLEX
|
||||
#define _LIBCPP_CCOMPLEX
|
||||
|
||||
/*
|
||||
ccomplex synopsis
|
||||
|
||||
#include <complex>
|
||||
|
||||
*/
|
||||
|
||||
#include <complex>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
// hh 080623 Created
|
||||
|
||||
#endif // _LIBCPP_CCOMPLEX
|
121
libcxx/include/cctype
Normal file
121
libcxx/include/cctype
Normal file
@ -0,0 +1,121 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- cctype ----------------------------------===//
|
||||
//
|
||||
// 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_CCTYPE
|
||||
#define _LIBCPP_CCTYPE
|
||||
|
||||
/*
|
||||
cctype synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
int isalnum(int c);
|
||||
int isalpha(int c);
|
||||
int isblank(int c); // C99
|
||||
int iscntrl(int c);
|
||||
int isdigit(int c);
|
||||
int isgraph(int c);
|
||||
int islower(int c);
|
||||
int isprint(int c);
|
||||
int ispunct(int c);
|
||||
int isspace(int c);
|
||||
int isupper(int c);
|
||||
int isxdigit(int c);
|
||||
int tolower(int c);
|
||||
int toupper(int c);
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <ctype.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifdef isalnum
|
||||
#undef isalnum
|
||||
#endif
|
||||
|
||||
#ifdef isalpha
|
||||
#undef isalpha
|
||||
#endif
|
||||
|
||||
#ifdef isblank
|
||||
#undef isblank
|
||||
#endif
|
||||
|
||||
#ifdef iscntrl
|
||||
#undef iscntrl
|
||||
#endif
|
||||
|
||||
#ifdef isdigit
|
||||
#undef isdigit
|
||||
#endif
|
||||
|
||||
#ifdef isgraph
|
||||
#undef isgraph
|
||||
#endif
|
||||
|
||||
#ifdef islower
|
||||
#undef islower
|
||||
#endif
|
||||
|
||||
#ifdef isprint
|
||||
#undef isprint
|
||||
#endif
|
||||
|
||||
#ifdef ispunct
|
||||
#undef ispunct
|
||||
#endif
|
||||
|
||||
#ifdef isspace
|
||||
#undef isspace
|
||||
#endif
|
||||
|
||||
#ifdef isupper
|
||||
#undef isupper
|
||||
#endif
|
||||
|
||||
#ifdef isxdigit
|
||||
#undef isxdigit
|
||||
#endif
|
||||
|
||||
#ifdef tolower
|
||||
#undef tolower
|
||||
#endif
|
||||
|
||||
#ifdef toupper
|
||||
#undef toupper
|
||||
#endif
|
||||
|
||||
|
||||
using ::isalnum;
|
||||
using ::isalpha;
|
||||
using ::isblank;
|
||||
using ::iscntrl;
|
||||
using ::isdigit;
|
||||
using ::isgraph;
|
||||
using ::islower;
|
||||
using ::isprint;
|
||||
using ::ispunct;
|
||||
using ::isspace;
|
||||
using ::isupper;
|
||||
using ::isxdigit;
|
||||
using ::tolower;
|
||||
using ::toupper;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CCTYPE
|
33
libcxx/include/cerrno
Normal file
33
libcxx/include/cerrno
Normal file
@ -0,0 +1,33 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- cerrno ------------------------------------===//
|
||||
//
|
||||
// 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_CERRNO
|
||||
#define _LIBCPP_CERRNO
|
||||
|
||||
/*
|
||||
cerrno synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
EDOM
|
||||
EILSEQ // C99
|
||||
ERANGE
|
||||
errno
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CERRNO
|
82
libcxx/include/cfenv
Normal file
82
libcxx/include/cfenv
Normal file
@ -0,0 +1,82 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- cfenv -----------------------------------===//
|
||||
//
|
||||
// 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_CFENV
|
||||
#define _LIBCPP_CFENV
|
||||
|
||||
/*
|
||||
cfenv synopsis
|
||||
|
||||
This entire header is C99 / C++0X
|
||||
|
||||
Macros:
|
||||
|
||||
FE_DIVBYZERO
|
||||
FE_INEXACT
|
||||
FE_INVALID
|
||||
FE_OVERFLOW
|
||||
FE_UNDERFLOW
|
||||
FE_ALL_EXCEPT
|
||||
FE_DOWNWARD
|
||||
FE_TONEAREST
|
||||
FE_TOWARDZERO
|
||||
FE_UPWARD
|
||||
FE_DFL_ENV
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
fenv_t
|
||||
fexcept_t
|
||||
|
||||
int feclearexcept(int excepts);
|
||||
int fegetexceptflag(fexcept_t* flagp, int excepts);
|
||||
int feraiseexcept(int excepts);
|
||||
int fesetexceptflag(const fexcept_t* flagp, int excepts);
|
||||
int fetestexcept(int excepts);
|
||||
int fegetround();
|
||||
int fesetround(int round);
|
||||
int fegetenv(fenv_t* envp);
|
||||
int feholdexcept(fenv_t* envp);
|
||||
int fesetenv(const fenv_t* envp);
|
||||
int feupdateenv(const fenv_t* envp);
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <fenv.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::fenv_t;
|
||||
using ::fexcept_t;
|
||||
|
||||
using ::feclearexcept;
|
||||
using ::fegetexceptflag;
|
||||
using ::feraiseexcept;
|
||||
using ::fesetexceptflag;
|
||||
using ::fetestexcept;
|
||||
using ::fegetround;
|
||||
using ::fesetround;
|
||||
using ::fegetenv;
|
||||
using ::feholdexcept;
|
||||
using ::fesetenv;
|
||||
using ::feupdateenv;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CFENV
|
80
libcxx/include/cfloat
Normal file
80
libcxx/include/cfloat
Normal file
@ -0,0 +1,80 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cfloat -----------------------------------===//
|
||||
//
|
||||
// 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_CFLOAT
|
||||
#define _LIBCPP_CFLOAT
|
||||
|
||||
/*
|
||||
cfloat synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
FLT_ROUNDS
|
||||
FLT_EVAL_METHOD // C99
|
||||
FLT_RADIX
|
||||
|
||||
FLT_HAS_SUBNORM // C11
|
||||
DBL_HAS_SUBNORM // C11
|
||||
LDBL_HAS_SUBNORM // C11
|
||||
|
||||
FLT_MANT_DIG
|
||||
DBL_MANT_DIG
|
||||
LDBL_MANT_DIG
|
||||
|
||||
DECIMAL_DIG // C99
|
||||
FLT_DECIMAL_DIG // C11
|
||||
DBL_DECIMAL_DIG // C11
|
||||
LDBL_DECIMAL_DIG // C11
|
||||
|
||||
FLT_DIG
|
||||
DBL_DIG
|
||||
LDBL_DIG
|
||||
|
||||
FLT_MIN_EXP
|
||||
DBL_MIN_EXP
|
||||
LDBL_MIN_EXP
|
||||
|
||||
FLT_MIN_10_EXP
|
||||
DBL_MIN_10_EXP
|
||||
LDBL_MIN_10_EXP
|
||||
|
||||
FLT_MAX_EXP
|
||||
DBL_MAX_EXP
|
||||
LDBL_MAX_EXP
|
||||
|
||||
FLT_MAX_10_EXP
|
||||
DBL_MAX_10_EXP
|
||||
LDBL_MAX_10_EXP
|
||||
|
||||
FLT_MAX
|
||||
DBL_MAX
|
||||
LDBL_MAX
|
||||
|
||||
FLT_EPSILON
|
||||
DBL_EPSILON
|
||||
LDBL_EPSILON
|
||||
|
||||
FLT_MIN
|
||||
DBL_MIN
|
||||
LDBL_MIN
|
||||
|
||||
FLT_TRUE_MIN // C11
|
||||
DBL_TRUE_MIN // C11
|
||||
LDBL_TRUE_MIN // C11
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <float.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CFLOAT
|
617
libcxx/include/charconv
Normal file
617
libcxx/include/charconv
Normal file
@ -0,0 +1,617 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------------ charconv ------------------------------===//
|
||||
//
|
||||
// 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_CHARCONV
|
||||
#define _LIBCPP_CHARCONV
|
||||
|
||||
/*
|
||||
charconv synopsis
|
||||
|
||||
namespace std {
|
||||
|
||||
// floating-point format for primitive numerical conversion
|
||||
enum class chars_format {
|
||||
scientific = unspecified,
|
||||
fixed = unspecified,
|
||||
hex = unspecified,
|
||||
general = fixed | scientific
|
||||
};
|
||||
|
||||
// 23.20.2, primitive numerical output conversion
|
||||
struct to_chars_result {
|
||||
char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
to_chars_result to_chars(char* first, char* last, see below value,
|
||||
int base = 10);
|
||||
|
||||
to_chars_result to_chars(char* first, char* last, float value);
|
||||
to_chars_result to_chars(char* first, char* last, double value);
|
||||
to_chars_result to_chars(char* first, char* last, long double value);
|
||||
|
||||
to_chars_result to_chars(char* first, char* last, float value,
|
||||
chars_format fmt);
|
||||
to_chars_result to_chars(char* first, char* last, double value,
|
||||
chars_format fmt);
|
||||
to_chars_result to_chars(char* first, char* last, long double value,
|
||||
chars_format fmt);
|
||||
|
||||
to_chars_result to_chars(char* first, char* last, float value,
|
||||
chars_format fmt, int precision);
|
||||
to_chars_result to_chars(char* first, char* last, double value,
|
||||
chars_format fmt, int precision);
|
||||
to_chars_result to_chars(char* first, char* last, long double value,
|
||||
chars_format fmt, int precision);
|
||||
|
||||
// 23.20.3, primitive numerical input conversion
|
||||
struct from_chars_result {
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
from_chars_result from_chars(const char* first, const char* last,
|
||||
see below& value, int base = 10);
|
||||
|
||||
from_chars_result from_chars(const char* first, const char* last,
|
||||
float& value,
|
||||
chars_format fmt = chars_format::general);
|
||||
from_chars_result from_chars(const char* first, const char* last,
|
||||
double& value,
|
||||
chars_format fmt = chars_format::general);
|
||||
from_chars_result from_chars(const char* first, const char* last,
|
||||
long double& value,
|
||||
chars_format fmt = chars_format::general);
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <__errc>
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
namespace __itoa {
|
||||
_LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer);
|
||||
_LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS chars_format
|
||||
{
|
||||
scientific = 0x1,
|
||||
fixed = 0x2,
|
||||
hex = 0x4,
|
||||
general = fixed | scientific
|
||||
};
|
||||
|
||||
struct _LIBCPP_TYPE_VIS to_chars_result
|
||||
{
|
||||
char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
struct _LIBCPP_TYPE_VIS from_chars_result
|
||||
{
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
};
|
||||
|
||||
void to_chars(char*, char*, bool, int = 10) = delete;
|
||||
void from_chars(const char*, const char*, bool, int = 10) = delete;
|
||||
|
||||
namespace __itoa
|
||||
{
|
||||
|
||||
static constexpr uint64_t __pow10_64[] = {
|
||||
UINT64_C(0),
|
||||
UINT64_C(10),
|
||||
UINT64_C(100),
|
||||
UINT64_C(1000),
|
||||
UINT64_C(10000),
|
||||
UINT64_C(100000),
|
||||
UINT64_C(1000000),
|
||||
UINT64_C(10000000),
|
||||
UINT64_C(100000000),
|
||||
UINT64_C(1000000000),
|
||||
UINT64_C(10000000000),
|
||||
UINT64_C(100000000000),
|
||||
UINT64_C(1000000000000),
|
||||
UINT64_C(10000000000000),
|
||||
UINT64_C(100000000000000),
|
||||
UINT64_C(1000000000000000),
|
||||
UINT64_C(10000000000000000),
|
||||
UINT64_C(100000000000000000),
|
||||
UINT64_C(1000000000000000000),
|
||||
UINT64_C(10000000000000000000),
|
||||
};
|
||||
|
||||
static constexpr uint32_t __pow10_32[] = {
|
||||
UINT32_C(0), UINT32_C(10), UINT32_C(100),
|
||||
UINT32_C(1000), UINT32_C(10000), UINT32_C(100000),
|
||||
UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000),
|
||||
UINT32_C(1000000000),
|
||||
};
|
||||
|
||||
template <typename _Tp, typename = void>
|
||||
struct _LIBCPP_HIDDEN __traits_base
|
||||
{
|
||||
using type = uint64_t;
|
||||
|
||||
#if !defined(_LIBCPP_COMPILER_MSVC)
|
||||
static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
|
||||
{
|
||||
auto __t = (64 - __builtin_clzll(__v | 1)) * 1233 >> 12;
|
||||
return __t - (__v < __pow10_64[__t]) + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
|
||||
{
|
||||
return __u64toa(__v, __p);
|
||||
}
|
||||
|
||||
static _LIBCPP_INLINE_VISIBILITY auto& __pow() { return __pow10_64; }
|
||||
};
|
||||
|
||||
template <typename _Tp>
|
||||
struct _LIBCPP_HIDDEN
|
||||
__traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))>
|
||||
{
|
||||
using type = uint32_t;
|
||||
|
||||
#if !defined(_LIBCPP_COMPILER_MSVC)
|
||||
static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)
|
||||
{
|
||||
auto __t = (32 - __builtin_clz(__v | 1)) * 1233 >> 12;
|
||||
return __t - (__v < __pow10_32[__t]) + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p)
|
||||
{
|
||||
return __u32toa(__v, __p);
|
||||
}
|
||||
|
||||
static _LIBCPP_INLINE_VISIBILITY auto& __pow() { return __pow10_32; }
|
||||
};
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY bool
|
||||
__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
|
||||
{
|
||||
auto __c = __a * __b;
|
||||
__r = __c;
|
||||
return __c > (numeric_limits<unsigned char>::max)();
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY bool
|
||||
__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
|
||||
{
|
||||
auto __c = __a * __b;
|
||||
__r = __c;
|
||||
return __c > (numeric_limits<unsigned short>::max)();
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY bool
|
||||
__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
|
||||
{
|
||||
static_assert(is_unsigned<_Tp>::value, "");
|
||||
#if !defined(_LIBCPP_COMPILER_MSVC)
|
||||
return __builtin_mul_overflow(__a, __b, &__r);
|
||||
#else
|
||||
bool __did = __b && ((numeric_limits<_Tp>::max)() / __b) < __a;
|
||||
__r = __a * __b;
|
||||
return __did;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename _Tp, typename _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY bool
|
||||
__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
|
||||
{
|
||||
return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
|
||||
{
|
||||
static constexpr int digits = numeric_limits<_Tp>::digits10 + 1;
|
||||
using __traits_base<_Tp>::__pow;
|
||||
using typename __traits_base<_Tp>::type;
|
||||
|
||||
// precondition: at least one non-zero character available
|
||||
static _LIBCPP_INLINE_VISIBILITY char const*
|
||||
__read(char const* __p, char const* __ep, type& __a, type& __b)
|
||||
{
|
||||
type __cprod[digits];
|
||||
int __j = digits - 1;
|
||||
int __i = digits;
|
||||
do
|
||||
{
|
||||
if (!('0' <= *__p && *__p <= '9'))
|
||||
break;
|
||||
__cprod[--__i] = *__p++ - '0';
|
||||
} while (__p != __ep && __i != 0);
|
||||
|
||||
__a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,
|
||||
__cprod[__i]);
|
||||
if (__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
|
||||
--__p;
|
||||
return __p;
|
||||
}
|
||||
|
||||
template <typename _It1, typename _It2, class _Up>
|
||||
static _LIBCPP_INLINE_VISIBILITY _Up
|
||||
__inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
|
||||
{
|
||||
for (; __first1 < __last1; ++__first1, ++__first2)
|
||||
__init = __init + *__first1 * *__first2;
|
||||
return __init;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace __itoa
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _Tp
|
||||
__complement(_Tp __x)
|
||||
{
|
||||
static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
|
||||
return _Tp(~__x + 1);
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY auto
|
||||
__to_unsigned(_Tp __x)
|
||||
{
|
||||
return static_cast<make_unsigned_t<_Tp>>(__x);
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
|
||||
__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
|
||||
{
|
||||
auto __x = __to_unsigned(__value);
|
||||
if (__value < 0 && __first != __last)
|
||||
{
|
||||
*__first++ = '-';
|
||||
__x = __complement(__x);
|
||||
}
|
||||
|
||||
return __to_chars_itoa(__first, __last, __x, false_type());
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
|
||||
__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
|
||||
{
|
||||
using __tx = __itoa::__traits<_Tp>;
|
||||
auto __diff = __last - __first;
|
||||
|
||||
#if !defined(_LIBCPP_COMPILER_MSVC)
|
||||
if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
|
||||
return {__tx::__convert(__value, __first), {}};
|
||||
else
|
||||
return {__last, errc::value_too_large};
|
||||
#else
|
||||
if (__tx::digits <= __diff)
|
||||
return {__tx::__convert(__value, __first), {}};
|
||||
else
|
||||
{
|
||||
char __buf[__tx::digits];
|
||||
auto __p = __tx::__convert(__value, __buf);
|
||||
auto __len = __p - __buf;
|
||||
if (__len <= __diff)
|
||||
{
|
||||
memcpy(__first, __buf, __len);
|
||||
return {__first + __len, {}};
|
||||
}
|
||||
else
|
||||
return {__last, errc::value_too_large};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
|
||||
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
|
||||
true_type)
|
||||
{
|
||||
auto __x = __to_unsigned(__value);
|
||||
if (__value < 0 && __first != __last)
|
||||
{
|
||||
*__first++ = '-';
|
||||
__x = __complement(__x);
|
||||
}
|
||||
|
||||
return __to_chars_integral(__first, __last, __x, __base, false_type());
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
|
||||
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
|
||||
false_type)
|
||||
{
|
||||
if (__base == 10)
|
||||
return __to_chars_itoa(__first, __last, __value, false_type());
|
||||
|
||||
auto __p = __last;
|
||||
while (__p != __first)
|
||||
{
|
||||
auto __c = __value % __base;
|
||||
__value /= __base;
|
||||
*--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c];
|
||||
if (__value == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
auto __len = __last - __p;
|
||||
if (__value != 0 || !__len)
|
||||
return {__last, errc::value_too_large};
|
||||
else
|
||||
{
|
||||
memmove(__first, __p, __len);
|
||||
return {__first + __len, {}};
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
|
||||
to_chars(char* __first, char* __last, _Tp __value)
|
||||
{
|
||||
return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
|
||||
to_chars(char* __first, char* __last, _Tp __value, int __base)
|
||||
{
|
||||
_LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
|
||||
return __to_chars_integral(__first, __last, __value, __base,
|
||||
is_signed<_Tp>());
|
||||
}
|
||||
|
||||
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
|
||||
{
|
||||
using __tl = numeric_limits<_Tp>;
|
||||
decltype(__to_unsigned(__value)) __x;
|
||||
|
||||
bool __neg = (__first != __last && *__first == '-');
|
||||
auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
|
||||
switch (__r.ec)
|
||||
{
|
||||
case errc::invalid_argument:
|
||||
return {__first, __r.ec};
|
||||
case errc::result_out_of_range:
|
||||
return __r;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (__neg)
|
||||
{
|
||||
if (__x <= __complement(__to_unsigned(__tl::min())))
|
||||
{
|
||||
__x = __complement(__x);
|
||||
memcpy(&__value, &__x, sizeof(__x));
|
||||
return __r;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__x <= (__tl::max)())
|
||||
{
|
||||
__value = __x;
|
||||
return __r;
|
||||
}
|
||||
}
|
||||
|
||||
return {__r.ptr, errc::result_out_of_range};
|
||||
}
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY bool
|
||||
__in_pattern(_Tp __c)
|
||||
{
|
||||
return '0' <= __c && __c <= '9';
|
||||
}
|
||||
|
||||
struct _LIBCPP_HIDDEN __in_pattern_result
|
||||
{
|
||||
bool __ok;
|
||||
int __val;
|
||||
|
||||
explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; }
|
||||
};
|
||||
|
||||
template <typename _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result
|
||||
__in_pattern(_Tp __c, int __base)
|
||||
{
|
||||
if (__base <= 10)
|
||||
return {'0' <= __c && __c < '0' + __base, __c - '0'};
|
||||
else if (__in_pattern(__c))
|
||||
return {true, __c - '0'};
|
||||
else if ('a' <= __c && __c < 'a' + __base - 10)
|
||||
return {true, __c - 'a' + 10};
|
||||
else
|
||||
return {'A' <= __c && __c < 'A' + __base - 10, __c - 'A' + 10};
|
||||
}
|
||||
|
||||
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
|
||||
_Ts... __args)
|
||||
{
|
||||
auto __find_non_zero = [](_It __first, _It __last) {
|
||||
for (; __first != __last; ++__first)
|
||||
if (*__first != '0')
|
||||
break;
|
||||
return __first;
|
||||
};
|
||||
|
||||
auto __p = __find_non_zero(__first, __last);
|
||||
if (__p == __last || !__in_pattern(*__p, __args...))
|
||||
{
|
||||
if (__p == __first)
|
||||
return {__first, errc::invalid_argument};
|
||||
else
|
||||
{
|
||||
__value = 0;
|
||||
return {__p, {}};
|
||||
}
|
||||
}
|
||||
|
||||
auto __r = __f(__p, __last, __value, __args...);
|
||||
if (__r.ec == errc::result_out_of_range)
|
||||
{
|
||||
for (; __r.ptr != __last; ++__r.ptr)
|
||||
{
|
||||
if (!__in_pattern(*__r.ptr, __args...))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_unsigned<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
|
||||
{
|
||||
using __tx = __itoa::__traits<_Tp>;
|
||||
using __output_type = typename __tx::type;
|
||||
|
||||
return __subject_seq_combinator(
|
||||
__first, __last, __value,
|
||||
[](const char* __first, const char* __last,
|
||||
_Tp& __value) -> from_chars_result {
|
||||
__output_type __a, __b;
|
||||
auto __p = __tx::__read(__first, __last, __a, __b);
|
||||
if (__p == __last || !__in_pattern(*__p))
|
||||
{
|
||||
__output_type __m = (numeric_limits<_Tp>::max)();
|
||||
if (__m >= __a && __m - __a >= __b)
|
||||
{
|
||||
__value = __a + __b;
|
||||
return {__p, {}};
|
||||
}
|
||||
}
|
||||
return {__p, errc::result_out_of_range};
|
||||
});
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_signed<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
|
||||
{
|
||||
using __t = decltype(__to_unsigned(__value));
|
||||
return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_unsigned<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
|
||||
int __base)
|
||||
{
|
||||
if (__base == 10)
|
||||
return __from_chars_atoi(__first, __last, __value);
|
||||
|
||||
return __subject_seq_combinator(
|
||||
__first, __last, __value,
|
||||
[](const char* __p, const char* __last, _Tp& __value,
|
||||
int __base) -> from_chars_result {
|
||||
using __tl = numeric_limits<_Tp>;
|
||||
auto __digits = __tl::digits / log2f(float(__base));
|
||||
_Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;
|
||||
|
||||
for (int __i = 1; __p != __last; ++__i, ++__p)
|
||||
{
|
||||
if (auto __c = __in_pattern(*__p, __base))
|
||||
{
|
||||
if (__i < __digits - 1)
|
||||
__a = __a * __base + __c.__val;
|
||||
else
|
||||
{
|
||||
if (!__itoa::__mul_overflowed(__a, __base, __a))
|
||||
++__p;
|
||||
__b = __c.__val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (__p == __last || !__in_pattern(*__p, __base))
|
||||
{
|
||||
if ((__tl::max)() - __a >= __b)
|
||||
{
|
||||
__value = __a + __b;
|
||||
return {__p, {}};
|
||||
}
|
||||
}
|
||||
return {__p, errc::result_out_of_range};
|
||||
},
|
||||
__base);
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_signed<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
|
||||
int __base)
|
||||
{
|
||||
using __t = decltype(__to_unsigned(__value));
|
||||
return __sign_combinator(__first, __last, __value,
|
||||
__from_chars_integral<__t>, __base);
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
from_chars(const char* __first, const char* __last, _Tp& __value)
|
||||
{
|
||||
return __from_chars_atoi(__first, __last, __value);
|
||||
}
|
||||
|
||||
template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
|
||||
from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
|
||||
{
|
||||
_LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
|
||||
return __from_chars_integral(__first, __last, __value, __base);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_CHARCONV
|
2865
libcxx/include/chrono
Normal file
2865
libcxx/include/chrono
Normal file
File diff suppressed because it is too large
Load Diff
258
libcxx/include/cinttypes
Normal file
258
libcxx/include/cinttypes
Normal file
@ -0,0 +1,258 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cinttypes --------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CINTTYPES
|
||||
#define _LIBCPP_CINTTYPES
|
||||
|
||||
/*
|
||||
cinttypes synopsis
|
||||
|
||||
This entire header is C99 / C++0X
|
||||
|
||||
#include <cstdint> // <cinttypes> includes <cstdint>
|
||||
|
||||
Macros:
|
||||
|
||||
PRId8
|
||||
PRId16
|
||||
PRId32
|
||||
PRId64
|
||||
|
||||
PRIdLEAST8
|
||||
PRIdLEAST16
|
||||
PRIdLEAST32
|
||||
PRIdLEAST64
|
||||
|
||||
PRIdFAST8
|
||||
PRIdFAST16
|
||||
PRIdFAST32
|
||||
PRIdFAST64
|
||||
|
||||
PRIdMAX
|
||||
PRIdPTR
|
||||
|
||||
PRIi8
|
||||
PRIi16
|
||||
PRIi32
|
||||
PRIi64
|
||||
|
||||
PRIiLEAST8
|
||||
PRIiLEAST16
|
||||
PRIiLEAST32
|
||||
PRIiLEAST64
|
||||
|
||||
PRIiFAST8
|
||||
PRIiFAST16
|
||||
PRIiFAST32
|
||||
PRIiFAST64
|
||||
|
||||
PRIiMAX
|
||||
PRIiPTR
|
||||
|
||||
PRIo8
|
||||
PRIo16
|
||||
PRIo32
|
||||
PRIo64
|
||||
|
||||
PRIoLEAST8
|
||||
PRIoLEAST16
|
||||
PRIoLEAST32
|
||||
PRIoLEAST64
|
||||
|
||||
PRIoFAST8
|
||||
PRIoFAST16
|
||||
PRIoFAST32
|
||||
PRIoFAST64
|
||||
|
||||
PRIoMAX
|
||||
PRIoPTR
|
||||
|
||||
PRIu8
|
||||
PRIu16
|
||||
PRIu32
|
||||
PRIu64
|
||||
|
||||
PRIuLEAST8
|
||||
PRIuLEAST16
|
||||
PRIuLEAST32
|
||||
PRIuLEAST64
|
||||
|
||||
PRIuFAST8
|
||||
PRIuFAST16
|
||||
PRIuFAST32
|
||||
PRIuFAST64
|
||||
|
||||
PRIuMAX
|
||||
PRIuPTR
|
||||
|
||||
PRIx8
|
||||
PRIx16
|
||||
PRIx32
|
||||
PRIx64
|
||||
|
||||
PRIxLEAST8
|
||||
PRIxLEAST16
|
||||
PRIxLEAST32
|
||||
PRIxLEAST64
|
||||
|
||||
PRIxFAST8
|
||||
PRIxFAST16
|
||||
PRIxFAST32
|
||||
PRIxFAST64
|
||||
|
||||
PRIxMAX
|
||||
PRIxPTR
|
||||
|
||||
PRIX8
|
||||
PRIX16
|
||||
PRIX32
|
||||
PRIX64
|
||||
|
||||
PRIXLEAST8
|
||||
PRIXLEAST16
|
||||
PRIXLEAST32
|
||||
PRIXLEAST64
|
||||
|
||||
PRIXFAST8
|
||||
PRIXFAST16
|
||||
PRIXFAST32
|
||||
PRIXFAST64
|
||||
|
||||
PRIXMAX
|
||||
PRIXPTR
|
||||
|
||||
SCNd8
|
||||
SCNd16
|
||||
SCNd32
|
||||
SCNd64
|
||||
|
||||
SCNdLEAST8
|
||||
SCNdLEAST16
|
||||
SCNdLEAST32
|
||||
SCNdLEAST64
|
||||
|
||||
SCNdFAST8
|
||||
SCNdFAST16
|
||||
SCNdFAST32
|
||||
SCNdFAST64
|
||||
|
||||
SCNdMAX
|
||||
SCNdPTR
|
||||
|
||||
SCNi8
|
||||
SCNi16
|
||||
SCNi32
|
||||
SCNi64
|
||||
|
||||
SCNiLEAST8
|
||||
SCNiLEAST16
|
||||
SCNiLEAST32
|
||||
SCNiLEAST64
|
||||
|
||||
SCNiFAST8
|
||||
SCNiFAST16
|
||||
SCNiFAST32
|
||||
SCNiFAST64
|
||||
|
||||
SCNiMAX
|
||||
SCNiPTR
|
||||
|
||||
SCNo8
|
||||
SCNo16
|
||||
SCNo32
|
||||
SCNo64
|
||||
|
||||
SCNoLEAST8
|
||||
SCNoLEAST16
|
||||
SCNoLEAST32
|
||||
SCNoLEAST64
|
||||
|
||||
SCNoFAST8
|
||||
SCNoFAST16
|
||||
SCNoFAST32
|
||||
SCNoFAST64
|
||||
|
||||
SCNoMAX
|
||||
SCNoPTR
|
||||
|
||||
SCNu8
|
||||
SCNu16
|
||||
SCNu32
|
||||
SCNu64
|
||||
|
||||
SCNuLEAST8
|
||||
SCNuLEAST16
|
||||
SCNuLEAST32
|
||||
SCNuLEAST64
|
||||
|
||||
SCNuFAST8
|
||||
SCNuFAST16
|
||||
SCNuFAST32
|
||||
SCNuFAST64
|
||||
|
||||
SCNuMAX
|
||||
SCNuPTR
|
||||
|
||||
SCNx8
|
||||
SCNx16
|
||||
SCNx32
|
||||
SCNx64
|
||||
|
||||
SCNxLEAST8
|
||||
SCNxLEAST16
|
||||
SCNxLEAST32
|
||||
SCNxLEAST64
|
||||
|
||||
SCNxFAST8
|
||||
SCNxFAST16
|
||||
SCNxFAST32
|
||||
SCNxFAST64
|
||||
|
||||
SCNxMAX
|
||||
SCNxPTR
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
imaxdiv_t
|
||||
|
||||
intmax_t imaxabs(intmax_t j);
|
||||
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
|
||||
intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
|
||||
uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
|
||||
intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
|
||||
uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cstdint>
|
||||
#include <inttypes.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using::imaxdiv_t;
|
||||
using::imaxabs;
|
||||
using::imaxdiv;
|
||||
using::strtoimax;
|
||||
using::strtoumax;
|
||||
using::wcstoimax;
|
||||
using::wcstoumax;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CINTTYPES
|
25
libcxx/include/ciso646
Normal file
25
libcxx/include/ciso646
Normal file
@ -0,0 +1,25 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- ciso646 ----------------------------------===//
|
||||
//
|
||||
// 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_CISO646
|
||||
#define _LIBCPP_CISO646
|
||||
|
||||
/*
|
||||
ciso646 synopsis
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CISO646
|
48
libcxx/include/climits
Normal file
48
libcxx/include/climits
Normal file
@ -0,0 +1,48 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- climits ----------------------------------===//
|
||||
//
|
||||
// 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_CLIMITS
|
||||
#define _LIBCPP_CLIMITS
|
||||
|
||||
/*
|
||||
climits synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
CHAR_BIT
|
||||
SCHAR_MIN
|
||||
SCHAR_MAX
|
||||
UCHAR_MAX
|
||||
CHAR_MIN
|
||||
CHAR_MAX
|
||||
MB_LEN_MAX
|
||||
SHRT_MIN
|
||||
SHRT_MAX
|
||||
USHRT_MAX
|
||||
INT_MIN
|
||||
INT_MAX
|
||||
UINT_MAX
|
||||
LONG_MIN
|
||||
LONG_MAX
|
||||
ULONG_MAX
|
||||
LLONG_MIN // C99
|
||||
LLONG_MAX // C99
|
||||
ULLONG_MAX // C99
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <limits.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CLIMITS
|
55
libcxx/include/clocale
Normal file
55
libcxx/include/clocale
Normal file
@ -0,0 +1,55 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- clocale ----------------------------------===//
|
||||
//
|
||||
// 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_CLOCALE
|
||||
#define _LIBCPP_CLOCALE
|
||||
|
||||
/*
|
||||
clocale synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
LC_ALL
|
||||
LC_COLLATE
|
||||
LC_CTYPE
|
||||
LC_MONETARY
|
||||
LC_NUMERIC
|
||||
LC_TIME
|
||||
NULL
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
struct lconv;
|
||||
char* setlocale(int category, const char* locale);
|
||||
lconv* localeconv();
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <locale.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::lconv;
|
||||
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
using ::setlocale;
|
||||
#endif
|
||||
using ::localeconv;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CLOCALE
|
612
libcxx/include/cmath
Normal file
612
libcxx/include/cmath
Normal file
@ -0,0 +1,612 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- cmath -----------------------------------===//
|
||||
//
|
||||
// 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_CMATH
|
||||
#define _LIBCPP_CMATH
|
||||
|
||||
/*
|
||||
cmath synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
HUGE_VAL
|
||||
HUGE_VALF // C99
|
||||
HUGE_VALL // C99
|
||||
INFINITY // C99
|
||||
NAN // C99
|
||||
FP_INFINITE // C99
|
||||
FP_NAN // C99
|
||||
FP_NORMAL // C99
|
||||
FP_SUBNORMAL // C99
|
||||
FP_ZERO // C99
|
||||
FP_FAST_FMA // C99
|
||||
FP_FAST_FMAF // C99
|
||||
FP_FAST_FMAL // C99
|
||||
FP_ILOGB0 // C99
|
||||
FP_ILOGBNAN // C99
|
||||
MATH_ERRNO // C99
|
||||
MATH_ERREXCEPT // C99
|
||||
math_errhandling // C99
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
float_t // C99
|
||||
double_t // C99
|
||||
|
||||
// C90
|
||||
|
||||
floating_point abs(floating_point x);
|
||||
|
||||
floating_point acos (arithmetic x);
|
||||
float acosf(float x);
|
||||
long double acosl(long double x);
|
||||
|
||||
floating_point asin (arithmetic x);
|
||||
float asinf(float x);
|
||||
long double asinl(long double x);
|
||||
|
||||
floating_point atan (arithmetic x);
|
||||
float atanf(float x);
|
||||
long double atanl(long double x);
|
||||
|
||||
floating_point atan2 (arithmetic y, arithmetic x);
|
||||
float atan2f(float y, float x);
|
||||
long double atan2l(long double y, long double x);
|
||||
|
||||
floating_point ceil (arithmetic x);
|
||||
float ceilf(float x);
|
||||
long double ceill(long double x);
|
||||
|
||||
floating_point cos (arithmetic x);
|
||||
float cosf(float x);
|
||||
long double cosl(long double x);
|
||||
|
||||
floating_point cosh (arithmetic x);
|
||||
float coshf(float x);
|
||||
long double coshl(long double x);
|
||||
|
||||
floating_point exp (arithmetic x);
|
||||
float expf(float x);
|
||||
long double expl(long double x);
|
||||
|
||||
floating_point fabs (arithmetic x);
|
||||
float fabsf(float x);
|
||||
long double fabsl(long double x);
|
||||
|
||||
floating_point floor (arithmetic x);
|
||||
float floorf(float x);
|
||||
long double floorl(long double x);
|
||||
|
||||
floating_point fmod (arithmetic x, arithmetic y);
|
||||
float fmodf(float x, float y);
|
||||
long double fmodl(long double x, long double y);
|
||||
|
||||
floating_point frexp (arithmetic value, int* exp);
|
||||
float frexpf(float value, int* exp);
|
||||
long double frexpl(long double value, int* exp);
|
||||
|
||||
floating_point ldexp (arithmetic value, int exp);
|
||||
float ldexpf(float value, int exp);
|
||||
long double ldexpl(long double value, int exp);
|
||||
|
||||
floating_point log (arithmetic x);
|
||||
float logf(float x);
|
||||
long double logl(long double x);
|
||||
|
||||
floating_point log10 (arithmetic x);
|
||||
float log10f(float x);
|
||||
long double log10l(long double x);
|
||||
|
||||
floating_point modf (floating_point value, floating_point* iptr);
|
||||
float modff(float value, float* iptr);
|
||||
long double modfl(long double value, long double* iptr);
|
||||
|
||||
floating_point pow (arithmetic x, arithmetic y);
|
||||
float powf(float x, float y);
|
||||
long double powl(long double x, long double y);
|
||||
|
||||
floating_point sin (arithmetic x);
|
||||
float sinf(float x);
|
||||
long double sinl(long double x);
|
||||
|
||||
floating_point sinh (arithmetic x);
|
||||
float sinhf(float x);
|
||||
long double sinhl(long double x);
|
||||
|
||||
floating_point sqrt (arithmetic x);
|
||||
float sqrtf(float x);
|
||||
long double sqrtl(long double x);
|
||||
|
||||
floating_point tan (arithmetic x);
|
||||
float tanf(float x);
|
||||
long double tanl(long double x);
|
||||
|
||||
floating_point tanh (arithmetic x);
|
||||
float tanhf(float x);
|
||||
long double tanhl(long double x);
|
||||
|
||||
// C99
|
||||
|
||||
bool signbit(arithmetic x);
|
||||
|
||||
int fpclassify(arithmetic x);
|
||||
|
||||
bool isfinite(arithmetic x);
|
||||
bool isinf(arithmetic x);
|
||||
bool isnan(arithmetic x);
|
||||
bool isnormal(arithmetic x);
|
||||
|
||||
bool isgreater(arithmetic x, arithmetic y);
|
||||
bool isgreaterequal(arithmetic x, arithmetic y);
|
||||
bool isless(arithmetic x, arithmetic y);
|
||||
bool islessequal(arithmetic x, arithmetic y);
|
||||
bool islessgreater(arithmetic x, arithmetic y);
|
||||
bool isunordered(arithmetic x, arithmetic y);
|
||||
|
||||
floating_point acosh (arithmetic x);
|
||||
float acoshf(float x);
|
||||
long double acoshl(long double x);
|
||||
|
||||
floating_point asinh (arithmetic x);
|
||||
float asinhf(float x);
|
||||
long double asinhl(long double x);
|
||||
|
||||
floating_point atanh (arithmetic x);
|
||||
float atanhf(float x);
|
||||
long double atanhl(long double x);
|
||||
|
||||
floating_point cbrt (arithmetic x);
|
||||
float cbrtf(float x);
|
||||
long double cbrtl(long double x);
|
||||
|
||||
floating_point copysign (arithmetic x, arithmetic y);
|
||||
float copysignf(float x, float y);
|
||||
long double copysignl(long double x, long double y);
|
||||
|
||||
floating_point erf (arithmetic x);
|
||||
float erff(float x);
|
||||
long double erfl(long double x);
|
||||
|
||||
floating_point erfc (arithmetic x);
|
||||
float erfcf(float x);
|
||||
long double erfcl(long double x);
|
||||
|
||||
floating_point exp2 (arithmetic x);
|
||||
float exp2f(float x);
|
||||
long double exp2l(long double x);
|
||||
|
||||
floating_point expm1 (arithmetic x);
|
||||
float expm1f(float x);
|
||||
long double expm1l(long double x);
|
||||
|
||||
floating_point fdim (arithmetic x, arithmetic y);
|
||||
float fdimf(float x, float y);
|
||||
long double fdiml(long double x, long double y);
|
||||
|
||||
floating_point fma (arithmetic x, arithmetic y, arithmetic z);
|
||||
float fmaf(float x, float y, float z);
|
||||
long double fmal(long double x, long double y, long double z);
|
||||
|
||||
floating_point fmax (arithmetic x, arithmetic y);
|
||||
float fmaxf(float x, float y);
|
||||
long double fmaxl(long double x, long double y);
|
||||
|
||||
floating_point fmin (arithmetic x, arithmetic y);
|
||||
float fminf(float x, float y);
|
||||
long double fminl(long double x, long double y);
|
||||
|
||||
floating_point hypot (arithmetic x, arithmetic y);
|
||||
float hypotf(float x, float y);
|
||||
long double hypotl(long double x, long double y);
|
||||
|
||||
double hypot(double x, double y, double z); // C++17
|
||||
float hypot(float x, float y, float z); // C++17
|
||||
long double hypot(long double x, long double y, long double z); // C++17
|
||||
|
||||
int ilogb (arithmetic x);
|
||||
int ilogbf(float x);
|
||||
int ilogbl(long double x);
|
||||
|
||||
floating_point lgamma (arithmetic x);
|
||||
float lgammaf(float x);
|
||||
long double lgammal(long double x);
|
||||
|
||||
long long llrint (arithmetic x);
|
||||
long long llrintf(float x);
|
||||
long long llrintl(long double x);
|
||||
|
||||
long long llround (arithmetic x);
|
||||
long long llroundf(float x);
|
||||
long long llroundl(long double x);
|
||||
|
||||
floating_point log1p (arithmetic x);
|
||||
float log1pf(float x);
|
||||
long double log1pl(long double x);
|
||||
|
||||
floating_point log2 (arithmetic x);
|
||||
float log2f(float x);
|
||||
long double log2l(long double x);
|
||||
|
||||
floating_point logb (arithmetic x);
|
||||
float logbf(float x);
|
||||
long double logbl(long double x);
|
||||
|
||||
long lrint (arithmetic x);
|
||||
long lrintf(float x);
|
||||
long lrintl(long double x);
|
||||
|
||||
long lround (arithmetic x);
|
||||
long lroundf(float x);
|
||||
long lroundl(long double x);
|
||||
|
||||
double nan (const char* str);
|
||||
float nanf(const char* str);
|
||||
long double nanl(const char* str);
|
||||
|
||||
floating_point nearbyint (arithmetic x);
|
||||
float nearbyintf(float x);
|
||||
long double nearbyintl(long double x);
|
||||
|
||||
floating_point nextafter (arithmetic x, arithmetic y);
|
||||
float nextafterf(float x, float y);
|
||||
long double nextafterl(long double x, long double y);
|
||||
|
||||
floating_point nexttoward (arithmetic x, long double y);
|
||||
float nexttowardf(float x, long double y);
|
||||
long double nexttowardl(long double x, long double y);
|
||||
|
||||
floating_point remainder (arithmetic x, arithmetic y);
|
||||
float remainderf(float x, float y);
|
||||
long double remainderl(long double x, long double y);
|
||||
|
||||
floating_point remquo (arithmetic x, arithmetic y, int* pquo);
|
||||
float remquof(float x, float y, int* pquo);
|
||||
long double remquol(long double x, long double y, int* pquo);
|
||||
|
||||
floating_point rint (arithmetic x);
|
||||
float rintf(float x);
|
||||
long double rintl(long double x);
|
||||
|
||||
floating_point round (arithmetic x);
|
||||
float roundf(float x);
|
||||
long double roundl(long double x);
|
||||
|
||||
floating_point scalbln (arithmetic x, long ex);
|
||||
float scalblnf(float x, long ex);
|
||||
long double scalblnl(long double x, long ex);
|
||||
|
||||
floating_point scalbn (arithmetic x, int ex);
|
||||
float scalbnf(float x, int ex);
|
||||
long double scalbnl(long double x, int ex);
|
||||
|
||||
floating_point tgamma (arithmetic x);
|
||||
float tgammaf(float x);
|
||||
long double tgammal(long double x);
|
||||
|
||||
floating_point trunc (arithmetic x);
|
||||
float truncf(float x);
|
||||
long double truncl(long double x);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <math.h>
|
||||
#include <version>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::signbit;
|
||||
using ::fpclassify;
|
||||
using ::isfinite;
|
||||
using ::isinf;
|
||||
using ::isnan;
|
||||
using ::isnormal;
|
||||
using ::isgreater;
|
||||
using ::isgreaterequal;
|
||||
using ::isless;
|
||||
using ::islessequal;
|
||||
using ::islessgreater;
|
||||
using ::isunordered;
|
||||
using ::isunordered;
|
||||
|
||||
using ::float_t;
|
||||
using ::double_t;
|
||||
|
||||
#ifndef _AIX
|
||||
using ::abs;
|
||||
#endif
|
||||
|
||||
using ::acos;
|
||||
using ::acosf;
|
||||
using ::asin;
|
||||
using ::asinf;
|
||||
using ::atan;
|
||||
using ::atanf;
|
||||
using ::atan2;
|
||||
using ::atan2f;
|
||||
using ::ceil;
|
||||
using ::ceilf;
|
||||
using ::cos;
|
||||
using ::cosf;
|
||||
using ::cosh;
|
||||
using ::coshf;
|
||||
|
||||
using ::exp;
|
||||
using ::expf;
|
||||
|
||||
using ::fabs;
|
||||
using ::fabsf;
|
||||
using ::floor;
|
||||
using ::floorf;
|
||||
|
||||
using ::fmod;
|
||||
using ::fmodf;
|
||||
|
||||
using ::frexp;
|
||||
using ::frexpf;
|
||||
using ::ldexp;
|
||||
using ::ldexpf;
|
||||
|
||||
using ::log;
|
||||
using ::logf;
|
||||
|
||||
using ::log10;
|
||||
using ::log10f;
|
||||
using ::modf;
|
||||
using ::modff;
|
||||
|
||||
using ::pow;
|
||||
using ::powf;
|
||||
|
||||
using ::sin;
|
||||
using ::sinf;
|
||||
using ::sinh;
|
||||
using ::sinhf;
|
||||
|
||||
using ::sqrt;
|
||||
using ::sqrtf;
|
||||
using ::tan;
|
||||
using ::tanf;
|
||||
|
||||
using ::tanh;
|
||||
using ::tanhf;
|
||||
|
||||
using ::acosh;
|
||||
using ::acoshf;
|
||||
using ::asinh;
|
||||
using ::asinhf;
|
||||
using ::atanh;
|
||||
using ::atanhf;
|
||||
using ::cbrt;
|
||||
using ::cbrtf;
|
||||
|
||||
using ::copysign;
|
||||
using ::copysignf;
|
||||
|
||||
using ::erf;
|
||||
using ::erff;
|
||||
using ::erfc;
|
||||
using ::erfcf;
|
||||
using ::exp2;
|
||||
using ::exp2f;
|
||||
using ::expm1;
|
||||
using ::expm1f;
|
||||
using ::fdim;
|
||||
using ::fdimf;
|
||||
using ::fmaf;
|
||||
using ::fma;
|
||||
using ::fmax;
|
||||
using ::fmaxf;
|
||||
using ::fmin;
|
||||
using ::fminf;
|
||||
using ::hypot;
|
||||
using ::hypotf;
|
||||
using ::ilogb;
|
||||
using ::ilogbf;
|
||||
using ::lgamma;
|
||||
using ::lgammaf;
|
||||
using ::llrint;
|
||||
using ::llrintf;
|
||||
using ::llround;
|
||||
using ::llroundf;
|
||||
using ::log1p;
|
||||
using ::log1pf;
|
||||
using ::log2;
|
||||
using ::log2f;
|
||||
using ::logb;
|
||||
using ::logbf;
|
||||
using ::lrint;
|
||||
using ::lrintf;
|
||||
using ::lround;
|
||||
using ::lroundf;
|
||||
|
||||
using ::nan;
|
||||
using ::nanf;
|
||||
|
||||
using ::nearbyint;
|
||||
using ::nearbyintf;
|
||||
using ::nextafter;
|
||||
using ::nextafterf;
|
||||
using ::nexttoward;
|
||||
using ::nexttowardf;
|
||||
using ::remainder;
|
||||
using ::remainderf;
|
||||
using ::remquo;
|
||||
using ::remquof;
|
||||
using ::rint;
|
||||
using ::rintf;
|
||||
using ::round;
|
||||
using ::roundf;
|
||||
using ::scalbln;
|
||||
using ::scalblnf;
|
||||
using ::scalbn;
|
||||
using ::scalbnf;
|
||||
using ::tgamma;
|
||||
using ::tgammaf;
|
||||
using ::trunc;
|
||||
using ::truncf;
|
||||
|
||||
using ::acosl;
|
||||
using ::asinl;
|
||||
using ::atanl;
|
||||
using ::atan2l;
|
||||
using ::ceill;
|
||||
using ::cosl;
|
||||
using ::coshl;
|
||||
using ::expl;
|
||||
using ::fabsl;
|
||||
using ::floorl;
|
||||
using ::fmodl;
|
||||
using ::frexpl;
|
||||
using ::ldexpl;
|
||||
using ::logl;
|
||||
using ::log10l;
|
||||
using ::modfl;
|
||||
using ::powl;
|
||||
using ::sinl;
|
||||
using ::sinhl;
|
||||
using ::sqrtl;
|
||||
using ::tanl;
|
||||
|
||||
using ::tanhl;
|
||||
using ::acoshl;
|
||||
using ::asinhl;
|
||||
using ::atanhl;
|
||||
using ::cbrtl;
|
||||
|
||||
using ::copysignl;
|
||||
|
||||
using ::erfl;
|
||||
using ::erfcl;
|
||||
using ::exp2l;
|
||||
using ::expm1l;
|
||||
using ::fdiml;
|
||||
using ::fmal;
|
||||
using ::fmaxl;
|
||||
using ::fminl;
|
||||
using ::hypotl;
|
||||
using ::ilogbl;
|
||||
using ::lgammal;
|
||||
using ::llrintl;
|
||||
using ::llroundl;
|
||||
using ::log1pl;
|
||||
using ::log2l;
|
||||
using ::logbl;
|
||||
using ::lrintl;
|
||||
using ::lroundl;
|
||||
using ::nanl;
|
||||
using ::nearbyintl;
|
||||
using ::nextafterl;
|
||||
using ::nexttowardl;
|
||||
using ::remainderl;
|
||||
using ::remquol;
|
||||
using ::rintl;
|
||||
using ::roundl;
|
||||
using ::scalblnl;
|
||||
using ::scalbnl;
|
||||
using ::tgammal;
|
||||
using ::truncl;
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
|
||||
|
||||
template <class _A1, class _A2, class _A3>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __lazy_enable_if
|
||||
<
|
||||
is_arithmetic<_A1>::value &&
|
||||
is_arithmetic<_A2>::value &&
|
||||
is_arithmetic<_A3>::value,
|
||||
__promote<_A1, _A2, _A3>
|
||||
>::type
|
||||
hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
|
||||
{
|
||||
typedef typename __promote<_A1, _A2, _A3>::type __result_type;
|
||||
static_assert((!(is_same<_A1, __result_type>::value &&
|
||||
is_same<_A2, __result_type>::value &&
|
||||
is_same<_A3, __result_type>::value)), "");
|
||||
return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
#if __has_builtin(__builtin_isnan)
|
||||
return __builtin_isnan(__lcpp_x);
|
||||
#else
|
||||
return isnan(__lcpp_x);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
return isnan(__lcpp_x);
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
#if __has_builtin(__builtin_isinf)
|
||||
return __builtin_isinf(__lcpp_x);
|
||||
#else
|
||||
return isinf(__lcpp_x);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
return isinf(__lcpp_x);
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
#if __has_builtin(__builtin_isfinite)
|
||||
return __builtin_isfinite(__lcpp_x);
|
||||
#else
|
||||
return isfinite(__lcpp_x);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
return isfinite(__lcpp_x);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CMATH
|
550
libcxx/include/codecvt
Normal file
550
libcxx/include/codecvt
Normal file
@ -0,0 +1,550 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- codecvt -----------------------------------===//
|
||||
//
|
||||
// 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_CODECVT
|
||||
#define _LIBCPP_CODECVT
|
||||
|
||||
/*
|
||||
codecvt synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
enum codecvt_mode
|
||||
{
|
||||
consume_header = 4,
|
||||
generate_header = 2,
|
||||
little_endian = 1
|
||||
};
|
||||
|
||||
template <class Elem, unsigned long Maxcode = 0x10ffff,
|
||||
codecvt_mode Mode = (codecvt_mode)0>
|
||||
class codecvt_utf8
|
||||
: public codecvt<Elem, char, mbstate_t>
|
||||
{
|
||||
explicit codecvt_utf8(size_t refs = 0);
|
||||
~codecvt_utf8();
|
||||
};
|
||||
|
||||
template <class Elem, unsigned long Maxcode = 0x10ffff,
|
||||
codecvt_mode Mode = (codecvt_mode)0>
|
||||
class codecvt_utf16
|
||||
: public codecvt<Elem, char, mbstate_t>
|
||||
{
|
||||
explicit codecvt_utf16(size_t refs = 0);
|
||||
~codecvt_utf16();
|
||||
};
|
||||
|
||||
template <class Elem, unsigned long Maxcode = 0x10ffff,
|
||||
codecvt_mode Mode = (codecvt_mode)0>
|
||||
class codecvt_utf8_utf16
|
||||
: public codecvt<Elem, char, mbstate_t>
|
||||
{
|
||||
explicit codecvt_utf8_utf16(size_t refs = 0);
|
||||
~codecvt_utf8_utf16();
|
||||
};
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <__locale>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
enum codecvt_mode
|
||||
{
|
||||
consume_header = 4,
|
||||
generate_header = 2,
|
||||
little_endian = 1
|
||||
};
|
||||
|
||||
// codecvt_utf8
|
||||
|
||||
template <class _Elem> class __codecvt_utf8;
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
|
||||
codecvt_mode _Mode = (codecvt_mode)0>
|
||||
class _LIBCPP_TEMPLATE_VIS codecvt_utf8
|
||||
: public __codecvt_utf8<_Elem>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf8(size_t __refs = 0)
|
||||
: __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf8() {}
|
||||
};
|
||||
|
||||
// codecvt_utf16
|
||||
|
||||
template <class _Elem, bool _LittleEndian> class __codecvt_utf16;
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
|
||||
codecvt_mode _Mode = (codecvt_mode)0>
|
||||
class _LIBCPP_TEMPLATE_VIS codecvt_utf16
|
||||
: public __codecvt_utf16<_Elem, _Mode & little_endian>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf16(size_t __refs = 0)
|
||||
: __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf16() {}
|
||||
};
|
||||
|
||||
// codecvt_utf8_utf16
|
||||
|
||||
template <class _Elem> class __codecvt_utf8_utf16;
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
|
||||
: public codecvt<wchar_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
|
||||
: public codecvt<char32_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char32_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
|
||||
: public codecvt<char16_t, char, mbstate_t>
|
||||
{
|
||||
unsigned long _Maxcode_;
|
||||
codecvt_mode _Mode_;
|
||||
public:
|
||||
typedef char16_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
|
||||
codecvt_mode _Mode)
|
||||
: codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
|
||||
_Mode_(_Mode) {}
|
||||
protected:
|
||||
virtual result
|
||||
do_out(state_type& __st,
|
||||
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_in(state_type& __st,
|
||||
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
||||
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
||||
virtual result
|
||||
do_unshift(state_type& __st,
|
||||
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
||||
virtual int do_encoding() const throw();
|
||||
virtual bool do_always_noconv() const throw();
|
||||
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
|
||||
size_t __mx) const;
|
||||
virtual int do_max_length() const throw();
|
||||
};
|
||||
|
||||
template <class _Elem, unsigned long _Maxcode = 0x10ffff,
|
||||
codecvt_mode _Mode = (codecvt_mode)0>
|
||||
class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
|
||||
: public __codecvt_utf8_utf16<_Elem>
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit codecvt_utf8_utf16(size_t __refs = 0)
|
||||
: __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~codecvt_utf8_utf16() {}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CODECVT
|
679
libcxx/include/compare
Normal file
679
libcxx/include/compare
Normal file
@ -0,0 +1,679 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- compare -----------------------------------===//
|
||||
//
|
||||
// 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_COMPARE
|
||||
#define _LIBCPP_COMPARE
|
||||
|
||||
/*
|
||||
compare synopsis
|
||||
|
||||
namespace std {
|
||||
// [cmp.categories], comparison category types
|
||||
class weak_equality;
|
||||
class strong_equality;
|
||||
class partial_ordering;
|
||||
class weak_ordering;
|
||||
class strong_ordering;
|
||||
|
||||
// named comparison functions
|
||||
constexpr bool is_eq (weak_equality cmp) noexcept { return cmp == 0; }
|
||||
constexpr bool is_neq (weak_equality cmp) noexcept { return cmp != 0; }
|
||||
constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }
|
||||
constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
|
||||
constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }
|
||||
constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
|
||||
|
||||
// [cmp.common], common comparison category type
|
||||
template<class... Ts>
|
||||
struct common_comparison_category {
|
||||
using type = see below;
|
||||
};
|
||||
template<class... Ts>
|
||||
using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
|
||||
|
||||
// [cmp.alg], comparison algorithms
|
||||
template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
|
||||
template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
|
||||
template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
|
||||
template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
|
||||
template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
|
||||
}
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <type_traits>
|
||||
#include <array>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
|
||||
// exposition only
|
||||
enum class _LIBCPP_ENUM_VIS _EqResult : unsigned char {
|
||||
__zero = 0,
|
||||
__equal = __zero,
|
||||
__equiv = __equal,
|
||||
__nonequal = 1,
|
||||
__nonequiv = __nonequal
|
||||
};
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS _OrdResult : signed char {
|
||||
__less = -1,
|
||||
__greater = 1
|
||||
};
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
|
||||
__unordered = -127
|
||||
};
|
||||
|
||||
struct _CmpUnspecifiedType;
|
||||
using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
|
||||
|
||||
class weak_equality {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr explicit weak_equality(_EqResult __val) noexcept : __value_(__val) {}
|
||||
|
||||
public:
|
||||
static const weak_equality equivalent;
|
||||
static const weak_equality nonequivalent;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_EqResult __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::nonequivalent(_EqResult::__nonequiv);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
inline constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept {
|
||||
return __v;
|
||||
}
|
||||
#endif
|
||||
|
||||
class strong_equality {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr strong_equality(_EqResult __val) noexcept : __value_(__val) {}
|
||||
|
||||
public:
|
||||
static const strong_equality equal;
|
||||
static const strong_equality nonequal;
|
||||
static const strong_equality equivalent;
|
||||
static const strong_equality nonequivalent;
|
||||
|
||||
// conversion
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == _EqResult::__zero ? weak_equality::equivalent
|
||||
: weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept;
|
||||
#endif
|
||||
private:
|
||||
_EqResult __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equal(_EqResult::__equal);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequal(_EqResult::__nonequal);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequivalent(_EqResult::__nonequiv);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept {
|
||||
return __v.__value_ == _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept {
|
||||
return __v.__value_ != _EqResult::__zero;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept {
|
||||
return __v;
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
class partial_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr partial_ordering(_EqResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr partial_ordering(_OrdResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr partial_ordering(_NCmpResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
constexpr bool __is_ordered() const noexcept {
|
||||
return __value_ != _ValueT(_NCmpResult::__unordered);
|
||||
}
|
||||
public:
|
||||
// valid values
|
||||
static const partial_ordering less;
|
||||
static const partial_ordering equivalent;
|
||||
static const partial_ordering greater;
|
||||
static const partial_ordering unordered;
|
||||
|
||||
// conversion
|
||||
constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == 0 ? weak_equality::equivalent : weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
|
||||
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ == 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ < 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ <= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ > 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ >= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 == __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 < __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 <= __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 > __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return !__v.__is_ordered() || __v.__value_ != 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return !__v.__is_ordered() || __v.__value_ != 0;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
class weak_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
|
||||
public:
|
||||
static const weak_ordering less;
|
||||
static const weak_ordering equivalent;
|
||||
static const weak_ordering greater;
|
||||
|
||||
// conversions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == 0 ? weak_equality::equivalent
|
||||
: weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator partial_ordering() const noexcept {
|
||||
return __value_ == 0 ? partial_ordering::equivalent
|
||||
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
|
||||
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ < 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ <= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ > 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ >= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 == __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 != __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 < __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 <= __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 > __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
class strong_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
|
||||
public:
|
||||
static const strong_ordering less;
|
||||
static const strong_ordering equal;
|
||||
static const strong_ordering equivalent;
|
||||
static const strong_ordering greater;
|
||||
|
||||
// conversions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator weak_equality() const noexcept {
|
||||
return __value_ == 0 ? weak_equality::equivalent
|
||||
: weak_equality::nonequivalent;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator strong_equality() const noexcept {
|
||||
return __value_ == 0 ? strong_equality::equal
|
||||
: strong_equality::nonequal;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator partial_ordering() const noexcept {
|
||||
return __value_ == 0 ? partial_ordering::equivalent
|
||||
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr operator weak_ordering() const noexcept {
|
||||
return __value_ == 0 ? weak_ordering::equivalent
|
||||
: (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
|
||||
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equal(_EqResult::__equal);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv);
|
||||
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ != 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ < 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ <= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ > 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ >= 0;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 == __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 != __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 < __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 <= __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 > __v.__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
|
||||
|
||||
// named comparison functions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_eq(weak_equality __cmp) noexcept { return __cmp == 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_neq(weak_equality __cmp) noexcept { return __cmp != 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_lteq(partial_ordering __cmp) noexcept { return __cmp <= 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_gt(partial_ordering __cmp) noexcept { return __cmp > 0; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool is_gteq(partial_ordering __cmp) noexcept { return __cmp >= 0; }
|
||||
|
||||
namespace __comp_detail {
|
||||
|
||||
enum _ClassifyCompCategory : unsigned{
|
||||
_None,
|
||||
_WeakEq,
|
||||
_StrongEq,
|
||||
_PartialOrd,
|
||||
_WeakOrd,
|
||||
_StrongOrd,
|
||||
_CCC_Size
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _ClassifyCompCategory __type_to_enum() noexcept {
|
||||
if (is_same_v<_Tp, weak_equality>)
|
||||
return _WeakEq;
|
||||
if (is_same_v<_Tp, strong_equality>)
|
||||
return _StrongEq;
|
||||
if (is_same_v<_Tp, partial_ordering>)
|
||||
return _PartialOrd;
|
||||
if (is_same_v<_Tp, weak_ordering>)
|
||||
return _WeakOrd;
|
||||
if (is_same_v<_Tp, strong_ordering>)
|
||||
return _StrongOrd;
|
||||
return _None;
|
||||
}
|
||||
|
||||
template <size_t _Size>
|
||||
constexpr _ClassifyCompCategory
|
||||
__compute_comp_type(std::array<_ClassifyCompCategory, _Size> __types) {
|
||||
std::array<int, _CCC_Size> __seen = {};
|
||||
for (auto __type : __types)
|
||||
++__seen[__type];
|
||||
if (__seen[_None])
|
||||
return _None;
|
||||
if (__seen[_WeakEq])
|
||||
return _WeakEq;
|
||||
if (__seen[_StrongEq] && (__seen[_PartialOrd] || __seen[_WeakOrd]))
|
||||
return _WeakEq;
|
||||
if (__seen[_StrongEq])
|
||||
return _StrongEq;
|
||||
if (__seen[_PartialOrd])
|
||||
return _PartialOrd;
|
||||
if (__seen[_WeakOrd])
|
||||
return _WeakOrd;
|
||||
return _StrongOrd;
|
||||
}
|
||||
|
||||
template <class ..._Ts>
|
||||
constexpr auto __get_comp_type() {
|
||||
using _CCC = _ClassifyCompCategory;
|
||||
constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
|
||||
constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
|
||||
: __compute_comp_type(__type_kinds);
|
||||
if constexpr (_Cat == _None)
|
||||
return void();
|
||||
else if constexpr (_Cat == _WeakEq)
|
||||
return weak_equality::equivalent;
|
||||
else if constexpr (_Cat == _StrongEq)
|
||||
return strong_equality::equivalent;
|
||||
else if constexpr (_Cat == _PartialOrd)
|
||||
return partial_ordering::equivalent;
|
||||
else if constexpr (_Cat == _WeakOrd)
|
||||
return weak_ordering::equivalent;
|
||||
else if constexpr (_Cat == _StrongOrd)
|
||||
return strong_ordering::equivalent;
|
||||
else
|
||||
static_assert(_Cat != _Cat, "unhandled case");
|
||||
}
|
||||
} // namespace __comp_detail
|
||||
|
||||
// [cmp.common], common comparison category type
|
||||
template<class... _Ts>
|
||||
struct _LIBCPP_TEMPLATE_VIS common_comparison_category {
|
||||
using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
|
||||
};
|
||||
|
||||
template<class... _Ts>
|
||||
using common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
|
||||
|
||||
// [cmp.alg], comparison algorithms
|
||||
// TODO: unimplemented
|
||||
template<class _Tp> constexpr strong_ordering strong_order(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr strong_equality strong_equal(const _Tp& __lhs, const _Tp& __rhs);
|
||||
template<class _Tp> constexpr weak_equality weak_equal(const _Tp& __lhs, const _Tp& __rhs);
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 17
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_COMPARE
|
1496
libcxx/include/complex
Normal file
1496
libcxx/include/complex
Normal file
File diff suppressed because it is too large
Load Diff
37
libcxx/include/complex.h
Normal file
37
libcxx/include/complex.h
Normal file
@ -0,0 +1,37 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- complex.h --------------------------------===//
|
||||
//
|
||||
// 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_COMPLEX_H
|
||||
#define _LIBCPP_COMPLEX_H
|
||||
|
||||
/*
|
||||
complex.h synopsis
|
||||
|
||||
#include <ccomplex>
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <ccomplex>
|
||||
|
||||
#else // __cplusplus
|
||||
|
||||
#include_next <complex.h>
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _LIBCPP_COMPLEX_H
|
269
libcxx/include/condition_variable
Normal file
269
libcxx/include/condition_variable
Normal file
@ -0,0 +1,269 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------- condition_variable ----------------------------===//
|
||||
//
|
||||
// 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_CONDITION_VARIABLE
|
||||
#define _LIBCPP_CONDITION_VARIABLE
|
||||
|
||||
/*
|
||||
condition_variable synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
enum class cv_status { no_timeout, timeout };
|
||||
|
||||
class condition_variable
|
||||
{
|
||||
public:
|
||||
condition_variable();
|
||||
~condition_variable();
|
||||
|
||||
condition_variable(const condition_variable&) = delete;
|
||||
condition_variable& operator=(const condition_variable&) = delete;
|
||||
|
||||
void notify_one() noexcept;
|
||||
void notify_all() noexcept;
|
||||
|
||||
void wait(unique_lock<mutex>& lock);
|
||||
template <class Predicate>
|
||||
void wait(unique_lock<mutex>& lock, Predicate pred);
|
||||
|
||||
template <class Clock, class Duration>
|
||||
cv_status
|
||||
wait_until(unique_lock<mutex>& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time);
|
||||
|
||||
template <class Clock, class Duration, class Predicate>
|
||||
bool
|
||||
wait_until(unique_lock<mutex>& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time,
|
||||
Predicate pred);
|
||||
|
||||
template <class Rep, class Period>
|
||||
cv_status
|
||||
wait_for(unique_lock<mutex>& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time);
|
||||
|
||||
template <class Rep, class Period, class Predicate>
|
||||
bool
|
||||
wait_for(unique_lock<mutex>& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time,
|
||||
Predicate pred);
|
||||
|
||||
typedef pthread_cond_t* native_handle_type;
|
||||
native_handle_type native_handle();
|
||||
};
|
||||
|
||||
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
|
||||
|
||||
class condition_variable_any
|
||||
{
|
||||
public:
|
||||
condition_variable_any();
|
||||
~condition_variable_any();
|
||||
|
||||
condition_variable_any(const condition_variable_any&) = delete;
|
||||
condition_variable_any& operator=(const condition_variable_any&) = delete;
|
||||
|
||||
void notify_one() noexcept;
|
||||
void notify_all() noexcept;
|
||||
|
||||
template <class Lock>
|
||||
void wait(Lock& lock);
|
||||
template <class Lock, class Predicate>
|
||||
void wait(Lock& lock, Predicate pred);
|
||||
|
||||
template <class Lock, class Clock, class Duration>
|
||||
cv_status
|
||||
wait_until(Lock& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time);
|
||||
|
||||
template <class Lock, class Clock, class Duration, class Predicate>
|
||||
bool
|
||||
wait_until(Lock& lock,
|
||||
const chrono::time_point<Clock, Duration>& abs_time,
|
||||
Predicate pred);
|
||||
|
||||
template <class Lock, class Rep, class Period>
|
||||
cv_status
|
||||
wait_for(Lock& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time);
|
||||
|
||||
template <class Lock, class Rep, class Period, class Predicate>
|
||||
bool
|
||||
wait_for(Lock& lock,
|
||||
const chrono::duration<Rep, Period>& rel_time,
|
||||
Predicate pred);
|
||||
};
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <__mutex_base>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_THREADS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
class _LIBCPP_TYPE_VIS condition_variable_any
|
||||
{
|
||||
condition_variable __cv_;
|
||||
shared_ptr<mutex> __mut_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
condition_variable_any();
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void notify_one() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void notify_all() _NOEXCEPT;
|
||||
|
||||
template <class _Lock>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
void wait(_Lock& __lock);
|
||||
template <class _Lock, class _Predicate>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void wait(_Lock& __lock, _Predicate __pred);
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration>
|
||||
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
cv_status
|
||||
wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t);
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration, class _Predicate>
|
||||
bool
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t,
|
||||
_Predicate __pred);
|
||||
|
||||
template <class _Lock, class _Rep, class _Period>
|
||||
cv_status
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d);
|
||||
|
||||
template <class _Lock, class _Rep, class _Period, class _Predicate>
|
||||
bool
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred);
|
||||
};
|
||||
|
||||
inline
|
||||
condition_variable_any::condition_variable_any()
|
||||
: __mut_(make_shared<mutex>()) {}
|
||||
|
||||
inline
|
||||
void
|
||||
condition_variable_any::notify_one() _NOEXCEPT
|
||||
{
|
||||
{lock_guard<mutex> __lx(*__mut_);}
|
||||
__cv_.notify_one();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
condition_variable_any::notify_all() _NOEXCEPT
|
||||
{
|
||||
{lock_guard<mutex> __lx(*__mut_);}
|
||||
__cv_.notify_all();
|
||||
}
|
||||
|
||||
struct __lock_external
|
||||
{
|
||||
template <class _Lock>
|
||||
void operator()(_Lock* __m) {__m->lock();}
|
||||
};
|
||||
|
||||
template <class _Lock>
|
||||
void
|
||||
condition_variable_any::wait(_Lock& __lock)
|
||||
{
|
||||
shared_ptr<mutex> __mut = __mut_;
|
||||
unique_lock<mutex> __lk(*__mut);
|
||||
__lock.unlock();
|
||||
unique_ptr<_Lock, __lock_external> __lxx(&__lock);
|
||||
lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
|
||||
__cv_.wait(__lk);
|
||||
} // __mut_.unlock(), __lock.lock()
|
||||
|
||||
template <class _Lock, class _Predicate>
|
||||
inline
|
||||
void
|
||||
condition_variable_any::wait(_Lock& __lock, _Predicate __pred)
|
||||
{
|
||||
while (!__pred())
|
||||
wait(__lock);
|
||||
}
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration>
|
||||
cv_status
|
||||
condition_variable_any::wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
shared_ptr<mutex> __mut = __mut_;
|
||||
unique_lock<mutex> __lk(*__mut);
|
||||
__lock.unlock();
|
||||
unique_ptr<_Lock, __lock_external> __lxx(&__lock);
|
||||
lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
|
||||
return __cv_.wait_until(__lk, __t);
|
||||
} // __mut_.unlock(), __lock.lock()
|
||||
|
||||
template <class _Lock, class _Clock, class _Duration, class _Predicate>
|
||||
inline
|
||||
bool
|
||||
condition_variable_any::wait_until(_Lock& __lock,
|
||||
const chrono::time_point<_Clock, _Duration>& __t,
|
||||
_Predicate __pred)
|
||||
{
|
||||
while (!__pred())
|
||||
if (wait_until(__lock, __t) == cv_status::timeout)
|
||||
return __pred();
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Lock, class _Rep, class _Period>
|
||||
inline
|
||||
cv_status
|
||||
condition_variable_any::wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d)
|
||||
{
|
||||
return wait_until(__lock, chrono::steady_clock::now() + __d);
|
||||
}
|
||||
|
||||
template <class _Lock, class _Rep, class _Period, class _Predicate>
|
||||
inline
|
||||
bool
|
||||
condition_variable_any::wait_for(_Lock& __lock,
|
||||
const chrono::duration<_Rep, _Period>& __d,
|
||||
_Predicate __pred)
|
||||
{
|
||||
return wait_until(__lock, chrono::steady_clock::now() + __d,
|
||||
_VSTD::move(__pred));
|
||||
}
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_THREADS
|
||||
|
||||
#endif // _LIBCPP_CONDITION_VARIABLE
|
48
libcxx/include/csetjmp
Normal file
48
libcxx/include/csetjmp
Normal file
@ -0,0 +1,48 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- csetjmp ----------------------------------===//
|
||||
//
|
||||
// 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_CSETJMP
|
||||
#define _LIBCPP_CSETJMP
|
||||
|
||||
/*
|
||||
csetjmp synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
setjmp
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
jmp_buf
|
||||
|
||||
void longjmp(jmp_buf env, int val);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <setjmp.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::jmp_buf;
|
||||
using ::longjmp;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSETJMP
|
58
libcxx/include/csignal
Normal file
58
libcxx/include/csignal
Normal file
@ -0,0 +1,58 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- csignal ----------------------------------===//
|
||||
//
|
||||
// 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_CSIGNAL
|
||||
#define _LIBCPP_CSIGNAL
|
||||
|
||||
/*
|
||||
csignal synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
SIG_DFL
|
||||
SIG_ERR
|
||||
SIG_IGN
|
||||
SIGABRT
|
||||
SIGFPE
|
||||
SIGILL
|
||||
SIGINT
|
||||
SIGSEGV
|
||||
SIGTERM
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
sig_atomic_t
|
||||
|
||||
void (*signal(int sig, void (*func)(int)))(int);
|
||||
int raise(int sig);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <signal.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::sig_atomic_t;
|
||||
using ::signal;
|
||||
using ::raise;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSIGNAL
|
48
libcxx/include/cstdarg
Normal file
48
libcxx/include/cstdarg
Normal file
@ -0,0 +1,48 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cstdarg ----------------------------------===//
|
||||
//
|
||||
// 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_CSTDARG
|
||||
#define _LIBCPP_CSTDARG
|
||||
|
||||
/*
|
||||
cstdarg synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
type va_arg(va_list ap, type);
|
||||
void va_copy(va_list dest, va_list src); // C99
|
||||
void va_end(va_list ap);
|
||||
void va_start(va_list ap, parmN);
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
va_list
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::va_list;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSTDARG
|
32
libcxx/include/cstdbool
Normal file
32
libcxx/include/cstdbool
Normal file
@ -0,0 +1,32 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cstdbool ---------------------------------===//
|
||||
//
|
||||
// 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_CSTDBOOL
|
||||
#define _LIBCPP_CSTDBOOL
|
||||
|
||||
/*
|
||||
cstdbool synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
__bool_true_false_are_defined
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#undef __bool_true_false_are_defined
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif // _LIBCPP_CSTDBOOL
|
114
libcxx/include/cstddef
Normal file
114
libcxx/include/cstddef
Normal file
@ -0,0 +1,114 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cstddef ----------------------------------===//
|
||||
//
|
||||
// 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_CSTDDEF
|
||||
#define _LIBCPP_CSTDDEF
|
||||
|
||||
/*
|
||||
cstddef synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
offsetof(type,member-designator)
|
||||
NULL
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
ptrdiff_t
|
||||
size_t
|
||||
max_align_t
|
||||
nullptr_t
|
||||
byte // C++17
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <version>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
|
||||
#include_next <stddef.h>
|
||||
#include <__nullptr>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::ptrdiff_t;
|
||||
using ::size_t;
|
||||
|
||||
#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
|
||||
defined(__DEFINED_max_align_t) || defined(__NetBSD__)
|
||||
// Re-use the compiler's <stddef.h> max_align_t where possible.
|
||||
using ::max_align_t;
|
||||
#else
|
||||
typedef long double max_align_t;
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
namespace std // purposefully not versioned
|
||||
{
|
||||
enum class byte : unsigned char {};
|
||||
|
||||
constexpr byte operator| (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = __lhs | __rhs; }
|
||||
|
||||
constexpr byte operator& (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = __lhs & __rhs; }
|
||||
|
||||
constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = __lhs ^ __rhs; }
|
||||
|
||||
constexpr byte operator~ (byte __b) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
~static_cast<unsigned int>(__b)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include <type_traits> // rest of byte
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CSTDDEF
|
191
libcxx/include/cstdint
Normal file
191
libcxx/include/cstdint
Normal file
@ -0,0 +1,191 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cstdint ----------------------------------===//
|
||||
//
|
||||
// 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_CSTDINT
|
||||
#define _LIBCPP_CSTDINT
|
||||
|
||||
/*
|
||||
cstdint synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
INT8_MIN
|
||||
INT16_MIN
|
||||
INT32_MIN
|
||||
INT64_MIN
|
||||
|
||||
INT8_MAX
|
||||
INT16_MAX
|
||||
INT32_MAX
|
||||
INT64_MAX
|
||||
|
||||
UINT8_MAX
|
||||
UINT16_MAX
|
||||
UINT32_MAX
|
||||
UINT64_MAX
|
||||
|
||||
INT_LEAST8_MIN
|
||||
INT_LEAST16_MIN
|
||||
INT_LEAST32_MIN
|
||||
INT_LEAST64_MIN
|
||||
|
||||
INT_LEAST8_MAX
|
||||
INT_LEAST16_MAX
|
||||
INT_LEAST32_MAX
|
||||
INT_LEAST64_MAX
|
||||
|
||||
UINT_LEAST8_MAX
|
||||
UINT_LEAST16_MAX
|
||||
UINT_LEAST32_MAX
|
||||
UINT_LEAST64_MAX
|
||||
|
||||
INT_FAST8_MIN
|
||||
INT_FAST16_MIN
|
||||
INT_FAST32_MIN
|
||||
INT_FAST64_MIN
|
||||
|
||||
INT_FAST8_MAX
|
||||
INT_FAST16_MAX
|
||||
INT_FAST32_MAX
|
||||
INT_FAST64_MAX
|
||||
|
||||
UINT_FAST8_MAX
|
||||
UINT_FAST16_MAX
|
||||
UINT_FAST32_MAX
|
||||
UINT_FAST64_MAX
|
||||
|
||||
INTPTR_MIN
|
||||
INTPTR_MAX
|
||||
UINTPTR_MAX
|
||||
|
||||
INTMAX_MIN
|
||||
INTMAX_MAX
|
||||
|
||||
UINTMAX_MAX
|
||||
|
||||
PTRDIFF_MIN
|
||||
PTRDIFF_MAX
|
||||
|
||||
SIG_ATOMIC_MIN
|
||||
SIG_ATOMIC_MAX
|
||||
|
||||
SIZE_MAX
|
||||
|
||||
WCHAR_MIN
|
||||
WCHAR_MAX
|
||||
|
||||
WINT_MIN
|
||||
WINT_MAX
|
||||
|
||||
INT8_C(value)
|
||||
INT16_C(value)
|
||||
INT32_C(value)
|
||||
INT64_C(value)
|
||||
|
||||
UINT8_C(value)
|
||||
UINT16_C(value)
|
||||
UINT32_C(value)
|
||||
UINT64_C(value)
|
||||
|
||||
INTMAX_C(value)
|
||||
UINTMAX_C(value)
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
int8_t
|
||||
int16_t
|
||||
int32_t
|
||||
int64_t
|
||||
|
||||
uint8_t
|
||||
uint16_t
|
||||
uint32_t
|
||||
uint64_t
|
||||
|
||||
int_least8_t
|
||||
int_least16_t
|
||||
int_least32_t
|
||||
int_least64_t
|
||||
|
||||
uint_least8_t
|
||||
uint_least16_t
|
||||
uint_least32_t
|
||||
uint_least64_t
|
||||
|
||||
int_fast8_t
|
||||
int_fast16_t
|
||||
int_fast32_t
|
||||
int_fast64_t
|
||||
|
||||
uint_fast8_t
|
||||
uint_fast16_t
|
||||
uint_fast32_t
|
||||
uint_fast64_t
|
||||
|
||||
intptr_t
|
||||
uintptr_t
|
||||
|
||||
intmax_t
|
||||
uintmax_t
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using::int8_t;
|
||||
using::int16_t;
|
||||
using::int32_t;
|
||||
using::int64_t;
|
||||
|
||||
using::uint8_t;
|
||||
using::uint16_t;
|
||||
using::uint32_t;
|
||||
using::uint64_t;
|
||||
|
||||
using::int_least8_t;
|
||||
using::int_least16_t;
|
||||
using::int_least32_t;
|
||||
using::int_least64_t;
|
||||
|
||||
using::uint_least8_t;
|
||||
using::uint_least16_t;
|
||||
using::uint_least32_t;
|
||||
using::uint_least64_t;
|
||||
|
||||
using::int_fast8_t;
|
||||
using::int_fast16_t;
|
||||
using::int_fast32_t;
|
||||
using::int_fast64_t;
|
||||
|
||||
using::uint_fast8_t;
|
||||
using::uint_fast16_t;
|
||||
using::uint_fast32_t;
|
||||
using::uint_fast64_t;
|
||||
|
||||
using::intptr_t;
|
||||
using::uintptr_t;
|
||||
|
||||
using::intmax_t;
|
||||
using::uintmax_t;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSTDINT
|
172
libcxx/include/cstdio
Normal file
172
libcxx/include/cstdio
Normal file
@ -0,0 +1,172 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- cstdio ----------------------------------===//
|
||||
//
|
||||
// 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_CSTDIO
|
||||
#define _LIBCPP_CSTDIO
|
||||
|
||||
/*
|
||||
cstdio synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
BUFSIZ
|
||||
EOF
|
||||
FILENAME_MAX
|
||||
FOPEN_MAX
|
||||
L_tmpnam
|
||||
NULL
|
||||
SEEK_CUR
|
||||
SEEK_END
|
||||
SEEK_SET
|
||||
TMP_MAX
|
||||
_IOFBF
|
||||
_IOLBF
|
||||
_IONBF
|
||||
stderr
|
||||
stdin
|
||||
stdout
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
FILE
|
||||
fpos_t
|
||||
size_t
|
||||
|
||||
int remove(const char* filename);
|
||||
int rename(const char* old, const char* new);
|
||||
FILE* tmpfile(void);
|
||||
char* tmpnam(char* s);
|
||||
int fclose(FILE* stream);
|
||||
int fflush(FILE* stream);
|
||||
FILE* fopen(const char* restrict filename, const char* restrict mode);
|
||||
FILE* freopen(const char* restrict filename, const char * restrict mode,
|
||||
FILE * restrict stream);
|
||||
void setbuf(FILE* restrict stream, char* restrict buf);
|
||||
int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
|
||||
int fprintf(FILE* restrict stream, const char* restrict format, ...);
|
||||
int fscanf(FILE* restrict stream, const char * restrict format, ...);
|
||||
int printf(const char* restrict format, ...);
|
||||
int scanf(const char* restrict format, ...);
|
||||
int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
|
||||
int sprintf(char* restrict s, const char* restrict format, ...);
|
||||
int sscanf(const char* restrict s, const char* restrict format, ...);
|
||||
int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
|
||||
int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
|
||||
int vprintf(const char* restrict format, va_list arg);
|
||||
int vscanf(const char* restrict format, va_list arg); // C99
|
||||
int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
|
||||
va_list arg);
|
||||
int vsprintf(char* restrict s, const char* restrict format, va_list arg);
|
||||
int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
|
||||
int fgetc(FILE* stream);
|
||||
char* fgets(char* restrict s, int n, FILE* restrict stream);
|
||||
int fputc(int c, FILE* stream);
|
||||
int fputs(const char* restrict s, FILE* restrict stream);
|
||||
int getc(FILE* stream);
|
||||
int getchar(void);
|
||||
char* gets(char* s); // removed in C++14
|
||||
int putc(int c, FILE* stream);
|
||||
int putchar(int c);
|
||||
int puts(const char* s);
|
||||
int ungetc(int c, FILE* stream);
|
||||
size_t fread(void* restrict ptr, size_t size, size_t nmemb,
|
||||
FILE* restrict stream);
|
||||
size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
|
||||
FILE* restrict stream);
|
||||
int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
|
||||
int fseek(FILE* stream, long offset, int whence);
|
||||
int fsetpos(FILE*stream, const fpos_t* pos);
|
||||
long ftell(FILE* stream);
|
||||
void rewind(FILE* stream);
|
||||
void clearerr(FILE* stream);
|
||||
int feof(FILE* stream);
|
||||
int ferror(FILE* stream);
|
||||
void perror(const char* s);
|
||||
|
||||
} // std
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::FILE;
|
||||
using ::fpos_t;
|
||||
using ::size_t;
|
||||
|
||||
using ::fclose;
|
||||
using ::fflush;
|
||||
using ::setbuf;
|
||||
using ::setvbuf;
|
||||
using ::fprintf;
|
||||
using ::fscanf;
|
||||
using ::snprintf;
|
||||
using ::sprintf;
|
||||
using ::sscanf;
|
||||
using ::vfprintf;
|
||||
using ::vfscanf;
|
||||
using ::vsscanf;
|
||||
using ::vsnprintf;
|
||||
using ::vsprintf;
|
||||
using ::fgetc;
|
||||
using ::fgets;
|
||||
using ::fputc;
|
||||
using ::fputs;
|
||||
using ::getc;
|
||||
using ::putc;
|
||||
using ::ungetc;
|
||||
using ::fread;
|
||||
using ::fwrite;
|
||||
using ::fgetpos;
|
||||
using ::fseek;
|
||||
using ::fsetpos;
|
||||
using ::ftell;
|
||||
using ::rewind;
|
||||
using ::clearerr;
|
||||
using ::feof;
|
||||
using ::ferror;
|
||||
using ::perror;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
using ::fopen;
|
||||
using ::freopen;
|
||||
using ::remove;
|
||||
using ::rename;
|
||||
using ::tmpfile;
|
||||
using ::tmpnam;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDIN
|
||||
using ::getchar;
|
||||
#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_MSVCRT)
|
||||
using ::gets;
|
||||
#endif
|
||||
using ::scanf;
|
||||
using ::vscanf;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
using ::printf;
|
||||
using ::putchar;
|
||||
using ::puts;
|
||||
using ::vprintf;
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSTDIO
|
164
libcxx/include/cstdlib
Normal file
164
libcxx/include/cstdlib
Normal file
@ -0,0 +1,164 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cstdlib ----------------------------------===//
|
||||
//
|
||||
// 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_CSTDLIB
|
||||
#define _LIBCPP_CSTDLIB
|
||||
|
||||
/*
|
||||
cstdlib synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
EXIT_FAILURE
|
||||
EXIT_SUCCESS
|
||||
MB_CUR_MAX
|
||||
NULL
|
||||
RAND_MAX
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
size_t
|
||||
div_t
|
||||
ldiv_t
|
||||
lldiv_t // C99
|
||||
|
||||
double atof (const char* nptr);
|
||||
int atoi (const char* nptr);
|
||||
long atol (const char* nptr);
|
||||
long long atoll(const char* nptr); // C99
|
||||
double strtod (const char* restrict nptr, char** restrict endptr);
|
||||
float strtof (const char* restrict nptr, char** restrict endptr); // C99
|
||||
long double strtold (const char* restrict nptr, char** restrict endptr); // C99
|
||||
long strtol (const char* restrict nptr, char** restrict endptr, int base);
|
||||
long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
|
||||
unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
|
||||
unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
|
||||
int rand(void);
|
||||
void srand(unsigned int seed);
|
||||
void* calloc(size_t nmemb, size_t size);
|
||||
void free(void* ptr);
|
||||
void* malloc(size_t size);
|
||||
void* realloc(void* ptr, size_t size);
|
||||
void abort(void);
|
||||
int atexit(void (*func)(void));
|
||||
void exit(int status);
|
||||
void _Exit(int status);
|
||||
char* getenv(const char* name);
|
||||
int system(const char* string);
|
||||
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
void qsort(void* base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
int abs( int j);
|
||||
long abs( long j);
|
||||
long long abs(long long j); // C++0X
|
||||
long labs( long j);
|
||||
long long llabs(long long j); // C99
|
||||
div_t div( int numer, int denom);
|
||||
ldiv_t div( long numer, long denom);
|
||||
lldiv_t div(long long numer, long long denom); // C++0X
|
||||
ldiv_t ldiv( long numer, long denom);
|
||||
lldiv_t lldiv(long long numer, long long denom); // C99
|
||||
int mblen(const char* s, size_t n);
|
||||
int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
|
||||
int wctomb(char* s, wchar_t wchar);
|
||||
size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
|
||||
size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
|
||||
int at_quick_exit(void (*func)(void)) // C++11
|
||||
void quick_exit(int status); // C++11
|
||||
void *aligned_alloc(size_t alignment, size_t size); // C11
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
#define _LIBCPP_UNREACHABLE() _VSTD::abort()
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::size_t;
|
||||
using ::div_t;
|
||||
using ::ldiv_t;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::lldiv_t;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::atof;
|
||||
using ::atoi;
|
||||
using ::atol;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::atoll;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::strtod;
|
||||
using ::strtof;
|
||||
using ::strtold;
|
||||
using ::strtol;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::strtoll;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::strtoul;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::strtoull;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::rand;
|
||||
using ::srand;
|
||||
using ::calloc;
|
||||
using ::free;
|
||||
using ::malloc;
|
||||
using ::realloc;
|
||||
using ::abort;
|
||||
using ::atexit;
|
||||
using ::exit;
|
||||
using ::_Exit;
|
||||
#ifndef _LIBCPP_WINDOWS_STORE_APP
|
||||
using ::getenv;
|
||||
using ::system;
|
||||
#endif
|
||||
using ::bsearch;
|
||||
using ::qsort;
|
||||
using ::abs;
|
||||
using ::labs;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::llabs;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::div;
|
||||
using ::ldiv;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::lldiv;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::mblen;
|
||||
using ::mbtowc;
|
||||
using ::wctomb;
|
||||
using ::mbstowcs;
|
||||
using ::wcstombs;
|
||||
#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
|
||||
using ::at_quick_exit;
|
||||
using ::quick_exit;
|
||||
#endif
|
||||
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
|
||||
using ::aligned_alloc;
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSTDLIB
|
97
libcxx/include/cstring
Normal file
97
libcxx/include/cstring
Normal file
@ -0,0 +1,97 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cstring ----------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_CSTRING
|
||||
#define _LIBCPP_CSTRING
|
||||
|
||||
/*
|
||||
cstring synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
NULL
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
size_t
|
||||
|
||||
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
|
||||
void* memmove(void* s1, const void* s2, size_t n);
|
||||
char* strcpy (char* restrict s1, const char* restrict s2);
|
||||
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
|
||||
char* strcat (char* restrict s1, const char* restrict s2);
|
||||
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
|
||||
int memcmp(const void* s1, const void* s2, size_t n);
|
||||
int strcmp (const char* s1, const char* s2);
|
||||
int strncmp(const char* s1, const char* s2, size_t n);
|
||||
int strcoll(const char* s1, const char* s2);
|
||||
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
|
||||
const void* memchr(const void* s, int c, size_t n);
|
||||
void* memchr( void* s, int c, size_t n);
|
||||
const char* strchr(const char* s, int c);
|
||||
char* strchr( char* s, int c);
|
||||
size_t strcspn(const char* s1, const char* s2);
|
||||
const char* strpbrk(const char* s1, const char* s2);
|
||||
char* strpbrk( char* s1, const char* s2);
|
||||
const char* strrchr(const char* s, int c);
|
||||
char* strrchr( char* s, int c);
|
||||
size_t strspn(const char* s1, const char* s2);
|
||||
const char* strstr(const char* s1, const char* s2);
|
||||
char* strstr( char* s1, const char* s2);
|
||||
char* strtok(char* restrict s1, const char* restrict s2);
|
||||
void* memset(void* s, int c, size_t n);
|
||||
char* strerror(int errnum);
|
||||
size_t strlen(const char* s);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::size_t;
|
||||
using ::memcpy;
|
||||
using ::memmove;
|
||||
using ::strcpy;
|
||||
using ::strncpy;
|
||||
using ::strcat;
|
||||
using ::strncat;
|
||||
using ::memcmp;
|
||||
using ::strcmp;
|
||||
using ::strncmp;
|
||||
using ::strcoll;
|
||||
using ::strxfrm;
|
||||
using ::memchr;
|
||||
using ::strchr;
|
||||
using ::strcspn;
|
||||
using ::strpbrk;
|
||||
using ::strrchr;
|
||||
using ::strspn;
|
||||
using ::strstr;
|
||||
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
using ::strtok;
|
||||
#endif
|
||||
using ::memset;
|
||||
using ::strerror;
|
||||
using ::strlen;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CSTRING
|
29
libcxx/include/ctgmath
Normal file
29
libcxx/include/ctgmath
Normal file
@ -0,0 +1,29 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- ctgmath -----------------------------------===//
|
||||
//
|
||||
// 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_CTGMATH
|
||||
#define _LIBCPP_CTGMATH
|
||||
|
||||
/*
|
||||
ctgmath synopsis
|
||||
|
||||
#include <ccomplex>
|
||||
#include <cmath>
|
||||
|
||||
*/
|
||||
|
||||
#include <ccomplex>
|
||||
#include <cmath>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CTGMATH
|
82
libcxx/include/ctime
Normal file
82
libcxx/include/ctime
Normal file
@ -0,0 +1,82 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- ctime -----------------------------------===//
|
||||
//
|
||||
// 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_CTIME
|
||||
#define _LIBCPP_CTIME
|
||||
|
||||
/*
|
||||
ctime synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
NULL
|
||||
CLOCKS_PER_SEC
|
||||
TIME_UTC // C++17
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
clock_t
|
||||
size_t
|
||||
time_t
|
||||
tm
|
||||
timespec // C++17
|
||||
|
||||
clock_t clock();
|
||||
double difftime(time_t time1, time_t time0);
|
||||
time_t mktime(tm* timeptr);
|
||||
time_t time(time_t* timer);
|
||||
char* asctime(const tm* timeptr);
|
||||
char* ctime(const time_t* timer);
|
||||
tm* gmtime(const time_t* timer);
|
||||
tm* localtime(const time_t* timer);
|
||||
size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
|
||||
const tm* restrict timeptr);
|
||||
int timespec_get( struct timespec *ts, int base); // C++17
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <time.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::clock_t;
|
||||
using ::size_t;
|
||||
using ::time_t;
|
||||
using ::tm;
|
||||
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
|
||||
using ::timespec;
|
||||
#endif
|
||||
using ::clock;
|
||||
using ::difftime;
|
||||
using ::mktime;
|
||||
using ::time;
|
||||
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||
using ::asctime;
|
||||
using ::ctime;
|
||||
using ::gmtime;
|
||||
using ::localtime;
|
||||
#endif
|
||||
using ::strftime;
|
||||
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
|
||||
using ::timespec_get;
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CTIME
|
60
libcxx/include/ctype.h
Normal file
60
libcxx/include/ctype.h
Normal file
@ -0,0 +1,60 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- ctype.h ---------------------------------===//
|
||||
//
|
||||
// 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_CTYPE_H
|
||||
#define _LIBCPP_CTYPE_H
|
||||
|
||||
/*
|
||||
ctype.h synopsis
|
||||
|
||||
int isalnum(int c);
|
||||
int isalpha(int c);
|
||||
int isblank(int c); // C99
|
||||
int iscntrl(int c);
|
||||
int isdigit(int c);
|
||||
int isgraph(int c);
|
||||
int islower(int c);
|
||||
int isprint(int c);
|
||||
int ispunct(int c);
|
||||
int isspace(int c);
|
||||
int isupper(int c);
|
||||
int isxdigit(int c);
|
||||
int tolower(int c);
|
||||
int toupper(int c);
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include_next <ctype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#undef isalnum
|
||||
#undef isalpha
|
||||
#undef isblank
|
||||
#undef iscntrl
|
||||
#undef isdigit
|
||||
#undef isgraph
|
||||
#undef islower
|
||||
#undef isprint
|
||||
#undef ispunct
|
||||
#undef isspace
|
||||
#undef isupper
|
||||
#undef isxdigit
|
||||
#undef tolower
|
||||
#undef toupper
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_CTYPE_H
|
193
libcxx/include/cwchar
Normal file
193
libcxx/include/cwchar
Normal file
@ -0,0 +1,193 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cwchar -----------------------------------===//
|
||||
//
|
||||
// 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_CWCHAR
|
||||
#define _LIBCPP_CWCHAR
|
||||
|
||||
/*
|
||||
cwchar synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
NULL
|
||||
WCHAR_MAX
|
||||
WCHAR_MIN
|
||||
WEOF
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
mbstate_t
|
||||
size_t
|
||||
tm
|
||||
wint_t
|
||||
|
||||
int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
|
||||
int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
|
||||
int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
|
||||
int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
|
||||
int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
|
||||
int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
|
||||
int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
|
||||
int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
|
||||
int vwprintf(const wchar_t* restrict format, va_list arg);
|
||||
int vwscanf(const wchar_t* restrict format, va_list arg); // C99
|
||||
int wprintf(const wchar_t* restrict format, ...);
|
||||
int wscanf(const wchar_t* restrict format, ...);
|
||||
wint_t fgetwc(FILE* stream);
|
||||
wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
|
||||
wint_t fputwc(wchar_t c, FILE* stream);
|
||||
int fputws(const wchar_t* restrict s, FILE* restrict stream);
|
||||
int fwide(FILE* stream, int mode);
|
||||
wint_t getwc(FILE* stream);
|
||||
wint_t getwchar();
|
||||
wint_t putwc(wchar_t c, FILE* stream);
|
||||
wint_t putwchar(wchar_t c);
|
||||
wint_t ungetwc(wint_t c, FILE* stream);
|
||||
double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
|
||||
float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
|
||||
long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
|
||||
long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
|
||||
long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
|
||||
unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
|
||||
unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
|
||||
wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
|
||||
wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
|
||||
wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
|
||||
wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
|
||||
int wcscmp(const wchar_t* s1, const wchar_t* s2);
|
||||
int wcscoll(const wchar_t* s1, const wchar_t* s2);
|
||||
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
|
||||
size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
|
||||
const wchar_t* wcschr(const wchar_t* s, wchar_t c);
|
||||
wchar_t* wcschr( wchar_t* s, wchar_t c);
|
||||
size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
|
||||
size_t wcslen(const wchar_t* s);
|
||||
const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
|
||||
wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
|
||||
const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
|
||||
wchar_t* wcsrchr( wchar_t* s, wchar_t c);
|
||||
size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
|
||||
const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
|
||||
wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
|
||||
wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
|
||||
const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
|
||||
wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
|
||||
int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
|
||||
wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
|
||||
wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
|
||||
wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
|
||||
size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
|
||||
const tm* restrict timeptr);
|
||||
wint_t btowc(int c);
|
||||
int wctob(wint_t c);
|
||||
int mbsinit(const mbstate_t* ps);
|
||||
size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
|
||||
size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
|
||||
size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
|
||||
size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
|
||||
mbstate_t* restrict ps);
|
||||
size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
|
||||
mbstate_t* restrict ps);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cwctype>
|
||||
#include <wchar.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::mbstate_t;
|
||||
using ::size_t;
|
||||
using ::tm;
|
||||
using ::wint_t;
|
||||
using ::FILE;
|
||||
using ::fwprintf;
|
||||
using ::fwscanf;
|
||||
using ::swprintf;
|
||||
using ::vfwprintf;
|
||||
using ::vswprintf;
|
||||
using ::swscanf;
|
||||
using ::vfwscanf;
|
||||
using ::vswscanf;
|
||||
using ::fgetwc;
|
||||
using ::fgetws;
|
||||
using ::fputwc;
|
||||
using ::fputws;
|
||||
using ::fwide;
|
||||
using ::getwc;
|
||||
using ::putwc;
|
||||
using ::ungetwc;
|
||||
using ::wcstod;
|
||||
using ::wcstof;
|
||||
using ::wcstold;
|
||||
using ::wcstol;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::wcstoll;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::wcstoul;
|
||||
#ifndef _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::wcstoull;
|
||||
#endif // _LIBCPP_HAS_NO_LONG_LONG
|
||||
using ::wcscpy;
|
||||
using ::wcsncpy;
|
||||
using ::wcscat;
|
||||
using ::wcsncat;
|
||||
using ::wcscmp;
|
||||
using ::wcscoll;
|
||||
using ::wcsncmp;
|
||||
using ::wcsxfrm;
|
||||
using ::wcschr;
|
||||
using ::wcspbrk;
|
||||
using ::wcsrchr;
|
||||
using ::wcsstr;
|
||||
using ::wmemchr;
|
||||
using ::wcscspn;
|
||||
using ::wcslen;
|
||||
using ::wcsspn;
|
||||
using ::wcstok;
|
||||
using ::wmemcmp;
|
||||
using ::wmemcpy;
|
||||
using ::wmemmove;
|
||||
using ::wmemset;
|
||||
using ::wcsftime;
|
||||
using ::btowc;
|
||||
using ::wctob;
|
||||
using ::mbsinit;
|
||||
using ::mbrlen;
|
||||
using ::mbrtowc;
|
||||
using ::wcrtomb;
|
||||
using ::mbsrtowcs;
|
||||
using ::wcsrtombs;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDIN
|
||||
using ::getwchar;
|
||||
using ::vwscanf;
|
||||
using ::wscanf;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
using ::putwchar;
|
||||
using ::vwprintf;
|
||||
using ::wprintf;
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CWCHAR
|
87
libcxx/include/cwctype
Normal file
87
libcxx/include/cwctype
Normal file
@ -0,0 +1,87 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- cwctype ----------------------------------===//
|
||||
//
|
||||
// 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_CWCTYPE
|
||||
#define _LIBCPP_CWCTYPE
|
||||
|
||||
/*
|
||||
cwctype synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
WEOF
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
Types:
|
||||
|
||||
wint_t
|
||||
wctrans_t
|
||||
wctype_t
|
||||
|
||||
int iswalnum(wint_t wc);
|
||||
int iswalpha(wint_t wc);
|
||||
int iswblank(wint_t wc); // C99
|
||||
int iswcntrl(wint_t wc);
|
||||
int iswdigit(wint_t wc);
|
||||
int iswgraph(wint_t wc);
|
||||
int iswlower(wint_t wc);
|
||||
int iswprint(wint_t wc);
|
||||
int iswpunct(wint_t wc);
|
||||
int iswspace(wint_t wc);
|
||||
int iswupper(wint_t wc);
|
||||
int iswxdigit(wint_t wc);
|
||||
int iswctype(wint_t wc, wctype_t desc);
|
||||
wctype_t wctype(const char* property);
|
||||
wint_t towlower(wint_t wc);
|
||||
wint_t towupper(wint_t wc);
|
||||
wint_t towctrans(wint_t wc, wctrans_t desc);
|
||||
wctrans_t wctrans(const char* property);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cctype>
|
||||
#include <wctype.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
using ::wint_t;
|
||||
using ::wctrans_t;
|
||||
using ::wctype_t;
|
||||
using ::iswalnum;
|
||||
using ::iswalpha;
|
||||
using ::iswblank;
|
||||
using ::iswcntrl;
|
||||
using ::iswdigit;
|
||||
using ::iswgraph;
|
||||
using ::iswlower;
|
||||
using ::iswprint;
|
||||
using ::iswpunct;
|
||||
using ::iswspace;
|
||||
using ::iswupper;
|
||||
using ::iswxdigit;
|
||||
using ::iswctype;
|
||||
using ::wctype;
|
||||
using ::towlower;
|
||||
using ::towupper;
|
||||
using ::towctrans;
|
||||
using ::wctrans;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CWCTYPE
|
2953
libcxx/include/deque
Normal file
2953
libcxx/include/deque
Normal file
File diff suppressed because it is too large
Load Diff
398
libcxx/include/errno.h
Normal file
398
libcxx/include/errno.h
Normal file
@ -0,0 +1,398 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- errno.h -----------------------------------===//
|
||||
//
|
||||
// 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_ERRNO_H
|
||||
#define _LIBCPP_ERRNO_H
|
||||
|
||||
/*
|
||||
errno.h synopsis
|
||||
|
||||
Macros:
|
||||
|
||||
EDOM
|
||||
EILSEQ // C99
|
||||
ERANGE
|
||||
errno
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include_next <errno.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
|
||||
|
||||
#ifdef ELAST
|
||||
|
||||
static const int __elast1 = ELAST+1;
|
||||
static const int __elast2 = ELAST+2;
|
||||
|
||||
#else
|
||||
|
||||
static const int __elast1 = 104;
|
||||
static const int __elast2 = 105;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENOTRECOVERABLE
|
||||
|
||||
#define EOWNERDEAD __elast1
|
||||
|
||||
#ifdef ELAST
|
||||
#undef ELAST
|
||||
#define ELAST EOWNERDEAD
|
||||
#endif
|
||||
|
||||
#elif defined(EOWNERDEAD)
|
||||
|
||||
#define ENOTRECOVERABLE __elast1
|
||||
#ifdef ELAST
|
||||
#undef ELAST
|
||||
#define ELAST ENOTRECOVERABLE
|
||||
#endif
|
||||
|
||||
#else // defined(EOWNERDEAD)
|
||||
|
||||
#define EOWNERDEAD __elast1
|
||||
#define ENOTRECOVERABLE __elast2
|
||||
#ifdef ELAST
|
||||
#undef ELAST
|
||||
#define ELAST ENOTRECOVERABLE
|
||||
#endif
|
||||
|
||||
#endif // defined(EOWNERDEAD)
|
||||
|
||||
#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
|
||||
|
||||
// supply errno values likely to be missing, particularly on Windows
|
||||
|
||||
#ifndef EAFNOSUPPORT
|
||||
#define EAFNOSUPPORT 9901
|
||||
#endif
|
||||
|
||||
#ifndef EADDRINUSE
|
||||
#define EADDRINUSE 9902
|
||||
#endif
|
||||
|
||||
#ifndef EADDRNOTAVAIL
|
||||
#define EADDRNOTAVAIL 9903
|
||||
#endif
|
||||
|
||||
#ifndef EISCONN
|
||||
#define EISCONN 9904
|
||||
#endif
|
||||
|
||||
#ifndef EBADMSG
|
||||
#define EBADMSG 9905
|
||||
#endif
|
||||
|
||||
#ifndef ECONNABORTED
|
||||
#define ECONNABORTED 9906
|
||||
#endif
|
||||
|
||||
#ifndef EALREADY
|
||||
#define EALREADY 9907
|
||||
#endif
|
||||
|
||||
#ifndef ECONNREFUSED
|
||||
#define ECONNREFUSED 9908
|
||||
#endif
|
||||
|
||||
#ifndef ECONNRESET
|
||||
#define ECONNRESET 9909
|
||||
#endif
|
||||
|
||||
#ifndef EDESTADDRREQ
|
||||
#define EDESTADDRREQ 9910
|
||||
#endif
|
||||
|
||||
#ifndef EHOSTUNREACH
|
||||
#define EHOSTUNREACH 9911
|
||||
#endif
|
||||
|
||||
#ifndef EIDRM
|
||||
#define EIDRM 9912
|
||||
#endif
|
||||
|
||||
#ifndef EMSGSIZE
|
||||
#define EMSGSIZE 9913
|
||||
#endif
|
||||
|
||||
#ifndef ENETDOWN
|
||||
#define ENETDOWN 9914
|
||||
#endif
|
||||
|
||||
#ifndef ENETRESET
|
||||
#define ENETRESET 9915
|
||||
#endif
|
||||
|
||||
#ifndef ENETUNREACH
|
||||
#define ENETUNREACH 9916
|
||||
#endif
|
||||
|
||||
#ifndef ENOBUFS
|
||||
#define ENOBUFS 9917
|
||||
#endif
|
||||
|
||||
#ifndef ENOLINK
|
||||
#define ENOLINK 9918
|
||||
#endif
|
||||
|
||||
#ifndef ENODATA
|
||||
#define ENODATA 9919
|
||||
#endif
|
||||
|
||||
#ifndef ENOMSG
|
||||
#define ENOMSG 9920
|
||||
#endif
|
||||
|
||||
#ifndef ENOPROTOOPT
|
||||
#define ENOPROTOOPT 9921
|
||||
#endif
|
||||
|
||||
#ifndef ENOSR
|
||||
#define ENOSR 9922
|
||||
#endif
|
||||
|
||||
#ifndef ENOTSOCK
|
||||
#define ENOTSOCK 9923
|
||||
#endif
|
||||
|
||||
#ifndef ENOSTR
|
||||
#define ENOSTR 9924
|
||||
#endif
|
||||
|
||||
#ifndef ENOTCONN
|
||||
#define ENOTCONN 9925
|
||||
#endif
|
||||
|
||||
#ifndef ENOTSUP
|
||||
#define ENOTSUP 9926
|
||||
#endif
|
||||
|
||||
#ifndef ECANCELED
|
||||
#define ECANCELED 9927
|
||||
#endif
|
||||
|
||||
#ifndef EINPROGRESS
|
||||
#define EINPROGRESS 9928
|
||||
#endif
|
||||
|
||||
#ifndef EOPNOTSUPP
|
||||
#define EOPNOTSUPP 9929
|
||||
#endif
|
||||
|
||||
#ifndef EWOULDBLOCK
|
||||
#define EWOULDBLOCK 9930
|
||||
#endif
|
||||
|
||||
#ifndef EOWNERDEAD
|
||||
#define EOWNERDEAD 9931
|
||||
#endif
|
||||
|
||||
#ifndef EPROTO
|
||||
#define EPROTO 9932
|
||||
#endif
|
||||
|
||||
#ifndef EPROTONOSUPPORT
|
||||
#define EPROTONOSUPPORT 9933
|
||||
#endif
|
||||
|
||||
#ifndef ENOTRECOVERABLE
|
||||
#define ENOTRECOVERABLE 9934
|
||||
#endif
|
||||
|
||||
#ifndef ETIME
|
||||
#define ETIME 9935
|
||||
#endif
|
||||
|
||||
#ifndef ETXTBSY
|
||||
#define ETXTBSY 9936
|
||||
#endif
|
||||
|
||||
#ifndef ETIMEDOUT
|
||||
#define ETIMEDOUT 9938
|
||||
#endif
|
||||
|
||||
#ifndef ELOOP
|
||||
#define ELOOP 9939
|
||||
#endif
|
||||
|
||||
#ifndef EOVERFLOW
|
||||
#define EOVERFLOW 9940
|
||||
#endif
|
||||
|
||||
#ifndef EPROTOTYPE
|
||||
#define EPROTOTYPE 9941
|
||||
#endif
|
||||
|
||||
#ifndef ENOSYS
|
||||
#define ENOSYS 9942
|
||||
#endif
|
||||
|
||||
#ifndef EINVAL
|
||||
#define EINVAL 9943
|
||||
#endif
|
||||
|
||||
#ifndef ERANGE
|
||||
#define ERANGE 9944
|
||||
#endif
|
||||
|
||||
#ifndef EILSEQ
|
||||
#define EILSEQ 9945
|
||||
#endif
|
||||
|
||||
// Windows Mobile doesn't appear to define these:
|
||||
|
||||
#ifndef E2BIG
|
||||
#define E2BIG 9946
|
||||
#endif
|
||||
|
||||
#ifndef EDOM
|
||||
#define EDOM 9947
|
||||
#endif
|
||||
|
||||
#ifndef EFAULT
|
||||
#define EFAULT 9948
|
||||
#endif
|
||||
|
||||
#ifndef EBADF
|
||||
#define EBADF 9949
|
||||
#endif
|
||||
|
||||
#ifndef EPIPE
|
||||
#define EPIPE 9950
|
||||
#endif
|
||||
|
||||
#ifndef EXDEV
|
||||
#define EXDEV 9951
|
||||
#endif
|
||||
|
||||
#ifndef EBUSY
|
||||
#define EBUSY 9952
|
||||
#endif
|
||||
|
||||
#ifndef ENOTEMPTY
|
||||
#define ENOTEMPTY 9953
|
||||
#endif
|
||||
|
||||
#ifndef ENOEXEC
|
||||
#define ENOEXEC 9954
|
||||
#endif
|
||||
|
||||
#ifndef EEXIST
|
||||
#define EEXIST 9955
|
||||
#endif
|
||||
|
||||
#ifndef EFBIG
|
||||
#define EFBIG 9956
|
||||
#endif
|
||||
|
||||
#ifndef ENAMETOOLONG
|
||||
#define ENAMETOOLONG 9957
|
||||
#endif
|
||||
|
||||
#ifndef ENOTTY
|
||||
#define ENOTTY 9958
|
||||
#endif
|
||||
|
||||
#ifndef EINTR
|
||||
#define EINTR 9959
|
||||
#endif
|
||||
|
||||
#ifndef ESPIPE
|
||||
#define ESPIPE 9960
|
||||
#endif
|
||||
|
||||
#ifndef EIO
|
||||
#define EIO 9961
|
||||
#endif
|
||||
|
||||
#ifndef EISDIR
|
||||
#define EISDIR 9962
|
||||
#endif
|
||||
|
||||
#ifndef ECHILD
|
||||
#define ECHILD 9963
|
||||
#endif
|
||||
|
||||
#ifndef ENOLCK
|
||||
#define ENOLCK 9964
|
||||
#endif
|
||||
|
||||
#ifndef ENOSPC
|
||||
#define ENOSPC 9965
|
||||
#endif
|
||||
|
||||
#ifndef ENXIO
|
||||
#define ENXIO 9966
|
||||
#endif
|
||||
|
||||
#ifndef ENODEV
|
||||
#define ENODEV 9967
|
||||
#endif
|
||||
|
||||
#ifndef ENOENT
|
||||
#define ENOENT 9968
|
||||
#endif
|
||||
|
||||
#ifndef ESRCH
|
||||
#define ESRCH 9969
|
||||
#endif
|
||||
|
||||
#ifndef ENOTDIR
|
||||
#define ENOTDIR 9970
|
||||
#endif
|
||||
|
||||
#ifndef ENOMEM
|
||||
#define ENOMEM 9971
|
||||
#endif
|
||||
|
||||
#ifndef EPERM
|
||||
#define EPERM 9972
|
||||
#endif
|
||||
|
||||
#ifndef EACCES
|
||||
#define EACCES 9973
|
||||
#endif
|
||||
|
||||
#ifndef EROFS
|
||||
#define EROFS 9974
|
||||
#endif
|
||||
|
||||
#ifndef EDEADLK
|
||||
#define EDEADLK 9975
|
||||
#endif
|
||||
|
||||
#ifndef EAGAIN
|
||||
#define EAGAIN 9976
|
||||
#endif
|
||||
|
||||
#ifndef ENFILE
|
||||
#define ENFILE 9977
|
||||
#endif
|
||||
|
||||
#ifndef EMFILE
|
||||
#define EMFILE 9978
|
||||
#endif
|
||||
|
||||
#ifndef EMLINK
|
||||
#define EMLINK 9979
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _LIBCPP_ERRNO_H
|
338
libcxx/include/exception
Normal file
338
libcxx/include/exception
Normal file
@ -0,0 +1,338 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- exception ---------------------------------===//
|
||||
//
|
||||
// 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_EXCEPTION
|
||||
#define _LIBCPP_EXCEPTION
|
||||
|
||||
/*
|
||||
exception synopsis
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
class exception
|
||||
{
|
||||
public:
|
||||
exception() noexcept;
|
||||
exception(const exception&) noexcept;
|
||||
exception& operator=(const exception&) noexcept;
|
||||
virtual ~exception() noexcept;
|
||||
virtual const char* what() const noexcept;
|
||||
};
|
||||
|
||||
class bad_exception
|
||||
: public exception
|
||||
{
|
||||
public:
|
||||
bad_exception() noexcept;
|
||||
bad_exception(const bad_exception&) noexcept;
|
||||
bad_exception& operator=(const bad_exception&) noexcept;
|
||||
virtual ~bad_exception() noexcept;
|
||||
virtual const char* what() const noexcept;
|
||||
};
|
||||
|
||||
typedef void (*unexpected_handler)();
|
||||
unexpected_handler set_unexpected(unexpected_handler f ) noexcept;
|
||||
unexpected_handler get_unexpected() noexcept;
|
||||
[[noreturn]] void unexpected();
|
||||
|
||||
typedef void (*terminate_handler)();
|
||||
terminate_handler set_terminate(terminate_handler f ) noexcept;
|
||||
terminate_handler get_terminate() noexcept;
|
||||
[[noreturn]] void terminate() noexcept;
|
||||
|
||||
bool uncaught_exception() noexcept;
|
||||
int uncaught_exceptions() noexcept; // C++17
|
||||
|
||||
typedef unspecified exception_ptr;
|
||||
|
||||
exception_ptr current_exception() noexcept;
|
||||
void rethrow_exception [[noreturn]] (exception_ptr p);
|
||||
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
|
||||
|
||||
class nested_exception
|
||||
{
|
||||
public:
|
||||
nested_exception() noexcept;
|
||||
nested_exception(const nested_exception&) noexcept = default;
|
||||
nested_exception& operator=(const nested_exception&) noexcept = default;
|
||||
virtual ~nested_exception() = default;
|
||||
|
||||
// access functions
|
||||
[[noreturn]] void rethrow_nested() const;
|
||||
exception_ptr nested_ptr() const noexcept;
|
||||
};
|
||||
|
||||
template <class T> [[noreturn]] void throw_with_nested(T&& t);
|
||||
template <class E> void rethrow_if_nested(const E& e);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <type_traits>
|
||||
#include <version>
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#include <vcruntime_exception.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
|
||||
class _LIBCPP_EXCEPTION_ABI exception
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
|
||||
virtual ~exception() _NOEXCEPT;
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI bad_exception
|
||||
: public exception
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
|
||||
virtual ~bad_exception() _NOEXCEPT;
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14 \
|
||||
|| defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \
|
||||
|| defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
typedef void (*unexpected_handler)();
|
||||
_LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
|
||||
_LIBCPP_FUNC_VIS unexpected_handler get_unexpected() _NOEXCEPT;
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void unexpected();
|
||||
#endif
|
||||
|
||||
typedef void (*terminate_handler)();
|
||||
_LIBCPP_FUNC_VIS terminate_handler set_terminate(terminate_handler) _NOEXCEPT;
|
||||
_LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT;
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT;
|
||||
_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_exceptions() _NOEXCEPT;
|
||||
|
||||
class _LIBCPP_TYPE_VIS exception_ptr;
|
||||
|
||||
_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
|
||||
|
||||
#ifndef _LIBCPP_ABI_MICROSOFT
|
||||
|
||||
class _LIBCPP_TYPE_VIS exception_ptr
|
||||
{
|
||||
void* __ptr_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY exception_ptr() _NOEXCEPT : __ptr_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
|
||||
|
||||
exception_ptr(const exception_ptr&) _NOEXCEPT;
|
||||
exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
|
||||
~exception_ptr() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
|
||||
{return __ptr_ != nullptr;}
|
||||
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
|
||||
{return __x.__ptr_ == __y.__ptr_;}
|
||||
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
|
||||
{return !(__x == __y);}
|
||||
|
||||
friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
|
||||
friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
|
||||
};
|
||||
|
||||
template<class _Ep>
|
||||
_LIBCPP_INLINE_VISIBILITY exception_ptr
|
||||
make_exception_ptr(_Ep __e) _NOEXCEPT
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
throw __e;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return current_exception();
|
||||
}
|
||||
#else
|
||||
((void)__e);
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
#else // _LIBCPP_ABI_MICROSOFT
|
||||
|
||||
class _LIBCPP_TYPE_VIS exception_ptr
|
||||
{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-private-field"
|
||||
#endif
|
||||
void* __ptr1_;
|
||||
void* __ptr2_;
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
public:
|
||||
exception_ptr() _NOEXCEPT;
|
||||
exception_ptr(nullptr_t) _NOEXCEPT;
|
||||
exception_ptr(const exception_ptr& __other) _NOEXCEPT;
|
||||
exception_ptr& operator=(const exception_ptr& __other) _NOEXCEPT;
|
||||
exception_ptr& operator=(nullptr_t) _NOEXCEPT;
|
||||
~exception_ptr() _NOEXCEPT;
|
||||
_LIBCPP_EXPLICIT operator bool() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
_LIBCPP_FUNC_VIS
|
||||
bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT;
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
|
||||
{return !(__x == __y);}
|
||||
|
||||
_LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr);
|
||||
_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p);
|
||||
|
||||
// This is a built-in template function which automagically extracts the required
|
||||
// information.
|
||||
template <class _E> void *__GetExceptionInfo(_E);
|
||||
|
||||
template<class _Ep>
|
||||
_LIBCPP_INLINE_VISIBILITY exception_ptr
|
||||
make_exception_ptr(_Ep __e) _NOEXCEPT
|
||||
{
|
||||
return __copy_exception_ptr(_VSTD::addressof(__e), __GetExceptionInfo(__e));
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_ABI_MICROSOFT
|
||||
// nested_exception
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI nested_exception
|
||||
{
|
||||
exception_ptr __ptr_;
|
||||
public:
|
||||
nested_exception() _NOEXCEPT;
|
||||
// nested_exception(const nested_exception&) noexcept = default;
|
||||
// nested_exception& operator=(const nested_exception&) noexcept = default;
|
||||
virtual ~nested_exception() _NOEXCEPT;
|
||||
|
||||
// access functions
|
||||
_LIBCPP_NORETURN void rethrow_nested() const;
|
||||
_LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const _NOEXCEPT {return __ptr_;}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __nested
|
||||
: public _Tp,
|
||||
public nested_exception
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {}
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
template <class _Tp, class _Up, bool>
|
||||
struct __throw_with_nested;
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __throw_with_nested<_Tp, _Up, true> {
|
||||
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__do_throw(_Tp&& __t)
|
||||
#else
|
||||
__do_throw (_Tp& __t)
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
{
|
||||
throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __throw_with_nested<_Tp, _Up, false> {
|
||||
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
__do_throw(_Tp&& __t)
|
||||
#else
|
||||
__do_throw (_Tp& __t)
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
{
|
||||
throw _VSTD::forward<_Tp>(__t);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_NORETURN
|
||||
void
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
throw_with_nested(_Tp&& __t)
|
||||
#else
|
||||
throw_with_nested (_Tp& __t)
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
typedef typename decay<_Tp>::type _Up;
|
||||
static_assert( is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible");
|
||||
__throw_with_nested<_Tp, _Up,
|
||||
is_class<_Up>::value &&
|
||||
!is_base_of<nested_exception, _Up>::value &&
|
||||
!__libcpp_is_final<_Up>::value>::
|
||||
__do_throw(_VSTD::forward<_Tp>(__t));
|
||||
#else
|
||||
((void)__t);
|
||||
// FIXME: Make this abort
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _From, class _To>
|
||||
struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT(
|
||||
is_polymorphic<_From>::value &&
|
||||
(!is_base_of<_To, _From>::value ||
|
||||
is_convertible<const _From*, const _To*>::value)) {};
|
||||
|
||||
template <class _Ep>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
rethrow_if_nested(const _Ep& __e,
|
||||
typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
|
||||
{
|
||||
const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e));
|
||||
if (__nep)
|
||||
__nep->rethrow_nested();
|
||||
}
|
||||
|
||||
template <class _Ep>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
rethrow_if_nested(const _Ep&,
|
||||
typename enable_if<!__can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
|
||||
{
|
||||
}
|
||||
|
||||
} // std
|
||||
|
||||
#endif // _LIBCPP_EXCEPTION
|
74
libcxx/include/experimental/__config
Normal file
74
libcxx/include/experimental/__config
Normal file
@ -0,0 +1,74 @@
|
||||
// -*- 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 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
|
||||
|
||||
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
|
||||
} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
|
||||
|
||||
// TODO: support more targets
|
||||
#if defined(__AVX__)
|
||||
#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
|
||||
#else
|
||||
#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
|
||||
#endif
|
||||
|
||||
#endif
|
90
libcxx/include/experimental/__memory
Normal file
90
libcxx/include/experimental/__memory
Normal 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 */
|
60
libcxx/include/experimental/algorithm
Normal file
60
libcxx/include/experimental/algorithm
Normal file
@ -0,0 +1,60 @@
|
||||
// -*- 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);
|
||||
|
||||
// sample removed because it's now part of C++17
|
||||
|
||||
} // 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; }
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */
|
21
libcxx/include/experimental/any
Normal file
21
libcxx/include/experimental/any
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------------- any ----------------------------------===//
|
||||
//
|
||||
// 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_ANY
|
||||
#define _LIBCPP_EXPERIMENTAL_ANY
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/any> has been removed. Use <any> instead.")
|
||||
#else
|
||||
# warning "<experimental/any> has been removed. Use <any> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_ANY
|
21
libcxx/include/experimental/chrono
Normal file
21
libcxx/include/experimental/chrono
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===---------------------------- chrono ----------------------------------===//
|
||||
//
|
||||
// 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_CHRONO
|
||||
#define _LIBCPP_EXPERIMENTAL_CHRONO
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/chrono> has been removed. Use <chrono> instead.")
|
||||
#else
|
||||
# warning "<experimental/chrono> has been removed. Use <chrono> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_CHRONO
|
336
libcxx/include/experimental/coroutine
Normal file
336
libcxx/include/experimental/coroutine
Normal file
@ -0,0 +1,336 @@
|
||||
// -*- 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_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR coroutine_handle() _NOEXCEPT : __handle_(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR coroutine_handle(nullptr_t) _NOEXCEPT : __handle_(nullptr) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
coroutine_handle& operator=(nullptr_t) _NOEXCEPT {
|
||||
__handle_ = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR void* address() const _NOEXCEPT { return __handle_; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return __handle_; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void operator()() { resume(); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
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_INLINE_VISIBILITY
|
||||
void destroy() {
|
||||
_LIBCPP_ASSERT(__is_suspended(),
|
||||
"destroy() can only be called on suspended coroutines");
|
||||
__builtin_coro_destroy(__handle_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool done() const {
|
||||
_LIBCPP_ASSERT(__is_suspended(),
|
||||
"done() can only be called on suspended coroutines");
|
||||
return __builtin_coro_done(__handle_);
|
||||
}
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static coroutine_handle from_address(void* __addr) _NOEXCEPT {
|
||||
coroutine_handle __tmp;
|
||||
__tmp.__handle_ = __addr;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
// FIXME: Should from_address(nullptr) be allowed?
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
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_INLINE_VISIBILITY
|
||||
bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return __x.address() == __y.address();
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return !(__x == __y);
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return less<void*>()(__x.address(), __y.address());
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return __y < __x;
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(coroutine_handle<> __x, coroutine_handle<> __y) _NOEXCEPT {
|
||||
return !(__x > __y);
|
||||
}
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
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_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT : _Base() {}
|
||||
_LIBCPP_INLINE_VISIBILITY 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 *static_cast<_Promise*>(
|
||||
__builtin_coro_promise(this->__handle_, _LIBCPP_ALIGNOF(_Promise), false));
|
||||
}
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
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_INLINE_VISIBILITY
|
||||
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_INLINE_VISIBILITY
|
||||
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)),
|
||||
_LIBCPP_ALIGNOF(_Promise), true);
|
||||
return __tmp;
|
||||
}
|
||||
};
|
||||
|
||||
#if __has_builtin(__builtin_coro_noop)
|
||||
struct noop_coroutine_promise {};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise>
|
||||
: public coroutine_handle<> {
|
||||
using _Base = coroutine_handle<>;
|
||||
using _Promise = noop_coroutine_promise;
|
||||
public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Promise& promise() const {
|
||||
return *static_cast<_Promise*>(
|
||||
__builtin_coro_promise(this->__handle_, _LIBCPP_ALIGNOF(_Promise), false));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }
|
||||
_LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
friend coroutine_handle<noop_coroutine_promise> noop_coroutine() _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY coroutine_handle() _NOEXCEPT {
|
||||
this->__handle_ = __builtin_coro_noop();
|
||||
}
|
||||
};
|
||||
|
||||
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
noop_coroutine_handle noop_coroutine() _NOEXCEPT {
|
||||
return noop_coroutine_handle();
|
||||
}
|
||||
#endif // __has_builtin(__builtin_coro_noop)
|
||||
|
||||
struct _LIBCPP_TYPE_VIS suspend_never {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool await_ready() const _NOEXCEPT { return true; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_resume() const _NOEXCEPT {}
|
||||
};
|
||||
|
||||
struct _LIBCPP_TYPE_VIS suspend_always {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool await_ready() const _NOEXCEPT { return false; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void await_suspend(coroutine_handle<>) const _NOEXCEPT {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
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 */
|
47
libcxx/include/experimental/deque
Normal file
47
libcxx/include/experimental/deque
Normal 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 */
|
257
libcxx/include/experimental/filesystem
Normal file
257
libcxx/include/experimental/filesystem
Normal file
@ -0,0 +1,257 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- filesystem -------------------------------===//
|
||||
//
|
||||
// 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_FILESYSTEM
|
||||
#define _LIBCPP_EXPERIMENTAL_FILESYSTEM
|
||||
/*
|
||||
filesystem synopsis
|
||||
|
||||
namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
|
||||
|
||||
class path;
|
||||
|
||||
void swap(path& lhs, path& rhs) noexcept;
|
||||
size_t hash_value(const path& p) noexcept;
|
||||
|
||||
bool operator==(const path& lhs, const path& rhs) noexcept;
|
||||
bool operator!=(const path& lhs, const path& rhs) noexcept;
|
||||
bool operator< (const path& lhs, const path& rhs) noexcept;
|
||||
bool operator<=(const path& lhs, const path& rhs) noexcept;
|
||||
bool operator> (const path& lhs, const path& rhs) noexcept;
|
||||
bool operator>=(const path& lhs, const path& rhs) noexcept;
|
||||
|
||||
path operator/ (const path& lhs, const path& rhs);
|
||||
|
||||
// fs.path.io operators are friends of path.
|
||||
template <class charT, class traits>
|
||||
friend basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os, const path& p);
|
||||
|
||||
template <class charT, class traits>
|
||||
friend basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, path& p);
|
||||
|
||||
template <class Source>
|
||||
path u8path(const Source& source);
|
||||
template <class InputIterator>
|
||||
path u8path(InputIterator first, InputIterator last);
|
||||
|
||||
class filesystem_error;
|
||||
class directory_entry;
|
||||
|
||||
class directory_iterator;
|
||||
|
||||
// enable directory_iterator range-based for statements
|
||||
directory_iterator begin(directory_iterator iter) noexcept;
|
||||
directory_iterator end(const directory_iterator&) noexcept;
|
||||
|
||||
class recursive_directory_iterator;
|
||||
|
||||
// enable recursive_directory_iterator range-based for statements
|
||||
recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept;
|
||||
recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
|
||||
|
||||
class file_status;
|
||||
|
||||
struct space_info
|
||||
{
|
||||
uintmax_t capacity;
|
||||
uintmax_t free;
|
||||
uintmax_t available;
|
||||
};
|
||||
|
||||
enum class file_type;
|
||||
enum class perms;
|
||||
enum class perm_options;
|
||||
enum class copy_options;
|
||||
enum class directory_options;
|
||||
|
||||
typedef chrono::time_point<trivial-clock> file_time_type;
|
||||
|
||||
// operational functions
|
||||
|
||||
path absolute(const path& p);
|
||||
path absolute(const path& p, error_code &ec);
|
||||
|
||||
path canonical(const path& p);
|
||||
path canonical(const path& p, error_code& ec);
|
||||
|
||||
void copy(const path& from, const path& to);
|
||||
void copy(const path& from, const path& to, error_code& ec);
|
||||
void copy(const path& from, const path& to, copy_options options);
|
||||
void copy(const path& from, const path& to, copy_options options,
|
||||
error_code& ec);
|
||||
|
||||
bool copy_file(const path& from, const path& to);
|
||||
bool copy_file(const path& from, const path& to, error_code& ec);
|
||||
bool copy_file(const path& from, const path& to, copy_options option);
|
||||
bool copy_file(const path& from, const path& to, copy_options option,
|
||||
error_code& ec);
|
||||
|
||||
void copy_symlink(const path& existing_symlink, const path& new_symlink);
|
||||
void copy_symlink(const path& existing_symlink, const path& new_symlink,
|
||||
error_code& ec) noexcept;
|
||||
|
||||
bool create_directories(const path& p);
|
||||
bool create_directories(const path& p, error_code& ec);
|
||||
|
||||
bool create_directory(const path& p);
|
||||
bool create_directory(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool create_directory(const path& p, const path& attributes);
|
||||
bool create_directory(const path& p, const path& attributes,
|
||||
error_code& ec) noexcept;
|
||||
|
||||
void create_directory_symlink(const path& to, const path& new_symlink);
|
||||
void create_directory_symlink(const path& to, const path& new_symlink,
|
||||
error_code& ec) noexcept;
|
||||
|
||||
void create_hard_link(const path& to, const path& new_hard_link);
|
||||
void create_hard_link(const path& to, const path& new_hard_link,
|
||||
error_code& ec) noexcept;
|
||||
|
||||
void create_symlink(const path& to, const path& new_symlink);
|
||||
void create_symlink(const path& to, const path& new_symlink,
|
||||
error_code& ec) noexcept;
|
||||
|
||||
path current_path();
|
||||
path current_path(error_code& ec);
|
||||
void current_path(const path& p);
|
||||
void current_path(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool exists(file_status s) noexcept;
|
||||
bool exists(const path& p);
|
||||
bool exists(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool equivalent(const path& p1, const path& p2);
|
||||
bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
|
||||
|
||||
uintmax_t file_size(const path& p);
|
||||
uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
||||
|
||||
uintmax_t hard_link_count(const path& p);
|
||||
uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_block_file(file_status s) noexcept;
|
||||
bool is_block_file(const path& p);
|
||||
bool is_block_file(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_character_file(file_status s) noexcept;
|
||||
bool is_character_file(const path& p);
|
||||
bool is_character_file(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_directory(file_status s) noexcept;
|
||||
bool is_directory(const path& p);
|
||||
bool is_directory(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_empty(const path& p);
|
||||
bool is_empty(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_fifo(file_status s) noexcept;
|
||||
bool is_fifo(const path& p);
|
||||
bool is_fifo(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_other(file_status s) noexcept;
|
||||
bool is_other(const path& p);
|
||||
bool is_other(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_regular_file(file_status s) noexcept;
|
||||
bool is_regular_file(const path& p);
|
||||
bool is_regular_file(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_socket(file_status s) noexcept;
|
||||
bool is_socket(const path& p);
|
||||
bool is_socket(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool is_symlink(file_status s) noexcept;
|
||||
bool is_symlink(const path& p);
|
||||
bool is_symlink(const path& p, error_code& ec) noexcept;
|
||||
|
||||
file_time_type last_write_time(const path& p);
|
||||
file_time_type last_write_time(const path& p, error_code& ec) noexcept;
|
||||
void last_write_time(const path& p, file_time_type new_time);
|
||||
void last_write_time(const path& p, file_time_type new_time,
|
||||
error_code& ec) noexcept;
|
||||
|
||||
void permissions(const path& p, perms prms,
|
||||
perm_options opts=perm_options::replace);
|
||||
void permissions(const path& p, perms prms, error_code& ec) noexcept;
|
||||
void permissions(const path& p, perms prms, perm_options opts,
|
||||
error_code& ec);
|
||||
|
||||
path proximate(const path& p, error_code& ec);
|
||||
path proximate(const path& p, const path& base = current_path());
|
||||
path proximate(const path& p, const path& base, error_code &ec);
|
||||
|
||||
path read_symlink(const path& p);
|
||||
path read_symlink(const path& p, error_code& ec);
|
||||
|
||||
path relative(const path& p, error_code& ec);
|
||||
path relative(const path& p, const path& base=current_path());
|
||||
path relative(const path& p, const path& base, error_code& ec);
|
||||
|
||||
bool remove(const path& p);
|
||||
bool remove(const path& p, error_code& ec) noexcept;
|
||||
|
||||
uintmax_t remove_all(const path& p);
|
||||
uintmax_t remove_all(const path& p, error_code& ec);
|
||||
|
||||
void rename(const path& from, const path& to);
|
||||
void rename(const path& from, const path& to, error_code& ec) noexcept;
|
||||
|
||||
void resize_file(const path& p, uintmax_t size);
|
||||
void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept;
|
||||
|
||||
space_info space(const path& p);
|
||||
space_info space(const path& p, error_code& ec) noexcept;
|
||||
|
||||
file_status status(const path& p);
|
||||
file_status status(const path& p, error_code& ec) noexcept;
|
||||
|
||||
bool status_known(file_status s) noexcept;
|
||||
|
||||
file_status symlink_status(const path& p);
|
||||
file_status symlink_status(const path& p, error_code& ec) noexcept;
|
||||
|
||||
path temp_directory_path();
|
||||
path temp_directory_path(error_code& ec);
|
||||
|
||||
path weakly_canonical(path const& p);
|
||||
path weakly_canonical(path const& p, error_code& ec);
|
||||
|
||||
|
||||
} } } } // namespaces std::experimental::filesystem::v1
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <filesystem>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
#define __cpp_lib_experimental_filesystem 201406
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
using namespace _VSTD_FS;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
|
||||
|
||||
#endif // !_LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM
|
47
libcxx/include/experimental/forward_list
Normal file
47
libcxx/include/experimental/forward_list
Normal 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 */
|
462
libcxx/include/experimental/functional
Normal file
462
libcxx/include/experimental/functional
Normal 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::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
|
||||
typename std::__uncvref<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::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
|
||||
typename std::__uncvref<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 */
|
114
libcxx/include/experimental/iterator
Normal file
114
libcxx/include/experimental/iterator
Normal 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
|
47
libcxx/include/experimental/list
Normal file
47
libcxx/include/experimental/list
Normal 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 */
|
57
libcxx/include/experimental/map
Normal file
57
libcxx/include/experimental/map
Normal 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 */
|
427
libcxx/include/experimental/memory_resource
Normal file
427
libcxx/include/experimental/memory_resource
Normal 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_TYPE_VIS memory_resource
|
||||
{
|
||||
static const size_t __max_align = _LIBCPP_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), _LIBCPP_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), _LIBCPP_ALIGNOF(_ValueType));
|
||||
}
|
||||
|
||||
template <class _Tp, class ..._Ts>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void construct(_Tp* __p, _Ts &&... __args)
|
||||
{
|
||||
_VSTD_LFTS::__lfts_user_alloc_construct(
|
||||
__p, *this, _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, polymorphic_allocator&, _Args1...
|
||||
>::type()
|
||||
, _VSTD::move(__x)
|
||||
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
|
||||
)
|
||||
, __transform_tuple(
|
||||
typename __lfts_uses_alloc_ctor<
|
||||
_T2, polymorphic_allocator&, _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&, polymorphic_allocator&, _Args&&...>
|
||||
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>;
|
||||
return _Tup(allocator_arg, *this,
|
||||
_VSTD::get<_Idx>(_VSTD::move(__t))...);
|
||||
}
|
||||
|
||||
template <class ..._Args, size_t ..._Idx>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
tuple<_Args&&..., polymorphic_allocator&>
|
||||
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
|
||||
__tuple_indices<_Idx...>)
|
||||
{
|
||||
using _Tup = tuple<_Args&&..., polymorphic_allocator&>;
|
||||
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., *this);
|
||||
}
|
||||
|
||||
_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 = _LIBCPP_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 */
|
21
libcxx/include/experimental/numeric
Normal file
21
libcxx/include/experimental/numeric
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- 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
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/numeric> has been removed. Use <numeric> instead.")
|
||||
#else
|
||||
# warning "<experimental/numeric> has been removed. Use <numeric> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_NUMERIC
|
21
libcxx/include/experimental/optional
Normal file
21
libcxx/include/experimental/optional
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- optional ----------------------------------===//
|
||||
//
|
||||
// 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_OPTIONAL
|
||||
#define _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/optional> has been removed. Use <optional> instead.")
|
||||
#else
|
||||
# warning "<experimental/optional> has been removed. Use <optional> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL
|
579
libcxx/include/experimental/propagate_const
Normal file
579
libcxx/include/experimental/propagate_const
Normal file
@ -0,0 +1,579 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------ propagate_const -----------------------------===//
|
||||
//
|
||||
// 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_PROPAGATE_CONST
|
||||
#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
|
||||
/*
|
||||
propagate_const synopsis
|
||||
|
||||
namespace std { namespace experimental { inline namespace fundamentals_v2 {
|
||||
|
||||
// [propagate_const]
|
||||
template <class T> class propagate_const;
|
||||
|
||||
// [propagate_const.underlying], underlying pointer access
|
||||
constexpr const _Tp& _VSTD_LFTS_V2::get_underlying(const propagate_const<T>& pt) noexcept;
|
||||
constexpr T& _VSTD_LFTS_V2::get_underlying(propagate_const<T>& pt) noexcept;
|
||||
|
||||
// [propagate_const.relational], relational operators
|
||||
template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t);
|
||||
template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu);
|
||||
template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t);
|
||||
template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu);
|
||||
template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u);
|
||||
template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu);
|
||||
|
||||
// [propagate_const.algorithms], specialized algorithms
|
||||
template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below);
|
||||
|
||||
template <class T>
|
||||
class propagate_const
|
||||
{
|
||||
|
||||
public:
|
||||
typedef remove_reference_t<decltype(*declval<T&>())> element_type;
|
||||
|
||||
// [propagate_const.ctor], constructors
|
||||
constexpr propagate_const() = default;
|
||||
propagate_const(const propagate_const& p) = delete;
|
||||
constexpr propagate_const(propagate_const&& p) = default;
|
||||
template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below
|
||||
template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below
|
||||
|
||||
// [propagate_const.assignment], assignment
|
||||
propagate_const& operator=(const propagate_const& p) = delete;
|
||||
constexpr propagate_const& operator=(propagate_const&& p) = default;
|
||||
template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu);
|
||||
template <class U> constexpr propagate_const& operator=(U&& u); // see below
|
||||
|
||||
// [propagate_const.const_observers], const observers
|
||||
explicit constexpr operator bool() const;
|
||||
constexpr const element_type* operator->() const;
|
||||
constexpr operator const element_type*() const; // Not always defined
|
||||
constexpr const element_type& operator*() const;
|
||||
constexpr const element_type* get() const;
|
||||
|
||||
// [propagate_const.non_const_observers], non-const observers
|
||||
constexpr element_type* operator->();
|
||||
constexpr operator element_type*(); // Not always defined
|
||||
constexpr element_type& operator*();
|
||||
constexpr element_type* get();
|
||||
|
||||
// [propagate_const.modifiers], modifiers
|
||||
constexpr void swap(propagate_const& pt) noexcept(see below)
|
||||
|
||||
private:
|
||||
T t_; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v2
|
||||
} // namespace experimental
|
||||
|
||||
// [propagate_const.hash], hash support
|
||||
template <class T> struct hash<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
|
||||
// [propagate_const.comparison_function_objects], comparison function objects
|
||||
template <class T> struct equal_to<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct not_equal_to<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct less<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct greater<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct less_equal<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
template <class T> struct greater_equal<experimental::fundamentals_v2::propagate_const<T>>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
class propagate_const;
|
||||
|
||||
template <class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
|
||||
template <class _Up>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
_Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
|
||||
template <class _Tp>
|
||||
class propagate_const
|
||||
{
|
||||
public:
|
||||
typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type;
|
||||
|
||||
static_assert(!is_array<_Tp>::value,
|
||||
"Instantiation of propagate_const with an array type is ill-formed.");
|
||||
static_assert(!is_reference<_Tp>::value,
|
||||
"Instantiation of propagate_const with a reference type is ill-formed.");
|
||||
static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value),
|
||||
"Instantiation of propagate_const with a function-pointer type is ill-formed.");
|
||||
static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value),
|
||||
"Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
|
||||
|
||||
private:
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u)
|
||||
{
|
||||
return __u;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u)
|
||||
{
|
||||
return __get_pointer(__u.get());
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u)
|
||||
{
|
||||
return __u;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u)
|
||||
{
|
||||
return __get_pointer(__u.get());
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
struct __is_propagate_const : false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Up>
|
||||
struct __is_propagate_const<propagate_const<_Up>> : true_type
|
||||
{
|
||||
};
|
||||
|
||||
_Tp __t_;
|
||||
|
||||
public:
|
||||
|
||||
template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& ::_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
template <class _Up> friend _LIBCPP_CONSTEXPR _Up& ::_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_CONSTEXPR propagate_const() = default;
|
||||
|
||||
propagate_const(const propagate_const&) = delete;
|
||||
|
||||
_LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default;
|
||||
|
||||
template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value,bool> = true>
|
||||
explicit _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
|
||||
: __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu)))
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value,bool> = false>
|
||||
_LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
|
||||
: __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu)))
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value &&
|
||||
!__is_propagate_const<decay_t<_Up>>::value,bool> = true>
|
||||
explicit _LIBCPP_CONSTEXPR propagate_const(_Up&& __u)
|
||||
: __t_(std::forward<_Up>(__u))
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value &&
|
||||
is_constructible<_Tp, _Up&&>::value &&
|
||||
!__is_propagate_const<decay_t<_Up>>::value,bool> = false>
|
||||
_LIBCPP_CONSTEXPR propagate_const(_Up&& __u)
|
||||
: __t_(std::forward<_Up>(__u))
|
||||
{
|
||||
}
|
||||
|
||||
propagate_const& operator=(const propagate_const&) = delete;
|
||||
|
||||
_LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default;
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu)
|
||||
{
|
||||
__t_ = std::move(_VSTD_LFTS_V2::get_underlying(__pu));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>>
|
||||
_LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u)
|
||||
{
|
||||
__t_ = std::forward<_Up>(__u);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR const element_type* get() const
|
||||
{
|
||||
return __get_pointer(__t_);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR element_type* get()
|
||||
{
|
||||
return __get_pointer(__t_);
|
||||
}
|
||||
|
||||
explicit _LIBCPP_CONSTEXPR operator bool() const
|
||||
{
|
||||
return get() != nullptr;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR const element_type* operator->() const
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
template <class _Tp_ = _Tp, class _Up = enable_if_t<is_convertible<
|
||||
const _Tp_, const element_type *>::value>>
|
||||
_LIBCPP_CONSTEXPR operator const element_type *() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR const element_type& operator*() const
|
||||
{
|
||||
return *get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR element_type* operator->()
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
template <class _Tp_ = _Tp, class _Up = enable_if_t<
|
||||
is_convertible<_Tp_, element_type *>::value>>
|
||||
_LIBCPP_CONSTEXPR operator element_type *() {
|
||||
return get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR element_type& operator*()
|
||||
{
|
||||
return *get();
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
swap(__t_, __pt.__t_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) == nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt)
|
||||
{
|
||||
return nullptr == _VSTD_LFTS_V2::get_underlying(__pt);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) != nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt)
|
||||
{
|
||||
return nullptr != _VSTD_LFTS_V2::get_underlying(__pt);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) == _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) != _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) < _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) > _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) <= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt,
|
||||
const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) >= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) == __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) != __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) < __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) > __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) <= __u;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u)
|
||||
{
|
||||
return _VSTD_LFTS_V2::get_underlying(__pt) >= __u;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t == _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t != _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t < _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t > _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t <= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu)
|
||||
{
|
||||
return __t >= _VSTD_LFTS_V2::get_underlying(__pu);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
|
||||
{
|
||||
__pc1.swap(__pc2);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT
|
||||
{
|
||||
return __pt.__t_;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT
|
||||
{
|
||||
return __pt.__t_;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_V2
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
struct hash<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef size_t result_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type;
|
||||
|
||||
size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const
|
||||
{
|
||||
return std::hash<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct equal_to<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct not_equal_to<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::not_equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct less<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::less<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct greater<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::greater<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct less_equal<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::less_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct greater_equal<experimental::fundamentals_v2::propagate_const<_Tp>>
|
||||
{
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
|
||||
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
|
||||
|
||||
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
|
||||
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
|
||||
{
|
||||
return std::greater_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
|
||||
}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
|
||||
|
21
libcxx/include/experimental/ratio
Normal file
21
libcxx/include/experimental/ratio
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------- ratio ----------------------------------===//
|
||||
//
|
||||
// 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_RATIO
|
||||
#define _LIBCPP_EXPERIMENTAL_RATIO
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/ratio> has been removed. Use <ratio> instead.")
|
||||
#else
|
||||
# warning "<experimental/ratio> has been removed. Use <ratio> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_RATIO
|
62
libcxx/include/experimental/regex
Normal file
62
libcxx/include/experimental/regex
Normal 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 */
|
57
libcxx/include/experimental/set
Normal file
57
libcxx/include/experimental/set
Normal file
@ -0,0 +1,57 @@
|
||||
// -*- 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_SET
|
||||
#define _LIBCPP_EXPERIMENTAL_SET
|
||||
/*
|
||||
experimental/set synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class Key, class T, class Compare = less<Key>>
|
||||
using set = std::set<Key, T, Compare,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
template <class Key, class T, class Compare = less<Key>>
|
||||
using multiset = std::multiset<Key, T, Compare,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <set>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _Value, class _Compare = less<_Value>>
|
||||
using set = _VSTD::set<_Value, _Compare,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
template <class _Value, class _Compare = less<_Value>>
|
||||
using multiset = _VSTD::multiset<_Value, _Compare,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_SET */
|
1570
libcxx/include/experimental/simd
Normal file
1570
libcxx/include/experimental/simd
Normal file
File diff suppressed because it is too large
Load Diff
62
libcxx/include/experimental/string
Normal file
62
libcxx/include/experimental/string
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- string ----------------------------------===//
|
||||
//
|
||||
// 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_STRING
|
||||
#define _LIBCPP_EXPERIMENTAL_STRING
|
||||
/*
|
||||
experimental/string synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
// basic_string using polymorphic allocator in namespace pmr
|
||||
template <class charT, class traits = char_traits<charT>>
|
||||
using basic_string =
|
||||
std::basic_string<charT, traits, polymorphic_allocator<charT>>;
|
||||
|
||||
// basic_string typedef names using polymorphic allocator in namespace
|
||||
// std::experimental::pmr
|
||||
typedef basic_string<char> string;
|
||||
typedef basic_string<char16_t> u16string;
|
||||
typedef basic_string<char32_t> u32string;
|
||||
typedef basic_string<wchar_t> wstring;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <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 _CharT, class _Traits = char_traits<_CharT>>
|
||||
using basic_string =
|
||||
_VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
|
||||
|
||||
typedef basic_string<char> string;
|
||||
typedef basic_string<char16_t> u16string;
|
||||
typedef basic_string<char32_t> u32string;
|
||||
typedef basic_string<wchar_t> wstring;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_STRING */
|
21
libcxx/include/experimental/string_view
Normal file
21
libcxx/include/experimental/string_view
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------ string_view ---------------------------------===//
|
||||
//
|
||||
// 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_STRING_VIEW
|
||||
#define _LIBCPP_EXPERIMENTAL_STRING_VIEW
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/string_view> has been removed. Use <string_view> instead.")
|
||||
#else
|
||||
# warning "<experimental/string_view> has been removed. Use <string_view> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_STRING_VIEW
|
21
libcxx/include/experimental/system_error
Normal file
21
libcxx/include/experimental/system_error
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- system_error ------------------------------===//
|
||||
//
|
||||
// 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_SYSTEM_ERROR
|
||||
#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/system_error> has been removed. Use <system_error> instead.")
|
||||
#else
|
||||
# warning "<experimental/system_error> has been removed. Use <system_error> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
|
21
libcxx/include/experimental/tuple
Normal file
21
libcxx/include/experimental/tuple
Normal file
@ -0,0 +1,21 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------- tuple ----------------------------------===//
|
||||
//
|
||||
// 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_TUPLE
|
||||
#define _LIBCPP_EXPERIMENTAL_TUPLE
|
||||
|
||||
#include <__config>
|
||||
|
||||
#ifdef _LIBCPP_WARNING
|
||||
_LIBCPP_WARNING("<experimental/tuple> has been removed. Use <tuple> instead.")
|
||||
#else
|
||||
# warning "<experimental/tuple> has been removed. Use <tuple> instead."
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_TUPLE
|
155
libcxx/include/experimental/type_traits
Normal file
155
libcxx/include/experimental/type_traits
Normal file
@ -0,0 +1,155 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- type_traits -------------------------------===//
|
||||
//
|
||||
// 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_TYPE_TRAITS
|
||||
#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
|
||||
|
||||
/**
|
||||
experimental/type_traits synopsis
|
||||
|
||||
// C++1y
|
||||
#include <type_traits>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
template <class> class invocation_type; // not defined
|
||||
template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
|
||||
template <class> class raw_invocation_type; // not defined
|
||||
template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;
|
||||
|
||||
template <class T>
|
||||
using invocation_type_t = typename invocation_type<T>::type;
|
||||
template <class T>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<T>::type;
|
||||
|
||||
// 3.3.4, Detection idiom
|
||||
template <class...> using void_t = void;
|
||||
|
||||
struct nonesuch {
|
||||
nonesuch() = delete;
|
||||
~nonesuch() = delete;
|
||||
nonesuch(nonesuch const&) = delete;
|
||||
void operator=(nonesuch const&) = delete;
|
||||
};
|
||||
|
||||
template <template<class...> class Op, class... Args>
|
||||
using is_detected = see below;
|
||||
template <template<class...> class Op, class... Args>
|
||||
constexpr bool is_detected_v = is_detected<Op, Args...>::value;
|
||||
template <template<class...> class Op, class... Args>
|
||||
using detected_t = see below;
|
||||
template <class Default, template<class...> class Op, class... Args>
|
||||
using detected_or = see below;
|
||||
template <class Default, template<class...> class Op, class... Args>
|
||||
using detected_or_t = typename detected_or<Default, Op, Args...>::type;
|
||||
template <class Expected, template<class...> class Op, class... Args>
|
||||
using is_detected_exact = is_same<Expected, detected_t<Op, Args...>>;
|
||||
template <class Expected, template<class...> class Op, class... Args>
|
||||
constexpr bool is_detected_exact_v
|
||||
= is_detected_exact<Expected, Op, Args...>::value;
|
||||
template <class To, template<class...> class Op, class... Args>
|
||||
using is_detected_convertible = is_convertible<detected_t<Op, Args...>, To>;
|
||||
template <class To, template<class...> class Op, class... Args>
|
||||
constexpr bool is_detected_convertible_v
|
||||
= is_detected_convertible<To, Op, Args...>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
/*
|
||||
template <class>
|
||||
class _LIBCPP_TEMPLATE_VIS raw_invocation_type;
|
||||
|
||||
template <class _Fn, class ..._Args>
|
||||
class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>;
|
||||
|
||||
template <class>
|
||||
class _LIBCPP_TEMPLATE_VIS invokation_type;
|
||||
|
||||
template <class _Fn, class ..._Args>
|
||||
class _LIBCPP_TEMPLATE_VIS invokation_type<_Fn(_Args...)>;
|
||||
|
||||
template <class _Tp>
|
||||
using invokation_type_t = typename invokation_type<_Tp>::type;
|
||||
|
||||
template <class _Tp>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
|
||||
*/
|
||||
|
||||
// 3.3.4, Detection idiom
|
||||
template <class...> using void_t = void;
|
||||
|
||||
struct nonesuch {
|
||||
nonesuch() = delete;
|
||||
~nonesuch() = delete;
|
||||
nonesuch (nonesuch const&) = delete;
|
||||
void operator=(nonesuch const&) = delete;
|
||||
};
|
||||
|
||||
template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>
|
||||
struct _DETECTOR {
|
||||
using value_t = false_type;
|
||||
using type = _Default;
|
||||
};
|
||||
|
||||
template <class _Default, template <class...> class _Op, class... _Args>
|
||||
struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
|
||||
using value_t = true_type;
|
||||
using type = _Op<_Args...>;
|
||||
};
|
||||
|
||||
|
||||
template <template<class...> class _Op, class... _Args>
|
||||
using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
|
||||
template <template<class...> class _Op, class... _Args>
|
||||
using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type;
|
||||
template <template<class...> class _Op, class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value;
|
||||
|
||||
template <class Default, template<class...> class _Op, class... _Args>
|
||||
using detected_or = _DETECTOR<Default, void, _Op, _Args...>;
|
||||
template <class Default, template<class...> class _Op, class... _Args>
|
||||
using detected_or_t = typename detected_or<Default, _Op, _Args...>::type;
|
||||
|
||||
template <class Expected, template<class...> class _Op, class... _Args>
|
||||
using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>;
|
||||
template <class Expected, template<class...> class _Op, class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<Expected, _Op, _Args...>::value;
|
||||
|
||||
template <class To, template<class...> class _Op, class... _Args>
|
||||
using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, To>;
|
||||
template <class To, template<class...> class _Op, class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
|
||||
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */
|
65
libcxx/include/experimental/unordered_map
Normal file
65
libcxx/include/experimental/unordered_map
Normal file
@ -0,0 +1,65 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- unordered_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_UNORDERED_MAP
|
||||
#define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP
|
||||
/*
|
||||
experimental/unordered_map synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class Key, class T,
|
||||
class Hash = hash<Key>,
|
||||
class Pred = equal_to<Key>>
|
||||
using unordered_map =
|
||||
std::unordered_map<Key, T, Hash, Pred,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
template <class Key, class T,
|
||||
class Hash = hash<Key>,
|
||||
class Pred = equal_to<Key>>
|
||||
using unordered_multimap =
|
||||
std::unordered_multimap<Key, T, Hash, Pred,
|
||||
polymorphic_allocator<pair<const Key,T>>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <unordered_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 _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
|
||||
using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred,
|
||||
polymorphic_allocator<pair<const _Key, _Value>>>;
|
||||
|
||||
template <class _Key, class _Value,
|
||||
class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
|
||||
using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred,
|
||||
polymorphic_allocator<pair<const _Key, _Value>>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */
|
59
libcxx/include/experimental/unordered_set
Normal file
59
libcxx/include/experimental/unordered_set
Normal file
@ -0,0 +1,59 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- unordered_set ------------------------------===//
|
||||
//
|
||||
// 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_UNORDERED_SET
|
||||
#define _LIBCPP_EXPERIMENTAL_UNORDERED_SET
|
||||
/*
|
||||
experimental/unordered_set synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T, class Hash = hash<T>, class Pred = equal_to<T>>
|
||||
using unordered_set = std::unordered_set<T, Hash, Pred,
|
||||
polymorphic_allocator<T>>;
|
||||
|
||||
template <class T, class Hash = hash<T>, class Pred = equal_to<T>>
|
||||
using unordered_multiset = std::unordered_multiset<T, Hash, Pred,
|
||||
polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <unordered_set>
|
||||
#include <experimental/memory_resource>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
|
||||
|
||||
template <class _Value,
|
||||
class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
|
||||
using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
template <class _Value,
|
||||
class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
|
||||
using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred,
|
||||
polymorphic_allocator<_Value>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */
|
47
libcxx/include/experimental/utility
Normal file
47
libcxx/include/experimental/utility
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- utility ----------------------------------===//
|
||||
//
|
||||
// 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_UTILITY
|
||||
#define _LIBCPP_EXPERIMENTAL_UTILITY
|
||||
|
||||
/*
|
||||
experimental/utility synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
3.1.2, erased-type placeholder
|
||||
struct erased_type { };
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
struct _LIBCPP_TEMPLATE_VIS erased_type { };
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */
|
47
libcxx/include/experimental/vector
Normal file
47
libcxx/include/experimental/vector
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
//===--------------------------- vector ------------------------------------===//
|
||||
//
|
||||
// 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_VECTOR
|
||||
#define _LIBCPP_EXPERIMENTAL_VECTOR
|
||||
/*
|
||||
experimental/vector synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
namespace pmr {
|
||||
|
||||
template <class T>
|
||||
using vector = std::vector<T, polymorphic_allocator<T>>;
|
||||
|
||||
} // namespace pmr
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <vector>
|
||||
#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 vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_PMR
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */
|
135
libcxx/include/ext/__hash
Normal file
135
libcxx/include/ext/__hash
Normal file
@ -0,0 +1,135 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- hash_set ------------------------------------===//
|
||||
//
|
||||
// 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_EXT_HASH
|
||||
#define _LIBCPP_EXT_HASH
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
namespace __gnu_cxx {
|
||||
using namespace std;
|
||||
|
||||
template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
|
||||
: public unary_function<const char*, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const char *__c) const _NOEXCEPT
|
||||
{
|
||||
return __do_string_hash(__c, __c + strlen(__c));
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
|
||||
: public unary_function<char*, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(char *__c) const _NOEXCEPT
|
||||
{
|
||||
return __do_string_hash<const char *>(__c, __c + strlen(__c));
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
|
||||
: public unary_function<char, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(char __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
|
||||
: public unary_function<signed char, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(signed char __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
|
||||
: public unary_function<unsigned char, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned char __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
|
||||
: public unary_function<short, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(short __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
|
||||
: public unary_function<unsigned short, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned short __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
|
||||
: public unary_function<int, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(int __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
|
||||
: public unary_function<unsigned int, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned int __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
|
||||
: public unary_function<long, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(long __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
|
||||
: public unary_function<unsigned long, size_t>
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(unsigned long __c) const _NOEXCEPT
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_EXT_HASH
|
984
libcxx/include/ext/hash_map
Normal file
984
libcxx/include/ext/hash_map
Normal file
@ -0,0 +1,984 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- hash_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_HASH_MAP
|
||||
#define _LIBCPP_HASH_MAP
|
||||
|
||||
/*
|
||||
|
||||
hash_map synopsis
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
|
||||
template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
||||
class Alloc = allocator<pair<const Key, T>>>
|
||||
class hash_map
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
|
||||
explicit hash_map(size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_map(InputIterator f, InputIterator l,
|
||||
size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
hash_map(const hash_map&);
|
||||
~hash_map();
|
||||
hash_map& operator=(const hash_map&);
|
||||
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
size_type max_size() const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
pair<iterator, bool> insert(const value_type& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
|
||||
void erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
void erase(const_iterator first, const_iterator last);
|
||||
void clear();
|
||||
|
||||
void swap(hash_map&);
|
||||
|
||||
hasher hash_funct() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
mapped_type& operator[](const key_type& k);
|
||||
|
||||
size_type bucket_count() const;
|
||||
size_type max_bucket_count() const;
|
||||
|
||||
size_type elems_in_bucket(size_type n) const;
|
||||
|
||||
void resize(size_type n);
|
||||
};
|
||||
|
||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
void swap(hash_map<Key, T, Hash, Pred, Alloc>& x,
|
||||
hash_map<Key, T, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator==(const hash_map<Key, T, Hash, Pred, Alloc>& x,
|
||||
const hash_map<Key, T, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator!=(const hash_map<Key, T, Hash, Pred, Alloc>& x,
|
||||
const hash_map<Key, T, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
||||
class Alloc = allocator<pair<const Key, T>>>
|
||||
class hash_multimap
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
|
||||
explicit hash_multimap(size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_multimap(InputIterator f, InputIterator l,
|
||||
size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
explicit hash_multimap(const allocator_type&);
|
||||
hash_multimap(const hash_multimap&);
|
||||
~hash_multimap();
|
||||
hash_multimap& operator=(const hash_multimap&);
|
||||
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
size_type max_size() const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
iterator insert(const value_type& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
|
||||
void erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
void erase(const_iterator first, const_iterator last);
|
||||
void clear();
|
||||
|
||||
void swap(hash_multimap&);
|
||||
|
||||
hasher hash_funct() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
size_type bucket_count() const;
|
||||
size_type max_bucket_count() const;
|
||||
|
||||
size_type elems_in_bucket(size_type n) const;
|
||||
|
||||
void resize(size_type n);
|
||||
};
|
||||
|
||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
void swap(hash_multimap<Key, T, Hash, Pred, Alloc>& x,
|
||||
hash_multimap<Key, T, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator==(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
|
||||
const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator!=(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
|
||||
const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
|
||||
|
||||
} // __gnu_cxx
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <__hash_table>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <ext/__hash>
|
||||
|
||||
#if __DEPRECATED
|
||||
#if defined(_LIBCPP_WARNING)
|
||||
_LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
|
||||
#else
|
||||
# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx {
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class _Tp, class _Hash,
|
||||
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
|
||||
>
|
||||
class __hash_map_hasher
|
||||
: private _Hash
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : _Hash() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : _Hash(__h) {}
|
||||
_LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Tp& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const typename _Tp::first_type& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x);}
|
||||
};
|
||||
|
||||
template <class _Tp, class _Hash>
|
||||
class __hash_map_hasher<_Tp, _Hash, false>
|
||||
{
|
||||
_Hash __hash_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : __hash_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : __hash_(__h) {}
|
||||
_LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return __hash_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Tp& __x) const
|
||||
{return __hash_(__x.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const typename _Tp::first_type& __x) const
|
||||
{return __hash_(__x);}
|
||||
};
|
||||
|
||||
template <class _Tp, class _Pred,
|
||||
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
|
||||
>
|
||||
class __hash_map_equal
|
||||
: private _Pred
|
||||
{
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_equal() : _Pred() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : _Pred(__p) {}
|
||||
_LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const typename _Tp::first_type& __x,
|
||||
const typename _Tp::first_type& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
||||
};
|
||||
|
||||
template <class _Tp, class _Pred>
|
||||
class __hash_map_equal<_Tp, _Pred, false>
|
||||
{
|
||||
_Pred __pred_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_equal() : __pred_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : __pred_(__p) {}
|
||||
_LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return __pred_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const
|
||||
{return __pred_(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
|
||||
{return __pred_(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
|
||||
{return __pred_(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const typename _Tp::first_type& __x,
|
||||
const typename _Tp::first_type& __y) const
|
||||
{return __pred_(__x, __y);}
|
||||
};
|
||||
|
||||
template <class _Alloc>
|
||||
class __hash_map_node_destructor
|
||||
{
|
||||
typedef _Alloc allocator_type;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
typedef typename __alloc_traits::value_type::__node_value_type value_type;
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
private:
|
||||
typedef typename value_type::first_type first_type;
|
||||
typedef typename value_type::second_type second_type;
|
||||
|
||||
allocator_type& __na_;
|
||||
|
||||
__hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
|
||||
|
||||
public:
|
||||
bool __first_constructed;
|
||||
bool __second_constructed;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __hash_map_node_destructor(allocator_type& __na)
|
||||
: __na_(__na),
|
||||
__first_constructed(false),
|
||||
__second_constructed(false)
|
||||
{}
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
|
||||
: __na_(__x.__na_),
|
||||
__first_constructed(__x.__value_constructed),
|
||||
__second_constructed(__x.__value_constructed)
|
||||
{
|
||||
__x.__value_constructed = false;
|
||||
}
|
||||
#else // _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
|
||||
: __na_(__x.__na_),
|
||||
__first_constructed(__x.__value_constructed),
|
||||
__second_constructed(__x.__value_constructed)
|
||||
{
|
||||
const_cast<bool&>(__x.__value_constructed) = false;
|
||||
}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void operator()(pointer __p)
|
||||
{
|
||||
if (__second_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second));
|
||||
if (__first_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first));
|
||||
if (__p)
|
||||
__alloc_traits::deallocate(__na_, __p, 1);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _HashIterator>
|
||||
class _LIBCPP_TEMPLATE_VIS __hash_map_iterator
|
||||
{
|
||||
_HashIterator __i_;
|
||||
|
||||
typedef const typename _HashIterator::value_type::first_type key_type;
|
||||
typedef typename _HashIterator::value_type::second_type mapped_type;
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef pair<key_type, mapped_type> value_type;
|
||||
typedef typename _HashIterator::difference_type difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef typename __rebind_pointer<typename _HashIterator::pointer, value_type>::type
|
||||
pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_iterator(_HashIterator __i) : __i_(__i) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return (pointer)__i_.operator->();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_iterator operator++(int)
|
||||
{
|
||||
__hash_map_iterator __t(*this);
|
||||
++(*this);
|
||||
return __t;
|
||||
}
|
||||
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
|
||||
{return __x.__i_ == __y.__i_;}
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
|
||||
{return __x.__i_ != __y.__i_;}
|
||||
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map;
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap;
|
||||
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
|
||||
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
|
||||
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
|
||||
};
|
||||
|
||||
template <class _HashIterator>
|
||||
class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
|
||||
{
|
||||
_HashIterator __i_;
|
||||
|
||||
typedef const typename _HashIterator::value_type::first_type key_type;
|
||||
typedef typename _HashIterator::value_type::second_type mapped_type;
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef pair<key_type, mapped_type> value_type;
|
||||
typedef typename _HashIterator::difference_type difference_type;
|
||||
typedef const value_type& reference;
|
||||
typedef typename __rebind_pointer<typename _HashIterator::pointer, const value_type>::type
|
||||
pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_const_iterator(_HashIterator __i) : __i_(__i) {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_const_iterator(
|
||||
__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
|
||||
: __i_(__i.__i_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return *operator->();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return (pointer)__i_.operator->();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_const_iterator& operator++() {++__i_; return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_const_iterator operator++(int)
|
||||
{
|
||||
__hash_map_const_iterator __t(*this);
|
||||
++(*this);
|
||||
return __t;
|
||||
}
|
||||
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
|
||||
{return __x.__i_ == __y.__i_;}
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
|
||||
{return __x.__i_ != __y.__i_;}
|
||||
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map;
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap;
|
||||
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
|
||||
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
|
||||
class _Alloc = allocator<pair<const _Key, _Tp> > >
|
||||
class _LIBCPP_TEMPLATE_VIS hash_map
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Hash hasher;
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
private:
|
||||
typedef pair<key_type, mapped_type> __value_type;
|
||||
typedef __hash_map_hasher<__value_type, hasher> __hasher;
|
||||
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
|
||||
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
|
||||
|
||||
typedef __hash_table<__value_type, __hasher,
|
||||
__key_equal, __allocator_type> __table;
|
||||
|
||||
__table __table_;
|
||||
|
||||
typedef typename __table::__node_pointer __node_pointer;
|
||||
typedef typename __table::__node_const_pointer __node_const_pointer;
|
||||
typedef typename __table::__node_traits __node_traits;
|
||||
typedef typename __table::__node_allocator __node_allocator;
|
||||
typedef typename __table::__node __node;
|
||||
typedef __hash_map_node_destructor<__node_allocator> _Dp;
|
||||
typedef unique_ptr<__node, _Dp> __node_holder;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
|
||||
typedef __hash_map_iterator<typename __table::iterator> iterator;
|
||||
typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY hash_map() {__table_.rehash(193);}
|
||||
explicit hash_map(size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
hash_map(size_type __n, const hasher& __hf,
|
||||
const key_equal& __eql,
|
||||
const allocator_type& __a);
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __first, _InputIterator __last);
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf,
|
||||
const key_equal& __eql,
|
||||
const allocator_type& __a);
|
||||
hash_map(const hash_map& __u);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return __table_.size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const {return __table_.max_size();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() {return __table_.end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const {return __table_.end();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> insert(const value_type& __x)
|
||||
{return __table_.__insert_unique(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __p) {__table_.erase(__p.__i_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __first, const_iterator __last)
|
||||
{__table_.erase(__first.__i_, __last.__i_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() {__table_.clear();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(hash_map& __u) {__table_.swap(__u.__table_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hasher hash_funct() const
|
||||
{return __table_.hash_function().hash_function();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_equal key_eq() const
|
||||
{return __table_.key_eq().key_eq();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||
{return __table_.__equal_range_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||
{return __table_.__equal_range_unique(__k);}
|
||||
|
||||
mapped_type& operator[](const key_type& __k);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type bucket_count() const {return __table_.bucket_count();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_bucket_count() const {return __table_.max_bucket_count();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{return __table_.bucket_size(__n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void resize(size_type __n) {__table_.rehash(__n);}
|
||||
|
||||
private:
|
||||
__node_holder __construct_node(const key_type& __k);
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
|
||||
_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
__table_.rehash(193);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
|
||||
const hash_map& __u)
|
||||
: __table_(__u.__table_)
|
||||
{
|
||||
__table_.rehash(__u.bucket_count());
|
||||
insert(__u.begin(), __u.end());
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline
|
||||
void
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
__table_.__insert_unique(*__first);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
_Tp&
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
|
||||
{
|
||||
iterator __i = find(__k);
|
||||
if (__i != end())
|
||||
return __i->second;
|
||||
__node_holder __h = __construct_node(__k);
|
||||
pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
|
||||
__h.release();
|
||||
return __r.first->second;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
|
||||
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
bool
|
||||
operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
if (__x.size() != __y.size())
|
||||
return false;
|
||||
typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
|
||||
const_iterator;
|
||||
for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
|
||||
__i != __ex; ++__i)
|
||||
{
|
||||
const_iterator __j = __y.find(__i->first);
|
||||
if (__j == __ey || !(*__i == *__j))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
|
||||
class _Alloc = allocator<pair<const _Key, _Tp> > >
|
||||
class _LIBCPP_TEMPLATE_VIS hash_multimap
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Hash hasher;
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
private:
|
||||
typedef pair<key_type, mapped_type> __value_type;
|
||||
typedef __hash_map_hasher<__value_type, hasher> __hasher;
|
||||
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
|
||||
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
|
||||
|
||||
typedef __hash_table<__value_type, __hasher,
|
||||
__key_equal, __allocator_type> __table;
|
||||
|
||||
__table __table_;
|
||||
|
||||
typedef typename __table::__node_traits __node_traits;
|
||||
typedef typename __table::__node_allocator __node_allocator;
|
||||
typedef typename __table::__node __node;
|
||||
typedef __hash_map_node_destructor<__node_allocator> _Dp;
|
||||
typedef unique_ptr<__node, _Dp> __node_holder;
|
||||
typedef allocator_traits<allocator_type> __alloc_traits;
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
|
||||
typedef __hash_map_iterator<typename __table::iterator> iterator;
|
||||
typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hash_multimap() {__table_.rehash(193);}
|
||||
explicit hash_multimap(size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
hash_multimap(size_type __n, const hasher& __hf,
|
||||
const key_equal& __eql,
|
||||
const allocator_type& __a);
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __first, _InputIterator __last);
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf,
|
||||
const key_equal& __eql,
|
||||
const allocator_type& __a);
|
||||
hash_multimap(const hash_multimap& __u);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return __table_.size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const {return __table_.max_size();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() {return __table_.end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const {return __table_.end();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __p) {__table_.erase(__p.__i_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __first, const_iterator __last)
|
||||
{__table_.erase(__first.__i_, __last.__i_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() {__table_.clear();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(hash_multimap& __u) {__table_.swap(__u.__table_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hasher hash_funct() const
|
||||
{return __table_.hash_function().hash_function();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_equal key_eq() const
|
||||
{return __table_.key_eq().key_eq();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||
{return __table_.__equal_range_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||
{return __table_.__equal_range_multi(__k);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type bucket_count() const {return __table_.bucket_count();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_bucket_count() const {return __table_.max_bucket_count();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{return __table_.bucket_size(__n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void resize(size_type __n) {__table_.rehash(__n);}
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
__table_.rehash(193);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
|
||||
const hash_multimap& __u)
|
||||
: __table_(__u.__table_)
|
||||
{
|
||||
__table_.rehash(__u.bucket_count());
|
||||
insert(__u.begin(), __u.end());
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline
|
||||
void
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
__table_.__insert_multi(*__first);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
|
||||
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
bool
|
||||
operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
if (__x.size() != __y.size())
|
||||
return false;
|
||||
typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
|
||||
const_iterator;
|
||||
typedef pair<const_iterator, const_iterator> _EqRng;
|
||||
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
|
||||
{
|
||||
_EqRng __xeq = __x.equal_range(__i->first);
|
||||
_EqRng __yeq = __y.equal_range(__i->first);
|
||||
if (_VSTD::distance(__xeq.first, __xeq.second) !=
|
||||
_VSTD::distance(__yeq.first, __yeq.second) ||
|
||||
!_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
|
||||
return false;
|
||||
__i = __xeq.second;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
} // __gnu_cxx
|
||||
|
||||
#endif // _LIBCPP_HASH_MAP
|
663
libcxx/include/ext/hash_set
Normal file
663
libcxx/include/ext/hash_set
Normal file
@ -0,0 +1,663 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- hash_set ------------------------------------===//
|
||||
//
|
||||
// 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_HASH_SET
|
||||
#define _LIBCPP_HASH_SET
|
||||
|
||||
/*
|
||||
|
||||
hash_set synopsis
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
|
||||
template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
|
||||
class Alloc = allocator<Value>>
|
||||
class hash_set
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Value key_type;
|
||||
typedef key_type value_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
|
||||
explicit hash_set(size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l,
|
||||
size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
hash_set(const hash_set&);
|
||||
~hash_set();
|
||||
hash_set& operator=(const hash_set&);
|
||||
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
size_type max_size() const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
pair<iterator, bool> insert(const value_type& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
|
||||
void erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
void erase(const_iterator first, const_iterator last);
|
||||
void clear();
|
||||
|
||||
void swap(hash_set&);
|
||||
|
||||
hasher hash_funct() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
size_type bucket_count() const;
|
||||
size_type max_bucket_count() const;
|
||||
|
||||
size_type elems_in_bucket(size_type n) const;
|
||||
|
||||
void resize(size_type n);
|
||||
};
|
||||
|
||||
template <class Value, class Hash, class Pred, class Alloc>
|
||||
void swap(hash_set<Value, Hash, Pred, Alloc>& x,
|
||||
hash_set<Value, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Value, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator==(const hash_set<Value, Hash, Pred, Alloc>& x,
|
||||
const hash_set<Value, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Value, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator!=(const hash_set<Value, Hash, Pred, Alloc>& x,
|
||||
const hash_set<Value, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
|
||||
class Alloc = allocator<Value>>
|
||||
class hash_multiset
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Value key_type;
|
||||
typedef key_type value_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
|
||||
explicit hash_multiset(size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_multiset(InputIterator f, InputIterator l,
|
||||
size_type n = 193, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
hash_multiset(const hash_multiset&);
|
||||
~hash_multiset();
|
||||
hash_multiset& operator=(const hash_multiset&);
|
||||
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
size_type max_size() const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
iterator insert(const value_type& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
|
||||
void erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
void erase(const_iterator first, const_iterator last);
|
||||
void clear();
|
||||
|
||||
void swap(hash_multiset&);
|
||||
|
||||
hasher hash_funct() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
size_type bucket_count() const;
|
||||
size_type max_bucket_count() const;
|
||||
|
||||
size_type elems_in_bucket(size_type n) const;
|
||||
|
||||
void resize(size_type n);
|
||||
};
|
||||
|
||||
template <class Value, class Hash, class Pred, class Alloc>
|
||||
void swap(hash_multiset<Value, Hash, Pred, Alloc>& x,
|
||||
hash_multiset<Value, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Value, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator==(const hash_multiset<Value, Hash, Pred, Alloc>& x,
|
||||
const hash_multiset<Value, Hash, Pred, Alloc>& y);
|
||||
|
||||
template <class Value, class Hash, class Pred, class Alloc>
|
||||
bool
|
||||
operator!=(const hash_multiset<Value, Hash, Pred, Alloc>& x,
|
||||
const hash_multiset<Value, Hash, Pred, Alloc>& y);
|
||||
} // __gnu_cxx
|
||||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
#include <__hash_table>
|
||||
#include <functional>
|
||||
#include <ext/__hash>
|
||||
|
||||
#if __DEPRECATED
|
||||
#if defined(_LIBCPP_WARNING)
|
||||
_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
|
||||
#else
|
||||
# warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx {
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
|
||||
class _Alloc = allocator<_Value> >
|
||||
class _LIBCPP_TEMPLATE_VIS hash_set
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef _Value key_type;
|
||||
typedef key_type value_type;
|
||||
typedef _Hash hasher;
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
private:
|
||||
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
|
||||
|
||||
__table __table_;
|
||||
|
||||
public:
|
||||
typedef typename __table::pointer pointer;
|
||||
typedef typename __table::const_pointer const_pointer;
|
||||
typedef typename __table::size_type size_type;
|
||||
typedef typename __table::difference_type difference_type;
|
||||
|
||||
typedef typename __table::const_iterator iterator;
|
||||
typedef typename __table::const_iterator const_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hash_set() {__table_.rehash(193);}
|
||||
explicit hash_set(size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a);
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __first, _InputIterator __last);
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a);
|
||||
hash_set(const hash_set& __u);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return __table_.size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const {return __table_.max_size();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() {return __table_.end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const {return __table_.end();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, bool> insert(const value_type& __x)
|
||||
{return __table_.__insert_unique(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __p) {__table_.erase(__p);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __first, const_iterator __last)
|
||||
{__table_.erase(__first, __last);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() {__table_.clear();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(hash_set& __u) {__table_.swap(__u.__table_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hasher hash_funct() const {return __table_.hash_function();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_equal key_eq() const {return __table_.key_eq();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||
{return __table_.__equal_range_unique(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||
{return __table_.__equal_range_unique(__k);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type bucket_count() const {return __table_.bucket_count();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_bucket_count() const {return __table_.max_bucket_count();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void resize(size_type __n) {__table_.rehash(__n);}
|
||||
};
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
|
||||
_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
__table_.rehash(193);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
|
||||
const hash_set& __u)
|
||||
: __table_(__u.__table_)
|
||||
{
|
||||
__table_.rehash(__u.bucket_count());
|
||||
insert(__u.begin(), __u.end());
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline
|
||||
void
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
__table_.__insert_unique(*__first);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
|
||||
hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
bool
|
||||
operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
if (__x.size() != __y.size())
|
||||
return false;
|
||||
typedef typename hash_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
|
||||
const_iterator;
|
||||
for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
|
||||
__i != __ex; ++__i)
|
||||
{
|
||||
const_iterator __j = __y.find(*__i);
|
||||
if (__j == __ey || !(*__i == *__j))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
|
||||
class _Alloc = allocator<_Value> >
|
||||
class _LIBCPP_TEMPLATE_VIS hash_multiset
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef _Value key_type;
|
||||
typedef key_type value_type;
|
||||
typedef _Hash hasher;
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
private:
|
||||
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
|
||||
|
||||
__table __table_;
|
||||
|
||||
public:
|
||||
typedef typename __table::pointer pointer;
|
||||
typedef typename __table::const_pointer const_pointer;
|
||||
typedef typename __table::size_type size_type;
|
||||
typedef typename __table::difference_type difference_type;
|
||||
|
||||
typedef typename __table::const_iterator iterator;
|
||||
typedef typename __table::const_iterator const_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hash_multiset() {__table_.rehash(193);}
|
||||
explicit hash_multiset(size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
hash_multiset(size_type __n, const hasher& __hf,
|
||||
const key_equal& __eql, const allocator_type& __a);
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __first, _InputIterator __last);
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n, const hasher& __hf = hasher(),
|
||||
const key_equal& __eql = key_equal());
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __first, _InputIterator __last,
|
||||
size_type __n , const hasher& __hf,
|
||||
const key_equal& __eql, const allocator_type& __a);
|
||||
hash_multiset(const hash_multiset& __u);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
allocator_type get_allocator() const
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return __table_.size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const {return __table_.max_size();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() {return __table_.end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const {return __table_.begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const {return __table_.end();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
|
||||
template <class _InputIterator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void insert(_InputIterator __first, _InputIterator __last);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __p) {__table_.erase(__p);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void erase(const_iterator __first, const_iterator __last)
|
||||
{__table_.erase(__first, __last);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() {__table_.clear();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(hash_multiset& __u) {__table_.swap(__u.__table_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
hasher hash_funct() const {return __table_.hash_function();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
key_equal key_eq() const {return __table_.key_eq();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator find(const key_type& __k) {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<iterator, iterator> equal_range(const key_type& __k)
|
||||
{return __table_.__equal_range_multi(__k);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
|
||||
{return __table_.__equal_range_multi(__k);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type bucket_count() const {return __table_.bucket_count();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_bucket_count() const {return __table_.max_bucket_count();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void resize(size_type __n) {__table_.rehash(__n);}
|
||||
};
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
__table_.rehash(193);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: __table_(__hf, __eql)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
_InputIterator __first, _InputIterator __last, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
|
||||
: __table_(__hf, __eql, __a)
|
||||
{
|
||||
__table_.rehash(__n);
|
||||
insert(__first, __last);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
|
||||
const hash_multiset& __u)
|
||||
: __table_(__u.__table_)
|
||||
{
|
||||
__table_.rehash(__u.bucket_count());
|
||||
insert(__u.begin(), __u.end());
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline
|
||||
void
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
__table_.__insert_multi(*__first);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
|
||||
hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
bool
|
||||
operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
if (__x.size() != __y.size())
|
||||
return false;
|
||||
typedef typename hash_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
|
||||
const_iterator;
|
||||
typedef pair<const_iterator, const_iterator> _EqRng;
|
||||
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
|
||||
{
|
||||
_EqRng __xeq = __x.equal_range(*__i);
|
||||
_EqRng __yeq = __y.equal_range(*__i);
|
||||
if (_VSTD::distance(__xeq.first, __xeq.second) !=
|
||||
_VSTD::distance(__yeq.first, __yeq.second) ||
|
||||
!_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
|
||||
return false;
|
||||
__i = __xeq.second;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Value, class _Hash, class _Pred, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
|
||||
const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
} // __gnu_cxx
|
||||
|
||||
#endif // _LIBCPP_HASH_SET
|
2637
libcxx/include/filesystem
Normal file
2637
libcxx/include/filesystem
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user