Update to upstream r216384.

This rebase skips the following patches in upstream:

+ 37025e1b32
Make the helper routines in string really be constexpr. This required a
bit of refacoring in algorithm as well. Give them better names while
we're at it. All of these are internal rotines; no visible functionality
change.

+ 164b297099
Implement string_view from the library fundamentals TS (n4023). Also
works in C++11 and 03, with reduced functionality (mostly in the area of
constexpr)

+ e4694b4129
Formatting improvements in the <string_view> synopsis suggested by
RSmith. No functionality change.

+ 3a61b30f3a
Minor cleanup for string_view; mostly from suggestions by Richard Smith.
Also, make the tests pass under c++03

+ 484728789e
string_view enhancements.  Move to the correct namespace. Better
constexpr support (thanks to Richard for the suggestions). Update the
tests to match this. Add <experimental/__config for experimental
macros/etc to live.

+ b1a40264dc
[libcxx] Add <experimental/utility> header for LFTS.

+ 3ee7233c80
[libcxx] expose experimental::erased_type for all standard versions.

+ 67740670f9
NFC. Remove trailing whitespace and tabs.

+ b9536101dc
NFC. Move definition of _LIBCPP_ASSERT into __debug header and remove
external include guards.

+ 98c4e404ca.
Revert "Turn off extern templates for most uses."

Bug: 17255369
Change-Id: I629ff16275d50e4cc8767b253a2c0542468348d8
This commit is contained in:
Dan Albert
2014-08-26 11:20:46 -07:00
parent 3d9e6ba593
commit 90dc8dd841
283 changed files with 4624 additions and 1158 deletions

View File

@@ -40,14 +40,27 @@ option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
if (LIBCXX_BUILT_STANDALONE)
set(LLVM_USE_SANITIZER "" CACHE STRING
"Define the sanitizer used to build the library and tests")
endif()
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
if (NOT DEFINED LIBCXX_CXX_ABI)
set(LIBCXX_CXX_ABI "none")
endif()
if (NOT LIBCXX_CXX_ABI)
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_LIBCXXABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
set(LIBCXX_CXX_ABI_INTREE 1)
else ()
set(LIBCXX_CXX_ABI_LIBNAME "none")
endif ()
else ()
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
endif ()
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
"Specify C++ ABI library to use." FORCE)
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
@@ -90,16 +103,17 @@ set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
macro(setup_abi_lib abipathvar abidefines abilibs abifiles abidirs)
list(APPEND LIBCXX_CXX_FEATURE_FLAGS ${abidefines})
set(${abipathvar} "${${abipathvar}}"
CACHE STRINGS
"Paths to ABI include directories separate by ';'."
CACHE PATH
"Paths to C++ ABI header directories separated by ';'." FORCE
)
set(LIBCXX_CXX_ABI_LIBRARIES ${abilibs})
set(LIBCXX_ABILIB_FILES ${abifiles})
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include")
foreach(_d ${abidirs})
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/${_d}")
endforeach()
set(LIBCXX_ABILIB_FILE_PATHS)
foreach(fpath ${LIBCXX_ABILIB_FILES})
set(found FALSE)
foreach(incpath ${${abipathvar}})
@@ -107,39 +121,33 @@ macro(setup_abi_lib abipathvar abidefines abilibs abifiles abidirs)
set(found TRUE)
get_filename_component(dstdir ${fpath} PATH)
get_filename_component(ifile ${fpath} NAME)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/include/${dstdir}/${ifile}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${incpath}/${fpath}"
"${CMAKE_BINARY_DIR}/include/${dstdir}"
MAIN_DEPENDENCY "${incpath}/${fpath}"
)
list(APPEND LIBCXX_CXX_ABI_DEPS
"${CMAKE_BINARY_DIR}/include/${dstdir}/${ifile}"
file(COPY "${incpath}/${fpath}"
DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}"
)
list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}")
endif()
endforeach()
if (NOT found)
message(FATAL_ERROR "Failed to find ${fpath}")
endif()
endforeach()
add_custom_target(abilib_headers DEPENDS ${LIBCXX_CXX_ABI_DEPS})
set(LIBCXX_CXX_ABI_DEPS abilib_headers)
add_custom_target(LIBCXX_CXX_ABI_DEPS DEPENDS ${abilib_headers})
include_directories("${CMAKE_BINARY_DIR}/include")
install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
install(FILES ${abilib_headers}
DESTINATION include/c++/v1
FILES_MATCHING
PATTERN "*"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
endmacro()
if ("${LIBCXX_CXX_ABI}" STREQUAL "libstdc++" OR
"${LIBCXX_CXX_ABI}" STREQUAL "libsupc++")
if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
"${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++")
set(_LIBSUPCXX_INCLUDE_FILES
cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h
bits/cxxabi_tweaks.h bits/cxxabi_forced.h
)
if ("${LIBCXX_CXX_ABI}" STREQUAL "libstdc++")
if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++")
set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX")
set(_LIBSUPCXX_LIBNAME stdc++)
else()
@@ -150,15 +158,22 @@ if ("${LIBCXX_CXX_ABI}" STREQUAL "libstdc++" OR
"-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}"
"${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
)
elseif ("${LIBCXX_CXX_ABI}" STREQUAL "libcxxabi")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
if (LIBCXX_CXX_ABI_INTREE)
# Link against just-built "cxxabi" target.
set(CXXABI_LIBNAME cxxabi)
else()
# Assume c++abi is installed in the system, rely on -lc++abi link flag.
set(CXXABI_LIBNAME "c++abi")
endif()
setup_abi_lib("LIBCXX_LIBCXXABI_INCLUDE_PATHS" ""
"c++abi" "cxxabi.h" ""
${CXXABI_LIBNAME} "cxxabi.h" ""
)
elseif ("${LIBCXX_CXX_ABI}" STREQUAL "libcxxrt")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
setup_abi_lib("LIBCXX_LIBCXXRT_INCLUDE_PATHS" "-DLIBCXXRT"
"cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
)
elseif (NOT "${LIBCXX_CXX_ABI}" STREQUAL "none")
elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
message(FATAL_ERROR
"Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are "
"supported for c++ abi."
@@ -181,10 +196,25 @@ if (MSVC)
else()
if (LIBCXX_HAS_NOSTDINCXX_FLAG)
list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -nostdinc++)
string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
if (LIBCXX_ENABLE_CXX0X AND LIBCXX_HAS_STDCXX0X_FLAG)
list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -std=c++0x)
# If c++1y has been enabled then attempt to use it. Fail if it is no supported
# by the compiler. Otherwise choose c++11 and ensure the compiler supports it.
if (LIBCXX_ENABLE_CXX1Y)
if (LIBCXX_HAS_STDCXX1Y_FLAG)
set(LIBCXX_STD_VERSION c++1y)
else()
message(FATAL_ERROR "c++1y was enabled but the compiler does not support it.")
endif()
else()
if (LIBCXX_HAS_STDCXX11_FLAG)
set(LIBCXX_STD_VERSION c++11)
else()
message(FATAL_ERROR "c++11 is required by libc++ but is not supported by the compiler")
endif()
endif()
# LIBCXX_STD_VERSION should always be set at this point.
list(APPEND LIBCXX_CXX_REQUIRED_FLAGS "-std=${LIBCXX_STD_VERSION}")
endif()
macro(append_if list condition var)
@@ -259,6 +289,29 @@ if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
if (LIBCXX_BUILT_STANDALONE)
# NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
# But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do.
if (LLVM_USE_SANITIZER AND NOT MSVC)
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_OMIT_FRAME_POINTER_FLAG
"-fno-omit-frame-pointer")
if (LLVM_USE_SANITIZER STREQUAL "Address")
list(APPEND LIBCXX_CXX_FEATURE_FLAGS "-fsanitize=address")
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
list(APPEND LIBCXX_CXX_FEATURE_FLAGS "-fsanitize=memory")
if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
list(APPEND LIBCXX_CXX_FEATURE_FLAGS "-fsanitize-memory-track-origins")
endif()
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
elseif(MSVC)
message(WARNING "LLVM_USE_SANITIZER is not supported with MSVC")
endif()
endif()
string(REPLACE ";" " " LIBCXX_CXX_REQUIRED_FLAGS "${LIBCXX_CXX_REQUIRED_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_REQUIRED_FLAGS}")

View File

@@ -33,6 +33,10 @@ E: mclow.lists@gmail.com
E: marshall@idio.com
D: C++14 support, patches and bug fixes.
N: Eric Fiselier
E: eric@efcs.ca
D: LFTS support, patches and bug fixes.
N: Bill Fisher
E: william.w.fisher@gmail.com
D: Regex bug fixes.

View File

@@ -2,8 +2,10 @@ include(CheckLibraryExists)
include(CheckCXXCompilerFlag)
# Check compiler flags
check_cxx_compiler_flag(-std=c++0x LIBCXX_HAS_STDCXX0X_FLAG)
check_cxx_compiler_flag(-std=c++11 LIBCXX_HAS_STDCXX11_FLAG)
check_cxx_compiler_flag(-std=c++1y LIBCXX_HAS_STDCXX1Y_FLAG)
check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG)
check_cxx_compiler_flag(-fno-omit-frame-pointer LIBCXX_HAS_NO_OMIT_FRAME_POINTER_FLAG)
check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG)
check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG)
check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG)

View File

@@ -2,15 +2,12 @@ if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
endif()
file(COPY .
DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1"
install(DIRECTORY .
DESTINATION include/c++/v1
FILES_MATCHING
PATTERN "*"
PATTERN "CMakeLists.txt" EXCLUDE
PATTERN ".svn" EXCLUDE
${LIBCXX_SUPPORT_HEADER_PATTERN}
)
install(DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/"
DESTINATION include/c++/v1/
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)

View File

@@ -174,7 +174,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
if (__n == __dn)
return _It(__first.__seg_, __first.__ctz_ + __n);
return __first + __n;
__n -= __dn;
++__first.__seg_;
}
@@ -210,7 +210,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
if (__n == __dn)
return _It(__first.__seg_, __first.__ctz_ + __n);
return __first + __n;
__n -= __dn;
++__first.__seg_;
}

View File

@@ -313,6 +313,10 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_CONSTEXPR
#endif
#if !(__has_feature(cxx_relaxed_constexpr))
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#endif
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
#if defined(__FreeBSD__)
#define _LIBCPP_HAS_QUICK_EXIT
@@ -341,7 +345,11 @@ typedef __char32_t char32_t;
#endif
#if __has_feature(underlying_type)
# define _LIBCXX_UNDERLYING_TYPE(T) __underlying_type(T)
# define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
#endif
#if __has_feature(is_literal)
# define _LIBCPP_IS_LITERAL(T) __is_literal(T)
#endif
// Inline namespaces are available in Clang regardless of C++ dialect.
@@ -354,6 +362,10 @@ namespace std {
}
}
#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
#define _LIBCPP_HAS_NO_ASAN
#endif
#elif defined(__GNUC__)
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -361,12 +373,27 @@ namespace std {
#define _LIBCPP_NORETURN __attribute__((noreturn))
#if _GNUC_VER >= 407
#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
#endif
#if !__EXCEPTIONS
#define _LIBCPP_NO_EXCEPTIONS
#endif
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
// constexpr was added to GCC in 4.6.
#if _GNUC_VER < 406
#define _LIBCPP_HAS_NO_CONSTEXPR
// Can only use constexpr in c++11 mode.
#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
#define _LIBCPP_HAS_NO_CONSTEXPR
#endif
// No version of GCC supports relaxed constexpr rules
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _NOEXCEPT throw()
#define _NOEXCEPT_(x)
@@ -428,11 +455,16 @@ namespace _LIBCPP_NAMESPACE {
using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
}
#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
#define _LIBCPP_HAS_NO_ASAN
#endif
#elif defined(_LIBCPP_MSVC)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
@@ -453,6 +485,8 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
namespace std {
}
#define _LIBCPP_HAS_NO_ASAN
#elif defined(__IBMCPP__)
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -485,6 +519,8 @@ namespace std {
}
}
#define _LIBCPP_HAS_NO_ASAN
#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
@@ -533,12 +569,20 @@ template <unsigned> struct __static_assert_check {};
#define __has_feature(__x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(__x) 0
#endif
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
# define _LIBCPP_EXPLICIT explicit
#else
# define _LIBCPP_EXPLICIT
#endif
#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
# define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
#endif
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
@@ -579,7 +623,7 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif
#if defined(__FreeBSD__)
#ifdef __FreeBSD__
#define _DECLARE_C99_LDBL_MATH 1
#endif
@@ -598,8 +642,10 @@ template <unsigned> struct __static_assert_check {};
#ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
# elif __cplusplus <= 201402L
# define _LIBCPP_STD_VER 14
# else
# define _LIBCPP_STD_VER 13 // current year, or date of c++14 ratification
# define _LIBCPP_STD_VER 15 // current year, or date of c++17 ratification
# endif
#endif // _LIBCPP_STD_VER
@@ -610,15 +656,24 @@ template <unsigned> struct __static_assert_check {};
#endif
#if _LIBCPP_STD_VER <= 11
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
#define _LIBCPP_EXPLICIT_AFTER_CXX11
#define _LIBCPP_DEPRECATED_AFTER_CXX11
#else
#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
#endif
#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
#else
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
#endif
#ifndef _LIBCPP_HAS_NO_ASAN
extern "C" void __sanitizer_annotate_contiguous_container(
const void *, const void *, const void *, const void *);
#endif
// Try to find out if RTTI is disabled.
// g++ and cl.exe have RTTI on by default and define a macro when it is.
// g++ only defines the macro in 4.3.2 and onwards.

View File

@@ -651,9 +651,14 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp()>
__base* __f_;
template <class _Fp>
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(const _Fp&) {return true;}
template <class _R2>
static bool __not_null(const function<_Rp()>& __p) {return __p;}
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(_R2 (*__p)()) {return __p;}
template <class _R2>
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(const function<_R2()>& __p) {return __p;}
public:
typedef _Rp result_type;
@@ -955,7 +960,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)>
static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;}
template <class _R2, class _B0>
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(const function<_Rp(_B0)>& __p) {return __p;}
static bool __not_null(const function<_R2(_B0)>& __p) {return __p;}
public:
typedef _Rp result_type;
@@ -1257,7 +1262,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)>
static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return __p;}
template <class _R2, class _B0, class _B1>
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(const function<_Rp(_B0, _B1)>& __p) {return __p;}
static bool __not_null(const function<_R2(_B0, _B1)>& __p) {return __p;}
public:
typedef _Rp result_type;
@@ -1558,7 +1563,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)>
static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const volatile) {return __p;}
template <class _R2, class _B0, class _B1, class _B2>
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(const function<_Rp(_B0, _B1, _B2)>& __p) {return __p;}
static bool __not_null(const function<_R2(_B0, _B1, _B2)>& __p) {return __p;}
public:
typedef _Rp result_type;
@@ -1911,7 +1916,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename __mu_return1<true, _Ti, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>)
{
__ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj))...);
__ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj))...);
}
template <class _Ti, class ..._Uj>
@@ -1947,9 +1952,9 @@ __mu(_Ti&, _Uj& __uj)
{
const size_t _Indx = is_placeholder<_Ti>::value - 1;
// compiler bug workaround
typename tuple_element<_Indx, _Uj>::type __t = get<_Indx>(__uj);
typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj);
return __t;
// return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj));
// return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
}
template <class _Ti, class _Uj>
@@ -2040,7 +2045,7 @@ typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
_Args&& __args)
{
return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...);
return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
}
template<class _Fp, class ..._BoundArgs>

View File

@@ -1027,7 +1027,7 @@ public:
typename __invoke_return0<type&, _A0>::type
operator() (_A0& __a0) const
{
return __invoke(get(), __a0);
return __invoke<type&, _A0>(get(), __a0);
}
template <class _A0, class _A1>
@@ -1035,7 +1035,7 @@ public:
typename __invoke_return1<type&, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const
{
return __invoke(get(), __a0, __a1);
return __invoke<type&, _A0, _A1>(get(), __a0, __a1);
}
template <class _A0, class _A1, class _A2>
@@ -1043,7 +1043,7 @@ public:
typename __invoke_return2<type&, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
{
return __invoke(get(), __a0, __a1, __a2);
return __invoke<type&, _A0, _A1, _A2>(get(), __a0, __a1, __a2);
}
};

View File

@@ -55,14 +55,14 @@ public:
__allocated_ = true;
return (pointer)&buf_;
}
return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type)
{
if (__p == (pointer)&buf_)
__allocated_ = false;
else
::operator delete(__p);
_VSTD::__deallocate(__p);
}
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}

View File

@@ -1980,9 +1980,9 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
__begin_node() = __r.__ptr_;
--size();
__node_allocator& __na = __node_alloc();
__node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
__tree_remove(__end_node()->__left_,
static_cast<__node_base_pointer>(__np));
__node_traits::destroy(__na, const_cast<value_type*>(_VSTD::addressof(*__p)));
__node_traits::deallocate(__na, __np, 1);
return __r;
}

View File

@@ -27,6 +27,32 @@
_LIBCPP_BEGIN_NAMESPACE_STD
// __lazy_and
template <bool _Last, class ..._Preds>
struct __lazy_and_impl;
template <class ..._Preds>
struct __lazy_and_impl<false, _Preds...> : false_type {};
template <>
struct __lazy_and_impl<true> : true_type {};
template <class _Pred>
struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
template <class _Hp, class ..._Tp>
struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
template <class _P1, class ..._Pr>
struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
// __lazy_not
template <class _Pred>
struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
template <class _Tp>

View File

@@ -4784,48 +4784,7 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
template <class _Compare, class _RandomAccessIterator>
void
__push_heap_front(_RandomAccessIterator __first, _RandomAccessIterator, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
if (__len > 1)
{
difference_type __p = 0;
_RandomAccessIterator __pp = __first;
difference_type __c = 2;
_RandomAccessIterator __cp = __first + __c;
if (__c == __len || __comp(*__cp, *(__cp - 1)))
{
--__c;
--__cp;
}
if (__comp(*__pp, *__cp))
{
value_type __t(_VSTD::move(*__pp));
do
{
*__pp = _VSTD::move(*__cp);
__pp = __cp;
__p = __c;
__c = (__p + 1) * 2;
if (__c > __len)
break;
__cp = __first + __c;
if (__c == __len || __comp(*__cp, *(__cp - 1)))
{
--__c;
--__cp;
}
} while (__comp(__t, *__cp));
*__pp = _VSTD::move(__t);
}
}
}
template <class _Compare, class _RandomAccessIterator>
void
__push_heap_back(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -4859,10 +4818,10 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
#ifdef _LIBCPP_DEBUG
typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
__debug_less<_Compare> __c(__comp);
__push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first);
__sift_up<_Comp_ref>(__first, __last, __c, __last - __first);
#else // _LIBCPP_DEBUG
typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
__push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first);
__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
#endif // _LIBCPP_DEBUG
}
@@ -4876,6 +4835,60 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
// pop_heap
template <class _Compare, class _RandomAccessIterator>
void
__sift_down(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
// left-child of __start is at 2 * __start + 1
// right-child of __start is at 2 * __start + 2
difference_type __child = __start - __first;
if (__len < 2 || (__len - 2) / 2 < __child)
return;
__child = 2 * __child + 1;
_RandomAccessIterator __child_i = __first + __child;
if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
// right-child exists and is greater than left-child
++__child_i;
++__child;
}
// check if we are in heap-order
if (__comp(*__child_i, *__start))
// we are, __start is larger than it's largest child
return;
value_type __top(_VSTD::move(*__start));
do
{
// we are not in heap-order, swap the parent with it's largest child
*__start = _VSTD::move(*__child_i);
__start = __child_i;
if ((__len - 2) / 2 < __child)
break;
// recompute the child based off of the updated parent
__child = 2 * __child + 1;
__child_i = __first + __child;
if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
// right-child exists and is greater than left-child
++__child_i;
++__child;
}
// check if we are in heap-order
} while (!__comp(*__child_i, __top));
*__start = _VSTD::move(__top);
}
template <class _Compare, class _RandomAccessIterator>
inline _LIBCPP_INLINE_VISIBILITY
void
@@ -4885,7 +4898,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
if (__len > 1)
{
swap(*__first, *--__last);
__push_heap_front<_Compare>(__first, __last, __comp, __len-1);
__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
}
}
@@ -4922,10 +4935,11 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
difference_type __n = __last - __first;
if (__n > 1)
{
__last = __first;
++__last;
for (difference_type __i = 1; __i < __n;)
__push_heap_back<_Compare>(__first, ++__last, __comp, ++__i);
// start from the first parent, there is no need to consider children
for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
{
__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
}
}
}
@@ -5000,7 +5014,7 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _R
if (__comp(*__i, *__first))
{
swap(*__i, *__first);
__push_heap_front<_Compare>(__first, __middle, __comp, __len);
__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
}
}
__sort_heap<_Compare>(__first, __middle, __comp);
@@ -5041,15 +5055,15 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __r = __result_first;
if (__r != __result_last)
{
typename iterator_traits<_RandomAccessIterator>::difference_type __len = 0;
for (; __first != __last && __r != __result_last; ++__first, ++__r, ++__len)
for (; __first != __last && __r != __result_last; ++__first, ++__r)
*__r = *__first;
__make_heap<_Compare>(__result_first, __r, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
for (; __first != __last; ++__first)
if (__comp(*__first, *__result_first))
{
*__result_first = *__first;
__push_heap_front<_Compare>(__result_first, __r, __comp, __len);
__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
}
__sort_heap<_Compare>(__result_first, __r, __comp);
}

View File

@@ -249,9 +249,9 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
#if __SIZE_WIDTH__ == 64
#if __SIZEOF_SIZE_T__ == 8
: __first_{__v}
#elif __SIZE_WIDTH__ == 32
#elif __SIZEOF_SIZE_T__ == 4
: __first_{__v, __v >> __bits_per_word}
#else
#error This constructor has not been ported to this platform

View File

@@ -38,18 +38,18 @@ class dynarray
public:
// construct/copy/destroy:
explicit dynarray(size_type c);
template <typename Alloc>
dynarray(size_type c, const Alloc& alloc);
dynarray(size_type c, const T& v);
template <typename Alloc>
dynarray(size_type c, const T& v, const Alloc& alloc);
dynarray(const dynarray& d);
template <typename Alloc>
dynarray(const dynarray& d, const Alloc& alloc);
dynarray(initializer_list<T>);
template <typename Alloc>
dynarray(initializer_list<T>, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc);
template <class Alloc>
dynarray(allocator_arg_t, const Alloc& a, initializer_list<T>, const Alloc& alloc);
dynarray& operator=(const dynarray&) = delete;
~dynarray();
@@ -147,12 +147,12 @@ private:
assert(!"dynarray::allocation");
#endif
}
return static_cast<value_type *> (::operator new (sizeof(value_type) * count));
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
}
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept
{
::operator delete (static_cast<void *> (__ptr));
_VSTD::__deallocate (static_cast<void *> (__ptr));
}
public:
@@ -163,15 +163,15 @@ public:
dynarray(initializer_list<value_type>);
// We're not implementing these right now.
// Waiting for the resolution of LWG issue #2235
// Updated with the resolution of LWG issue #2255
// template <typename _Alloc>
// dynarray(size_type __c, const _Alloc& __alloc);
// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c);
// template <typename _Alloc>
// dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc);
// dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v);
// template <typename _Alloc>
// dynarray(const dynarray& __d, const _Alloc& __alloc);
// dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d);
// template <typename _Alloc>
// dynarray(initializer_list<value_type>, const _Alloc& __alloc);
// dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list<value_type>);
dynarray& operator=(const dynarray&) = delete;
~dynarray();

View File

@@ -1421,6 +1421,7 @@ template <class _Tp, class _Alloc>
void
forward_list<_Tp, _Alloc>::remove(const value_type& __v)
{
forward_list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
iterator __e = end();
for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
{
@@ -1429,7 +1430,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
iterator __j = _VSTD::next(__i, 2);
for (; __j != __e && *__j == __v; ++__j)
;
erase_after(__i, __j);
__deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
if (__j == __e)
break;
__i = __j;

View File

@@ -1421,7 +1421,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;}
template <class _R2, class ..._Ap>
_LIBCPP_INLINE_VISIBILITY
static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;}
static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;}
template <class _Fp, bool = !is_same<_Fp, function>::value &&
__invokable<_Fp&, _ArgTypes...>::value>
@@ -1617,13 +1617,6 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
if (__not_null(__f))
{
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(_VSTD::move(__f));
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
@@ -1632,6 +1625,14 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
#endif
_Ap;
_Ap __a(__a0);
if (sizeof(_FF) <= sizeof(__buf_) &&
is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
}
else
{
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
@@ -1857,7 +1858,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename __invoke_of<_Ti&, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
{
return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...);
return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
}
template <class _Ti, class ..._Uj>
@@ -1892,7 +1893,7 @@ typename enable_if
__mu(_Ti&, _Uj& __uj)
{
const size_t _Indx = is_placeholder<_Ti>::value - 1;
return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj));
return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
}
template <class _Ti, class _Uj>
@@ -2019,7 +2020,7 @@ typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
_Args&& __args)
{
return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...);
return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
}
template<class _Fp, class ..._BoundArgs>

View File

@@ -1872,7 +1872,7 @@ template <class _Fp>
__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
: __f_(nullptr)
{
typedef typename remove_reference<_Fp>::type _FR;
typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{
@@ -1897,7 +1897,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
: __f_(nullptr)
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename remove_reference<_Fp>::type _FR;
typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
if (sizeof(_FF) <= sizeof(__buf_))
{

View File

@@ -235,7 +235,7 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
static _LIBCPP_CONSTEXPR const bool is_bounded = true;
static _LIBCPP_CONSTEXPR const bool is_modulo = true;
static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value;
#if __i386__ || __x86_64__
static _LIBCPP_CONSTEXPR const bool traps = true;
@@ -768,7 +768,7 @@ template <class _Tp>
template <class _Tp>
_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
template <class _Tp>
const int numeric_limits<const volatile _Tp>::max_digits10;
_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10;
template <class _Tp>
_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
template <class _Tp>

View File

@@ -214,10 +214,13 @@ struct __list_node_base
pointer __next_;
_LIBCPP_INLINE_VISIBILITY
__list_node_base()
: __prev_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this))),
__next_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this)))
{}
__list_node_base() : __prev_(__self()), __next_(__self()) {}
_LIBCPP_INLINE_VISIBILITY
pointer __self()
{
return static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this));
}
};
template <class _Tp, class _VoidPtr>
@@ -753,20 +756,14 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
swap(__sz(), __c.__sz());
swap(__end_, __c.__end_);
if (__sz() == 0)
__end_.__next_ = __end_.__prev_ = static_cast<__node_pointer>(
pointer_traits<__node_base_pointer>::pointer_to(__end_));
__end_.__next_ = __end_.__prev_ = __end_.__self();
else
__end_.__prev_->__next_ = __end_.__next_->__prev_
= static_cast<__node_pointer>(
pointer_traits<__node_base_pointer>::pointer_to(__end_));
__end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self();
if (__c.__sz() == 0)
__c.__end_.__next_ = __c.__end_.__prev_
= static_cast<__node_pointer>(
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
__c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self();
else
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_
= static_cast<__node_pointer>(
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self();
#if _LIBCPP_DEBUG_LEVEL >= 2
__libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this);
@@ -1059,7 +1056,9 @@ public:
#endif // _LIBCPP_DEBUG_LEVEL >= 2
private:
static void __link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l);
static void __link_nodes (__node_pointer __p, __node_pointer __f, __node_pointer __l);
void __link_nodes_at_front(__node_pointer __f, __node_pointer __l);
void __link_nodes_at_back (__node_pointer __f, __node_pointer __l);
iterator __iterator(size_type __n);
template <class _Comp>
static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
@@ -1081,6 +1080,31 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p
__l->__next_ = __p;
}
// Link in nodes [__f, __l] at the front of the list
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
void
list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l)
{
__f->__prev_ = base::__end_.__self();
__l->__next_ = base::__end_.__next_;
__l->__next_->__prev_ = __l;
base::__end_.__next_ = __f;
}
// Link in nodes [__f, __l] at the front of the list
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
void
list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l)
{
__l->__next_ = base::__end_.__self();
__f->__prev_ = base::__end_.__prev_;
__f->__prev_->__next_ = __f;
base::__end_.__prev_ = __l;
}
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
typename list<_Tp, _Alloc>::iterator
@@ -1502,7 +1526,7 @@ list<_Tp, _Alloc>::push_front(const value_type& __x)
typedef __allocator_destructor<__node_allocator> _Dp;
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
__link_nodes_at_front(__hold.get(), __hold.get());
++base::__sz();
__hold.release();
}
@@ -1515,8 +1539,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x)
typedef __allocator_destructor<__node_allocator> _Dp;
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
pointer_to(base::__end_)), __hold.get(), __hold.get());
__link_nodes_at_back(__hold.get(), __hold.get());
++base::__sz();
__hold.release();
}
@@ -1531,7 +1554,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x)
typedef __allocator_destructor<__node_allocator> _Dp;
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
__link_nodes_at_front(__hold.get(), __hold.get());
++base::__sz();
__hold.release();
}
@@ -1544,8 +1567,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x)
typedef __allocator_destructor<__node_allocator> _Dp;
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
pointer_to(base::__end_)), __hold.get(), __hold.get());
__link_nodes_at_back(__hold.get(), __hold.get());
++base::__sz();
__hold.release();
}
@@ -1561,7 +1583,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
typedef __allocator_destructor<__node_allocator> _Dp;
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
__link_nodes_at_front(__hold.get(), __hold.get());
++base::__sz();
__hold.release();
}
@@ -1575,8 +1597,7 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
typedef __allocator_destructor<__node_allocator> _Dp;
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
pointer_to(base::__end_)), __hold.get(), __hold.get());
__link_nodes_at_back(__hold.get(), __hold.get());
++base::__sz();
__hold.release();
}
@@ -1826,8 +1847,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
__link_nodes_at_back(__r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
}
@@ -2038,14 +2058,18 @@ template <class _Tp, class _Alloc>
void
list<_Tp, _Alloc>::remove(const value_type& __x)
{
for (iterator __i = begin(), __e = end(); __i != __e;)
list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
for (const_iterator __i = begin(), __e = end(); __i != __e;)
{
if (*__i == __x)
{
iterator __j = _VSTD::next(__i);
const_iterator __j = _VSTD::next(__i);
for (; __j != __e && *__j == __x; ++__j)
;
__i = erase(__i, __j);
__deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
__i = __j;
if (__i != __e)
++__i;
}
else
++__i;
@@ -2065,6 +2089,8 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred)
for (; __j != __e && __pred(*__j); ++__j)
;
__i = erase(__i, __j);
if (__i != __e)
++__i;
}
else
++__i;

View File

@@ -417,7 +417,7 @@ int __sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
// and failbit is set in __err.
// Else an iterator pointing to the matching keyword is found. If more than
// one keyword matches, an iterator to the first matching keyword is returned.
// If on exit __b == __e, eofbit is set in __err. If __case_senstive is false,
// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
// __ct is used to force to lower case before comparing characters.
// Examples:
// Keywords: "a", "abb"
@@ -1871,7 +1871,7 @@ public:
};
template <class _CharT>
class _LIBCPP_TYPE_VIS __time_get_c_storage
class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage
{
protected:
typedef basic_string<_CharT> string_type;
@@ -2038,7 +2038,7 @@ template <class _CharT, class _InputIterator>
locale::id
time_get<_CharT, _InputIterator>::id;
// time_get primatives
// time_get primitives
template <class _CharT, class _InputIterator>
void
@@ -2259,7 +2259,7 @@ time_get<_CharT, _InputIterator>::__get_percent(iter_type& __b, iter_type __e,
__err |= ios_base::eofbit;
}
// time_get end primatives
// time_get end primitives
template <class _CharT, class _InputIterator>
_InputIterator
@@ -2509,7 +2509,7 @@ protected:
};
template <class _CharT>
class _LIBCPP_TYPE_VIS __time_get_storage
class _LIBCPP_TYPE_VIS_ONLY __time_get_storage
: public __time_get
{
protected:

View File

@@ -159,7 +159,7 @@ public:
template<typename K>
const_iterator find(const K& x) const; // C++14
template<typename K>
size_type count(const K& x) const;
size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
iterator lower_bound(const key_type& k);
@@ -353,7 +353,7 @@ public:
template<typename K>
const_iterator find(const K& x) const; // C++14
template<typename K>
size_type count(const K& x) const;
size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
iterator lower_bound(const key_type& k);
@@ -846,7 +846,6 @@ public:
explicit map(const key_compare& __comp)
_NOEXCEPT_(
is_nothrow_default_constructible<allocator_type>::value &&
is_nothrow_default_constructible<key_compare>::value &&
is_nothrow_copy_constructible<key_compare>::value)
: __tree_(__vc(__comp)) {}
@@ -1105,6 +1104,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_unique(__k);}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_unique(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
@@ -1587,7 +1592,6 @@ public:
explicit multimap(const key_compare& __comp)
_NOEXCEPT_(
is_nothrow_default_constructible<allocator_type>::value &&
is_nothrow_default_constructible<key_compare>::value &&
is_nothrow_copy_constructible<key_compare>::value)
: __tree_(__vc(__comp)) {}
@@ -1836,6 +1840,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_multi(__k);}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_multi(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}

View File

@@ -1631,9 +1631,9 @@ public:
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
{return _VSTD::addressof(__x);}
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));}
{return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
{::operator delete((void*)__p);}
{_VSTD::__deallocate((void*)__p);}
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
{return size_type(~0) / sizeof(_Tp);}
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
@@ -1721,9 +1721,9 @@ public:
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
{return _VSTD::addressof(__x);}
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));}
{return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
{::operator delete((void*)__p);}
{_VSTD::__deallocate((void*)__p);}
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
{return size_type(~0) / sizeof(_Tp);}
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
@@ -2005,8 +2005,8 @@ public:
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
__tuple_indices<_I2...>)
: __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...),
__second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
: __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
__second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
{}
#endif // _LIBCPP_HAS_NO_VARIADICS
@@ -2019,7 +2019,7 @@ public:
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T1>::value)
__is_nothrow_swappable<_T2>::value)
{
using _VSTD::swap;
swap(__first_, __x.__first_);
@@ -2096,8 +2096,8 @@ public:
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
__tuple_indices<_I2...>)
: _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...),
__second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
: _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
__second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
{}
#endif // _LIBCPP_HAS_NO_VARIADICS
@@ -2110,7 +2110,7 @@ public:
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T1>::value)
__is_nothrow_swappable<_T2>::value)
{
using _VSTD::swap;
swap(__second_, __x.__second_);
@@ -2188,8 +2188,8 @@ public:
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
__tuple_indices<_I2...>)
: _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...),
__first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...)
: _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...),
__first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...)
{}
@@ -2203,7 +2203,7 @@ public:
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T1>::value)
__is_nothrow_swappable<_T2>::value)
{
using _VSTD::swap;
swap(__first_, __x.__first_);
@@ -2278,8 +2278,8 @@ public:
tuple<_Args2...> __second_args,
__tuple_indices<_I1...>,
__tuple_indices<_I2...>)
: _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...),
_T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
: _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
_T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
{}
#endif // _LIBCPP_HAS_NO_VARIADICS
@@ -2292,7 +2292,7 @@ public:
_LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T1>::value)
__is_nothrow_swappable<_T2>::value)
{
}
};
@@ -2375,7 +2375,7 @@ public:
_LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T1>::value)
__is_nothrow_swappable<_T2>::value)
{base::swap(__x);}
};
@@ -2384,7 +2384,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
_NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
__is_nothrow_swappable<_T1>::value)
__is_nothrow_swappable<_T2>::value)
{__x.swap(__y);}
// __same_or_less_cv_qualified
@@ -2401,13 +2401,14 @@ template <class _Ptr1, class _Ptr2>
struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false>
: false_type {};
template <class _Ptr1, class _Ptr2, bool = is_scalar<_Ptr1>::value &&
!is_pointer<_Ptr1>::value>
template <class _Ptr1, class _Ptr2, bool = is_pointer<_Ptr1>::value ||
is_same<_Ptr1, _Ptr2>::value ||
__has_element_type<_Ptr1>::value>
struct __same_or_less_cv_qualified
: __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {};
template <class _Ptr1, class _Ptr2>
struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true>
struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false>
: false_type {};
// default_delete

471
include/module.modulemap Normal file
View File

@@ -0,0 +1,471 @@
module std [system] {
// FIXME: The standard does not require that each of these submodules
// re-exports its imported modules. We should provide an alternative form of
// export that issues a warning if a name from the submodule is used, and
// use that to provide a 'strict mode' for libc++.
module algorithm {
header "algorithm"
export initializer_list
export *
}
module array {
header "array"
export initializer_list
export *
}
module atomic {
header "atomic"
export *
}
module bitset {
header "bitset"
export string
export iosfwd
export *
}
// No submodule for cassert. It fundamentally needs repeated, textual inclusion.
module ccomplex {
header "ccomplex"
export complex
export *
}
module cctype {
header "cctype"
export *
}
module cerrno {
header "cerrno"
/*
export_macros ECONNREFUSED, EIO, ENODEV, ENOTEMPTY, ERANGE,
E2BIG, ECONNRESET, EISCONN, ENOENT, ENOTRECOVERABLE, EROFS,
EACCES, EDEADLK, EISDIR, ENOEXEC, ENOTSOCK, ESPIPE,
EADDRINUSE, EDESTADDRREQ, ELOOP, ENOLCK, ENOTSUP, ESRCH,
EADDRNOTAVAIL, EDOM, EMFILE, ENOLINK, ENOTTY, ETIME,
EAFNOSUPPORT, EEXIST, EMLINK, ENOMEM, ENXIO, ETIMEDOUT,
EAGAIN, EFAULT, EMSGSIZE, ENOMSG, EOPNOTSUPP, ETXTBSY,
EALREADY, EFBIG, ENAMETOOLONG, ENOPROTOOPT, EOVERFLOW, EWOULDBLOCK,
EBADF, EHOSTUNREACH, ENETDOWN, ENOSPC, EOWNERDEAD, EXDEV,
EBADMSG, EIDRM, ENETRESET, ENOSR, EPERM, errno,
EBUSY, EILSEQ, ENETUNREACH, ENOSTR, EPIPE,
ECANCELED, EINPROGRESS, ENFILE, ENOSYS, EPROTO,
ECHILD, EINTR, ENOBUFS, ENOTCONN, EPROTONOSUPPORT,
ECONNABORTED, EINVAL, ENODATA, ENOTDIR, EPROTOTYPE
*/
export *
}
module cfenv {
header "cfenv"
/*
export_macros FE_ALL_EXCEPT, FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW,
FE_UNDERFLOW, FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD,
FE_DFL_ENV
*/
export *
}
module cfloat {
header "cfloat"
/*
export_macros FLT_EVAL_METHOD, FLT_RADIX, FLT_ROUNDS,
FLT_DIG, FLT_EPSILON, FLT_MANT_DIG,
FLT_MAX, FLT_MAX_10_EXP, FLT_MAX_EXP,
FLT_MIN, FLT_MIN_10_EXP, FLT_MIN_EXP,
DBL_DIG, DBL_EPSILON, DBL_MANT_DIG,
DBL_MAX, DBL_MAX_10_EXP, DBL_MAX_EXP,
DBL_MIN, DBL_MIN_10_EXP, DBL_MIN_EXP,
LDBL_DIG, LDBL_EPSILON, LDBL_MANT_DIG,
LDBL_MAX, LDBL_MAX_10_EXP, LDBL_MAX_EXP,
LDBL_MIN, LDBL_MIN_10_EXP, LDBL_MIN_EXP
*/
export *
}
module chrono {
header "chrono"
export *
}
module cinttypes {
header "cinttypes"
export cstdint
/*
export_macros
PRId8, PRId16, PRId32, PRId64, PRIdFAST8, PRIdFAST16, PRIdFAST32, PRIdFAST64, PRIdLEAST8, PRIdLEAST16, PRIdLEAST32, PRIdLEAST64, PRIdMAX, PRIdPTR,
PRIi8, PRIi16, PRIi32, PRIi64, PRIiFAST8, PRIiFAST16, PRIiFAST32, PRIiFAST64, PRIiLEAST8, PRIiLEAST16, PRIiLEAST32, PRIiLEAST64, PRIiMAX, PRIiPTR,
PRIo8, PRIo16, PRIo32, PRIo64, PRIoFAST8, PRIoFAST16, PRIoFAST32, PRIoFAST64, PRIoLEAST8, PRIoLEAST16, PRIoLEAST32, PRIoLEAST64, PRIoMAX, PRIoPTR,
PRIu8, PRIu16, PRIu32, PRIu64, PRIuFAST8, PRIuFAST16, PRIuFAST32, PRIuFAST64, PRIuLEAST8, PRIuLEAST16, PRIuLEAST32, PRIuLEAST64, PRIuMAX, PRIuPTR,
PRIx8, PRIx16, PRIx32, PRIx64, PRIxFAST8, PRIxFAST16, PRIxFAST32, PRIxFAST64, PRIxLEAST8, PRIxLEAST16, PRIxLEAST32, PRIxLEAST64, PRIxMAX, PRIxPTR,
PRIX8, PRIX16, PRIX32, PRIX64, PRIXFAST8, PRIXFAST16, PRIXFAST32, PRIXFAST64, PRIXLEAST8, PRIXLEAST16, PRIXLEAST32, PRIXLEAST64, PRIXMAX, PRIXPTR,
SCNd8, SCNd16, SCNd32, SCNd64, SCNdFAST8, SCNdFAST16, SCNdFAST32, SCNdFAST64, SCNdLEAST8, SCNdLEAST16, SCNdLEAST32, SCNdLEAST64, SCNdMAX, SCNdPTR,
SCNi8, SCNi16, SCNi32, SCNi64, SCNiFAST8, SCNiFAST16, SCNiFAST32, SCNiFAST64, SCNiLEAST8, SCNiLEAST16, SCNiLEAST32, SCNiLEAST64, SCNiMAX, SCNiPTR,
SCNo8, SCNo16, SCNo32, SCNo64, SCNoFAST8, SCNoFAST16, SCNoFAST32, SCNoFAST64, SCNoLEAST8, SCNoLEAST16, SCNoLEAST32, SCNoLEAST64, SCNoMAX, SCNoPTR,
SCNu8, SCNu16, SCNu32, SCNu64, SCNuFAST8, SCNuFAST16, SCNuFAST32, SCNuFAST64, SCNuLEAST8, SCNuLEAST16, SCNuLEAST32, SCNuLEAST64, SCNuMAX, SCNuPTR,
SCNx8, SCNx16, SCNx32, SCNx64, SCNxFAST8, SCNxFAST16, SCNxFAST32, SCNxFAST64, SCNxLEAST8, SCNxLEAST16, SCNxLEAST32, SCNxLEAST64, SCNxMAX, SCNxPTR,
SCNX8, SCNX16, SCNX32, SCNX64, SCNXFAST8, SCNXFAST16, SCNXFAST32, SCNXFAST64, SCNXLEAST8, SCNXLEAST16, SCNXLEAST32, SCNXLEAST64, SCNXMAX, SCNXPTR
*/
export *
}
module ciso646 {
header "ciso646"
export *
}
module climits {
header "climits"
/*
export_macros CHAR_BIT, CHAR_MIN, CHAR_MAX,
SCHAR_MIN, SCHAR_MAX, UCHAR_MAX,
SHRT_MIN, SHRT_MAX, USHRT_MAX,
INT_MIN, INT_MAX, UINT_MAX,
LONG_MIN, LONG_MAX, ULONG_MAX,
LLONG_MIN, LLONG_MAX, ULLONG_MAX,
MB_LEN_MAX
*/
export *
}
module clocale {
header "clocale"
/*
export_macros LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, NULL
*/
export *
}
module cmath {
header "cmath"
/*
export_macros FP_FAST_FMA, FP_FAST_FMAF, FP_FAST_FMAL, FP_ILOGBO, FP_ILOGBNAN,
FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, FP_ZERO,
HUGE_VAL, HUGE_VALF, HUGE_VALL, INFINITY, NAN,
MATH_ERRNO, MATH_ERREXCEPT, math_errhandling
*/
export *
}
module codecvt {
header "codecvt"
export *
}
module complex {
header "complex"
export *
}
module condition_variable {
header "condition_variable"
export *
}
module csetjmp {
header "csetjmp"
/*
export_macros setjmp
*/
export *
}
module csignal {
header "csignal"
/*
export_macros SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM,
SIG_DFL, SIG_IGN, SIG_ERR
*/
export *
}
module cstdarg {
header "cstdarg"
/*
export_macros va_arg, va_start, va_end, va_copy
*/
export *
}
module cstdbool {
header "cstdbool"
/*
export_macros __bool_true_false_are_defined
*/
export *
}
module cstddef {
header "cstddef"
/*
export_macros NULL, offsetof
*/
export *
}
module cstdint {
header "cstdint"
/*
export_macros
INT_8_MIN, INT_8_MAX, UINT_8_MAX, INT_16_MIN, INT_16_MAX, UINT_16_MAX,
INT_32_MIN, INT_32_MAX, UINT_32_MAX, INT_64_MIN, INT_64_MAX, UINT_64_MAX,
INT_FAST8_MIN, INT_FAST8_MAX, UINT_FAST8_MAX, INT_FAST16_MIN, INT_FAST16_MAX, UINT_FAST16_MAX,
INT_FAST32_MIN, INT_FAST32_MAX, UINT_FAST32_MAX, INT_FAST64_MIN, INT_FAST64_MAX, UINT_FAST64_MAX,
INT_LEAST8_MIN, INT_LEAST8_MAX, UINT_LEAST8_MAX, INT_LEAST16_MIN, INT_LEAST16_MAX, UINT_LEAST16_MAX,
INT_LEAST32_MIN, INT_LEAST32_MAX, UINT_LEAST32_MAX, INT_LEAST64_MIN, INT_LEAST64_MAX, UINT_LEAST64_MAX,
INT_MAX_MIN, INT_MAX_MAX, UINT_MAX_MAX, INT_PTR_MIN, INT_PTR_MAX, UINT_PTR_MAX,
PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN, WINT_MAX,
SIZE_MAX
*/
export *
}
module cstdio {
header "cstdio"
/*
export_macros BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_tmpnam, NULL,
SEEK_CUR, SEEK_END, SEEK_SET, TMP_MAX, _IOFBF, _IOLBF,
stdin, stdout, stderr
*/
export *
}
module cstdlib {
header "cstdlib"
/*
export_macros RAND_MAX
*/
export *
}
module cstring {
header "cstring"
/*
export_macros NULL
*/
export *
}
module ctgmath {
header "ctgmath"
export ccomplex
export cmath
export *
}
module ctime {
header "ctime"
/*
export_macros NULL, CLOCKS_PER_SEC
*/
export *
}
module cwchar {
header "cwchar"
/*
export_macros NULL, WCHAR_MAX, WCHAR_MIN, WEOF
*/
export *
}
module cwctype {
header "cwctype"
/*
export_macros WEOF
*/
export *
}
module deque {
header "deque"
export initializer_list
export *
}
module exception {
header "exception"
export *
}
module forward_list {
header "forward_list"
export initializer_list
export *
}
module fstream {
header "fstream"
export *
}
module functional {
header "functional"
export *
}
module future {
header "future"
export *
}
module initializer_list {
header "initializer_list"
export *
}
module iomanip {
header "iomanip"
export *
}
module ios {
header "ios"
export iosfwd
export *
}
module iosfwd {
header "iosfwd"
export *
}
module iostream {
header "iostream"
export ios
export streambuf
export istream
export ostream
export *
}
module istream {
header "istream"
// FIXME: should re-export ios, streambuf?
export *
}
module iterator {
header "iterator"
export *
}
module limits {
header "limits"
export *
}
module list {
header "list"
export initializer_list
export *
}
module locale {
header "locale"
export *
}
module map {
header "map"
export initializer_list
export *
}
module memory {
header "memory"
export *
}
module mutex {
header "mutex"
export *
}
module new {
header "new"
export *
}
module numeric {
header "numeric"
export *
}
module ostream {
header "ostream"
// FIXME: should re-export ios, streambuf?
export *
}
module queue {
header "queue"
export initializer_list
export *
}
module random {
header "random"
export initializer_list
export *
}
module ratio {
header "ratio"
export *
}
module regex {
header "regex"
export initializer_list
export *
}
module scoped_allocator {
header "scoped_allocator"
export *
}
module set {
header "set"
export initializer_list
export *
}
module sstream {
header "sstream"
// FIXME: should re-export istream, ostream, ios, streambuf, string?
export *
}
module stack {
header "stack"
export initializer_list
export *
}
module stdexcept {
header "stdexcept"
export *
}
module streambuf {
header "streambuf"
export *
}
module string {
header "string"
export initializer_list
export *
}
module strstream {
header "strstream"
requires !cplusplus11
}
module system_error {
header "system_error"
export *
}
module thread {
header "thread"
export *
}
module tuple {
header "tuple"
export *
}
module type_traits {
header "type_traits"
export *
}
module typeindex {
header "typeindex"
export *
}
module typeinfo {
header "typeinfo"
export *
}
module unordered_map {
header "unordered_map"
export initializer_list
export *
}
module unordered_set {
header "unordered_set"
export initializer_list
export *
}
module utility {
header "utility"
export initializer_list
export *
}
module valarray {
header "valarray"
export initializer_list
export *
}
module vector {
header "vector"
export initializer_list
export *
}
// FIXME: These should be private.
module __bit_reference { header "__bit_reference" export * }
module __config { header "__config" export * }
module __debug { header "__debug" export * }
module __functional_base { header "__functional_base" export * }
module __hash_table { header "__hash_table" export * }
module __locale { header "__locale" export * }
module __mutex_base { header "__mutex_base" export * }
module __split_buffer { header "__split_buffer" export * }
module __sso_allocator { header "__sso_allocator" export * }
module __std_stream { header "__std_stream" export * }
module __tree { header "__tree" export * }
module __tuple { header "__tuple" export * }
module __undef_min_max { header "__undef_min_max" export * }
}

View File

@@ -425,7 +425,7 @@ lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
#endif // _LIBCPP_HAS_NO_VARIADICS
struct _LIBCPP_TYPE_VIS once_flag;
struct _LIBCPP_TYPE_VIS_ONLY once_flag;
#ifndef _LIBCPP_HAS_NO_VARIADICS

View File

@@ -147,4 +147,24 @@ inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _N
inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {}
inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {}
_LIBCPP_BEGIN_NAMESPACE_STD
inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
return ::operator new(__size);
#else
return __builtin_operator_new(__size);
#endif
}
inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
::operator delete(__ptr);
#else
__builtin_operator_delete(__ptr);
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_NEW

View File

@@ -436,7 +436,6 @@ public:
explicit set(const value_compare& __comp)
_NOEXCEPT_(
is_nothrow_default_constructible<allocator_type>::value &&
is_nothrow_default_constructible<key_compare>::value &&
is_nothrow_copy_constructible<key_compare>::value)
: __tree_(__comp) {}
@@ -664,6 +663,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_unique(__k);}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_unique(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
@@ -842,7 +847,6 @@ public:
explicit multiset(const value_compare& __comp)
_NOEXCEPT_(
is_nothrow_default_constructible<allocator_type>::value &&
is_nothrow_default_constructible<key_compare>::value &&
is_nothrow_copy_constructible<key_compare>::value)
: __tree_(__comp) {}
@@ -1068,6 +1072,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const
{return __tree_.__count_multi(__k);}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_multi(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)

View File

@@ -232,7 +232,7 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
shared_lock() noexcept
shared_lock() _NOEXCEPT
: __m_(nullptr),
__owns_(false)
{}
@@ -244,7 +244,7 @@ public:
{__m_->lock_shared();}
_LIBCPP_INLINE_VISIBILITY
shared_lock(mutex_type& __m, defer_lock_t) noexcept
shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
: __m_(&__m),
__owns_(false)
{}
@@ -288,7 +288,7 @@ public:
shared_lock& operator=(shared_lock const&) = delete;
_LIBCPP_INLINE_VISIBILITY
shared_lock(shared_lock&& __u) noexcept
shared_lock(shared_lock&& __u) _NOEXCEPT
: __m_(__u.__m_),
__owns_(__u.__owns_)
{
@@ -297,7 +297,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
shared_lock& operator=(shared_lock&& __u) noexcept
shared_lock& operator=(shared_lock&& __u) _NOEXCEPT
{
if (__owns_)
__m_->unlock_shared();
@@ -320,14 +320,14 @@ public:
// Setters
_LIBCPP_INLINE_VISIBILITY
void swap(shared_lock& __u) noexcept
void swap(shared_lock& __u) _NOEXCEPT
{
_VSTD::swap(__m_, __u.__m_);
_VSTD::swap(__owns_, __u.__owns_);
}
_LIBCPP_INLINE_VISIBILITY
mutex_type* release() noexcept
mutex_type* release() _NOEXCEPT
{
mutex_type* __m = __m_;
__m_ = nullptr;
@@ -337,13 +337,13 @@ public:
// Getters
_LIBCPP_INLINE_VISIBILITY
bool owns_lock() const noexcept {return __owns_;}
bool owns_lock() const _NOEXCEPT {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
explicit operator bool () const noexcept {return __owns_;}
explicit operator bool () const _NOEXCEPT {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const noexcept {return __m_;}
mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
template <class _Mutex>
@@ -409,7 +409,7 @@ shared_lock<_Mutex>::unlock()
template <class _Mutex>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT
{__x.swap(__y);}
_LIBCPP_END_NAMESPACE_STD

View File

@@ -990,8 +990,80 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
// helper fns for basic_string
// __find
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_INLINE_VISIBILITY __find_first_of(const _CharT *__p, _SizeT __sz,
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__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 _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos > __sz || __sz - __pos < __n)
return __npos;
if (__n == 0)
return __pos;
// if (__n == 1)
// return _VSTD::__find<_CharT, _SizeT, _Traits, __npos>(__p, __sz, *__s, __pos);
const _CharT* __r =
_VSTD::search(__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq);
if (__r == __p + __sz)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
// __rfind
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__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>
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__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);
if (__n > 0 && __r == __p + __pos)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
// __find_first_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find_first_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos >= __sz || __n == 0)
@@ -1003,8 +1075,11 @@ _SizeT _LIBCPP_INLINE_VISIBILITY __find_first_of(const _CharT *__p, _SizeT __sz,
return static_cast<_SizeT>(__r - __p);
}
// __find_last_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_INLINE_VISIBILITY __find_last_of(const _CharT *__p, _SizeT __sz,
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find_last_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__n != 0)
@@ -1024,8 +1099,10 @@ _SizeT _LIBCPP_INLINE_VISIBILITY __find_last_of(const _CharT *__p, _SizeT __sz,
}
// __find_first_not_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_INLINE_VISIBILITY __find_first_not_of(const _CharT *__p, _SizeT __sz,
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find_first_not_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos < __sz)
@@ -1040,7 +1117,8 @@ _SizeT _LIBCPP_INLINE_VISIBILITY __find_first_not_of(const _CharT *__p, _SizeT _
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_INLINE_VISIBILITY __find_first_not_of(const _CharT *__p, _SizeT __sz,
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find_first_not_of(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__pos < __sz)
@@ -1054,8 +1132,10 @@ _SizeT _LIBCPP_INLINE_VISIBILITY __find_first_not_of(const _CharT *__p, _SizeT _
}
// __find_last_not_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_INLINE_VISIBILITY __find_last_not_of(const _CharT *__p, _SizeT __sz,
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find_last_not_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos < __sz)
@@ -1070,7 +1150,8 @@ _SizeT _LIBCPP_INLINE_VISIBILITY __find_last_not_of(const _CharT *__p, _SizeT __
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
_SizeT _LIBCPP_INLINE_VISIBILITY __find_last_not_of(const _CharT *__p, _SizeT __sz,
_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__find_last_not_of(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__pos < __sz)
@@ -2053,11 +2134,13 @@ inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
: __r_(__a)
{
if (__a == __str.__alloc() || !__str.__is_long())
__r_.first().__r = __str.__r_.first().__r;
else
if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
__init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
else
{
__r_.first().__r = __str.__r_.first().__r;
__str.__zero();
}
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
if (__is_long())
@@ -2311,7 +2394,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr");
size_type __cap = capacity();
if (__cap >= __n)
{
@@ -2485,7 +2568,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
{
_LIBCPP_ASSERT(__s != nullptr, "string::assign recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr");
return assign(__s, traits_type::length(__s));
}
@@ -2495,7 +2578,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr");
size_type __cap = capacity();
size_type __sz = size();
if (__cap - __sz >= __n)
@@ -2632,7 +2715,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
{
_LIBCPP_ASSERT(__s != nullptr, "string::append recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr");
return append(__s, traits_type::length(__s));
}
@@ -2642,7 +2725,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr");
size_type __sz = size();
if (__pos > __sz)
this->__throw_out_of_range();
@@ -2794,7 +2877,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
{
_LIBCPP_ASSERT(__s != nullptr, "string::insert recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr");
return insert(__pos, __s, traits_type::length(__s));
}
@@ -2845,7 +2928,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
{
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace recieved nullptr");
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
size_type __sz = size();
if (__pos > __sz)
this->__throw_out_of_range();
@@ -2977,7 +3060,7 @@ template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
{
_LIBCPP_ASSERT(__s != nullptr, "string::replace recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr");
return replace(__pos, __n1, __s, traits_type::length(__s));
}
@@ -3345,18 +3428,9 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
size_type __pos,
size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): recieved nullptr");
size_type __sz = size();
if (__pos > __sz || __sz - __pos < __n)
return npos;
if (__n == 0)
return __pos;
const value_type* __p = data();
const value_type* __r = _VSTD::search(__p + __pos, __p + __sz, __s, __s + __n,
__traits_eq<traits_type>());
if (__r == __p + __sz)
return npos;
return static_cast<size_type>(__r - __p);
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");
return _VSTD::__find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3365,7 +3439,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
size_type __pos) const _NOEXCEPT
{
return find(__str.data(), __pos, __str.size());
return _VSTD::__find<value_type, size_type, traits_type, npos>
(data(), size(), __str.data(), __pos, __str.size());
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3374,8 +3449,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
size_type __pos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::find(): recieved nullptr");
return find(__s, __pos, traits_type::length(__s));
_LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");
return _VSTD::__find<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3383,14 +3459,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
size_type __pos) const _NOEXCEPT
{
size_type __sz = size();
if (__pos >= __sz)
return npos;
const value_type* __p = data();
const value_type* __r = traits_type::find(__p + __pos, __sz - __pos, __c);
if (__r == 0)
return npos;
return static_cast<size_type>(__r - __p);
return _VSTD::__find<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
// rfind
@@ -3401,19 +3471,9 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
size_type __pos,
size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): recieved nullptr");
size_type __sz = size();
__pos = _VSTD::min(__pos, __sz);
if (__n < __sz - __pos)
__pos += __n;
else
__pos = __sz;
const value_type* __p = data();
const value_type* __r = _VSTD::find_end(__p, __p + __pos, __s, __s + __n,
__traits_eq<traits_type>());
if (__n > 0 && __r == __p + __pos)
return npos;
return static_cast<size_type>(__r - __p);
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
return _VSTD::__rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3422,7 +3482,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
size_type __pos) const _NOEXCEPT
{
return rfind(__str.data(), __pos, __str.size());
return _VSTD::__rfind<value_type, size_type, traits_type, npos>
(data(), size(), __str.data(), __pos, __str.size());
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3431,8 +3492,9 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
size_type __pos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::rfind(): recieved nullptr");
return rfind(__s, __pos, traits_type::length(__s));
_LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");
return _VSTD::__rfind<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3440,21 +3502,8 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
size_type __pos) const _NOEXCEPT
{
size_type __sz = size();
if (__sz)
{
if (__pos < __sz)
++__pos;
else
__pos = __sz;
const value_type* __p = data();
for (const value_type* __ps = __p + __pos; __ps != __p;)
{
if (traits_type::eq(*--__ps, __c))
return static_cast<size_type>(__ps - __p);
}
}
return npos;
return _VSTD::__rfind<value_type, size_type, traits_type, npos>
(data(), size(), __c, __pos);
}
// find_first_of
@@ -3465,7 +3514,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
size_type __pos,
size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
return _VSTD::__find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
@@ -3486,7 +3535,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");
return _VSTD::__find_first_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
@@ -3508,7 +3557,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
size_type __pos,
size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
return _VSTD::__find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
@@ -3529,7 +3578,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");
return _VSTD::__find_last_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
@@ -3551,7 +3600,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _
size_type __pos,
size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
return _VSTD::__find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
@@ -3572,7 +3621,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");
return _VSTD::__find_first_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
@@ -3595,7 +3644,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __
size_type __pos,
size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): recieved nullptr");
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
return _VSTD::__find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, __n);
}
@@ -3616,7 +3665,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
size_type __pos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");
return _VSTD::__find_last_not_of<value_type, size_type, traits_type, npos>
(data(), size(), __s, __pos, traits_type::length(__s));
}
@@ -3680,7 +3729,7 @@ template <class _CharT, class _Traits, class _Allocator>
int
basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
return compare(0, npos, __s, traits_type::length(__s));
}
@@ -3690,7 +3739,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
size_type __n1,
const value_type* __s) const
{
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr");
_LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
return compare(__pos1, __n1, __s, traits_type::length(__s));
}
@@ -3701,7 +3750,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
const value_type* __s,
size_type __n2) const
{
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): recieved nullptr");
_LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
size_type __sz = size();
if (__pos1 > __sz || __n2 == npos)
this->__throw_out_of_range();

View File

@@ -210,7 +210,13 @@ public:
"Attempted to default construct a reference element in a tuple");}
template <class _Tp,
class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
class = typename enable_if<
__lazy_and<
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
, is_constructible<_Hp, _Tp>
>::value
>::type
>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
: value(_VSTD::forward<_Tp>(__t))
@@ -268,17 +274,8 @@ public:
>::value)),
"Attempted to construct a reference element in a tuple with an rvalue");}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
: value(__t.get())
{static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value)
: value(_VSTD::forward<_Hp>(__t.get()))
{}
__tuple_leaf(const __tuple_leaf& __t) = default;
__tuple_leaf(__tuple_leaf&& __t) = default;
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
@@ -325,7 +322,13 @@ public:
: _Hp(__a) {}
template <class _Tp,
class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
class = typename enable_if<
__lazy_and<
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
, is_constructible<_Hp, _Tp>
>::value
>::type
>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
: _Hp(_VSTD::forward<_Tp>(__t)) {}
@@ -345,6 +348,9 @@ public:
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: _Hp(_VSTD::forward<_Tp>(__t), __a) {}
__tuple_leaf(__tuple_leaf const &) = default;
__tuple_leaf(__tuple_leaf &&) = default;
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf&
@@ -863,7 +869,7 @@ struct __tuple_equal
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool operator()(const _Tp& __x, const _Up& __y)
{
return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
}
};
@@ -902,7 +908,7 @@ struct __tuple_less
bool operator()(const _Tp& __x, const _Up& __y)
{
return __tuple_less<_Ip-1>()(__x, __y) ||
(!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
(!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y));
}
};
@@ -1051,8 +1057,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
}
template <class _Tuple0, class _Tuple1, class ..._Tuples>
@@ -1067,8 +1073,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
(forward_as_tuple(
_VSTD::forward<_Types>(get<_I0>(__t))...,
get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
),
_VSTD::forward<_Tuple1>(__t1),
_VSTD::forward<_Tuples>(__tpls)...);
@@ -1097,8 +1103,8 @@ inline _LIBCPP_INLINE_VISIBILITY
pair<_T1, _T2>::pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
: first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
: first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
{
}

View File

@@ -376,13 +376,9 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public t
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
#endif
#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#define _LIBCPP_HAS_TYPE_TRAITS
#endif
// is_union
#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(is_union) || (_GNUC_VER >= 403)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
: public integral_constant<bool, __is_union(_Tp)> {};
@@ -397,7 +393,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
// is_class
#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(is_class) || (_GNUC_VER >= 403)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
: public integral_constant<bool, __is_class(_Tp)> {};
@@ -484,7 +480,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
// is_enum
#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(is_enum) || (_GNUC_VER >= 403)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
: public integral_constant<bool, __is_enum(_Tp)> {};
@@ -797,7 +793,7 @@ template <class _Bp, class _Dp>
struct _LIBCPP_TYPE_VIS_ONLY is_base_of
: public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
#else // __has_feature(is_base_of)
#else // _LIBCPP_HAS_IS_BASE_OF
namespace __is_base_of_imp
{
@@ -822,7 +818,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of
: public integral_constant<bool, is_class<_Bp>::value &&
sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
#endif // __has_feature(is_base_of)
#endif // _LIBCPP_HAS_IS_BASE_OF
// is_convertible
@@ -945,7 +941,7 @@ template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
// is_empty
#if __has_feature(is_empty)
#if __has_feature(is_empty) || (_GNUC_VER >= 407)
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_empty
@@ -996,17 +992,17 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
// has_virtual_destructor
#if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
: public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
#else // _LIBCPP_HAS_TYPE_TRAITS
#else
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
: public false_type {};
#endif // _LIBCPP_HAS_TYPE_TRAITS
#endif
// alignment_of
@@ -1541,42 +1537,61 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
// is_destructible
template <class _Tp>
struct __destructible_test
{
_Tp __t;
// if it's a reference, return true
// if it's a function, return false
// if it's void, return false
// if it's an array of unknown bound, return false
// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
// where _Up is remove_all_extents<_Tp>::type
template <class>
struct __is_destructible_apply { typedef int type; };
template <typename _Tp>
struct __is_destructor_wellformed {
template <typename _Tp1>
static char __test (
typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
);
template <typename _Tp1>
static __two __test (...);
static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
};
template <class _Tp, bool>
struct __destructible_imp;
template <class _Tp>
decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type()))
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__is_destructible_test(_Tp&&);
#else
__is_destructible_test(_Tp&);
#endif
false_type
__is_destructible_test(__any);
template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value
|| is_function<_Tp>::value>
struct __destructible_imp
: public common_type
<
decltype(__is_destructible_test(declval<_Tp>()))
>::type {};
struct __destructible_imp<_Tp, false>
: public _VSTD::integral_constant<bool,
__is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
template <class _Tp>
struct __destructible_imp<_Tp, true>
: public false_type {};
: public _VSTD::true_type {};
template <class _Tp, bool>
struct __destructible_false;
template <class _Tp>
struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
template <class _Tp>
struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
template <class _Tp>
struct is_destructible
: public __destructible_imp<_Tp> {};
: public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
template <class _Tp>
struct is_destructible<_Tp[]>
: public false_type {};
: public _VSTD::false_type {};
template <>
struct is_destructible<void>
: public _VSTD::false_type {};
// move
@@ -1682,6 +1697,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
{
@@ -1690,6 +1713,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
{
@@ -1698,6 +1729,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, fa
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
{
@@ -1706,6 +1745,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, tr
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
#if __has_feature(cxx_reference_qualified_functions)
template <class _Rp, class _Class, class ..._Param>
@@ -1716,6 +1763,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
{
typedef _Class& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
{
@@ -1724,6 +1779,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, fals
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
{
typedef _Class const& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
{
@@ -1732,6 +1795,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, f
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
{
typedef _Class volatile& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
{
@@ -1740,6 +1811,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, t
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
{
typedef _Class const volatile& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
{
@@ -1748,6 +1827,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
{
typedef _Class&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
{
@@ -1756,6 +1843,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, fal
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
{
typedef _Class const&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
{
@@ -1764,6 +1859,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true,
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
{
typedef _Class volatile&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
{
@@ -1772,6 +1875,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&,
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
{
typedef _Class const volatile&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
#endif // __has_feature(cxx_reference_qualified_functions)
#else // _LIBCPP_HAS_NO_VARIADICS
@@ -1784,6 +1895,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
typedef _Rp (_FnType) ();
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (...);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
{
@@ -1792,6 +1911,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
typedef _Rp (_FnType) (_P0);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, ...);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
{
@@ -1800,6 +1927,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
typedef _Rp (_FnType) (_P0, _P1);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, ...);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
{
@@ -1808,6 +1943,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
typedef _Rp (_FnType) (_P0, _P1, _P2);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
{
@@ -1816,6 +1959,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
typedef _Rp (_FnType) ();
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (...);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
{
@@ -1824,6 +1975,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
typedef _Rp (_FnType) (_P0);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, ...);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
{
@@ -1832,6 +1991,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
typedef _Rp (_FnType) (_P0, _P1);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, ...);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
{
@@ -1840,6 +2007,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, f
typedef _Rp (_FnType) (_P0, _P1, _P2);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
{
@@ -1848,6 +2023,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
typedef _Rp (_FnType) ();
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (...);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
{
@@ -1856,6 +2039,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
typedef _Rp (_FnType) (_P0);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, ...);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
{
@@ -1864,6 +2055,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, fal
typedef _Rp (_FnType) (_P0, _P1);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, ...);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
{
@@ -1872,6 +2071,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true
typedef _Rp (_FnType) (_P0, _P1, _P2);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
{
@@ -1880,6 +2087,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false
typedef _Rp (_FnType) ();
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (...);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
{
@@ -1888,6 +2103,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, fa
typedef _Rp (_FnType) (_P0);
};
template <class _Rp, class _Class, class _P0>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, ...);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
{
@@ -1896,6 +2119,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, tru
typedef _Rp (_FnType) (_P0, _P1);
};
template <class _Rp, class _Class, class _P0, class _P1>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, ...);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
{
@@ -1904,6 +2135,14 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile
typedef _Rp (_FnType) (_P0, _P1, _P2);
};
template <class _Rp, class _Class, class _P0, class _P1, class _P2>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
};
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Rp, class _Class>
@@ -2076,10 +2315,24 @@ class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
#endif // _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_HAS_NO_VARIADICS
// template <class T, class... Args> struct is_constructible;
namespace __is_construct
{
struct __nat {};
}
#if __has_feature(is_constructible)
template <class _Tp, class ..._Args>
struct _LIBCPP_TYPE_VIS_ONLY is_constructible
: public integral_constant<bool, __is_constructible(_Tp, _Args...)>
{};
#else
#ifndef _LIBCPP_HAS_NO_VARIADICS
// main is_constructible test
template <class _Tp, class ..._Args>
@@ -2307,13 +2560,6 @@ struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
// is_constructible entry point
namespace __is_construct
{
struct __nat {};
}
template <class _Tp, class _A0 = __is_construct::__nat,
class _A1 = __is_construct::__nat>
struct _LIBCPP_TYPE_VIS_ONLY is_constructible
@@ -2378,6 +2624,7 @@ struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
{};
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // __has_feature(is_constructible)
// is_default_constructible
@@ -2426,7 +2673,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_trivial_constructor(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2555,7 +2802,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl
// is_trivially_assignable
#if __has_feature(is_trivially_constructible)
#if __has_feature(is_trivially_assignable)
template <class _Tp, class _Arg>
struct is_trivially_assignable
@@ -2563,7 +2810,7 @@ struct is_trivially_assignable
{
};
#else // !__has_feature(is_trivially_constructible)
#else // !__has_feature(is_trivially_assignable)
template <class _Tp, class _Arg>
struct is_trivially_assignable
@@ -2589,7 +2836,7 @@ struct is_trivially_assignable<_Tp&, _Tp&&>
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !__has_feature(is_trivially_constructible)
#endif // !__has_feature(is_trivially_assignable)
// is_trivially_copy_assignable
@@ -2611,12 +2858,12 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
// is_trivially_destructible
#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
: public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
#else // _LIBCPP_HAS_TYPE_TRAITS
#else
template <class _Tp> struct __libcpp_trivial_destructor
: public integral_constant<bool, is_scalar<_Tp>::value ||
@@ -2625,7 +2872,7 @@ template <class _Tp> struct __libcpp_trivial_destructor
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
: public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
#endif // _LIBCPP_HAS_TYPE_TRAITS
#endif
// is_nothrow_constructible
@@ -2640,7 +2887,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
#ifndef _LIBCPP_HAS_NO_VARIADICS
#if __has_feature(cxx_noexcept)
#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
template <bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
@@ -2678,7 +2925,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_constructor(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2692,7 +2939,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
#else
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
#endif
#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_copy(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2702,7 +2949,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_copy(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2712,7 +2959,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_copy(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2734,7 +2981,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
__is_construct::__nat>
#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_constructor(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2745,7 +2992,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
__is_construct::__nat>
#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_copy(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2756,7 +3003,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
__is_construct::__nat>
#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_copy(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2767,7 +3014,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
__is_construct::__nat>
#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_copy(_Tp)>
#else
: integral_constant<bool, is_scalar<_Tp>::value>
@@ -2802,7 +3049,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
// is_nothrow_assignable
#if __has_feature(cxx_noexcept)
#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
@@ -2832,7 +3079,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2840,7 +3087,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2848,7 +3095,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2858,7 +3105,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
template <class _Tp>
struct is_nothrow_assignable<_Tp&, _Tp&&>
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2888,7 +3135,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
// is_nothrow_destructible
#if __has_feature(cxx_noexcept)
#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
@@ -2945,12 +3192,12 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
// is_pod
#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#if __has_feature(is_pod) || (_GNUC_VER >= 403)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
: public integral_constant<bool, __is_pod(_Tp)> {};
#else // _LIBCPP_HAS_TYPE_TRAITS
#else
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
: public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
@@ -2958,13 +3205,13 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
is_trivially_copy_assignable<_Tp>::value &&
is_trivially_destructible<_Tp>::value> {};
#endif // _LIBCPP_HAS_TYPE_TRAITS
#endif
// is_literal_type;
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
#if __has_feature(is_literal)
: public integral_constant<bool, __is_literal(_Tp)>
#ifdef _LIBCPP_IS_LITERAL
: public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
#else
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
is_reference<typename remove_all_extents<_Tp>::type>::value>
@@ -2974,7 +3221,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
// is_standard_layout;
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
#if __has_feature(is_standard_layout)
#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
: public integral_constant<bool, __is_standard_layout(_Tp)>
#else
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
@@ -2994,7 +3241,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
// is_trivial;
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
#if __has_feature(is_trivial)
#if __has_feature(is_trivial) || (_GNUC_VER >= 407)
: public integral_constant<bool, __is_trivial(_Tp)>
#else
: integral_constant<bool, is_trivially_copyable<_Tp>::value &&
@@ -3324,7 +3571,7 @@ struct __is_swappable
{
};
#if __has_feature(cxx_noexcept)
#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
template <bool, class _Tp>
struct __is_nothrow_swappable_imp
@@ -3355,19 +3602,19 @@ struct __is_nothrow_swappable
#endif // __has_feature(cxx_noexcept)
#ifdef _LIBCXX_UNDERLYING_TYPE
#ifdef _LIBCPP_UNDERLYING_TYPE
template <class _Tp>
struct underlying_type
{
typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
};
#if _LIBCPP_STD_VER > 11
template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
#endif
#else // _LIBCXX_UNDERLYING_TYPE
#else // _LIBCPP_UNDERLYING_TYPE
template <class _Tp, bool _Support = false>
struct underlying_type
@@ -3377,7 +3624,7 @@ struct underlying_type
"libc++ does not know how to use it.");
};
#endif // _LIBCXX_UNDERLYING_TYPE
#endif // _LIBCPP_UNDERLYING_TYPE
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE

View File

@@ -116,7 +116,7 @@ public:
{return *reinterpret_cast<const size_t*>(&__type_name);}
#else
{if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
const char *__ptr = __name_for_load();
const char *__ptr = name();
size_t __hash = 5381;
while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
__hash = (__hash * 33) ^ __c;
@@ -141,15 +141,7 @@ public:
private:
_LIBCPP_INLINE_VISIBILITY
int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
{return __builtin_strcmp(__name_for_load(), __arg.__name_for_load());}
_LIBCPP_INLINE_VISIBILITY
const char *__name_for_load() const _NOEXCEPT
{uintptr_t __data = __type_name;
#if 1
__data &= ~_LIBCPP_NONUNIQUE_RTTI_BIT;
#endif
return reinterpret_cast<const char*>(__data);}
{return __builtin_strcmp(name(), __arg.name());}
#endif
};

View File

@@ -345,9 +345,9 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_Tuple&& __p)
: first(_VSTD::forward<typename tuple_element<0,
typename __make_tuple_types<_Tuple>::type>::type>(get<0>(__p))),
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<0>(__p))),
second(_VSTD::forward<typename tuple_element<1,
typename __make_tuple_types<_Tuple>::type>::type>(get<1>(__p)))
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p)))
{}

View File

@@ -345,6 +345,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
#include <initializer_list>
#include <algorithm>
#include <functional>
#include <new>
#include <__undef_min_max>
@@ -1219,6 +1220,7 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const
const value_type* __s = __sa.__vp_;
for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
*__t = *__s;
return *this;
}
template <class _Tp>
@@ -2089,6 +2091,7 @@ mask_array<_Tp>::operator=(const mask_array& __ma) const
size_t __n = __1d_.size();
for (size_t __i = 0; __i < __n; ++__i)
__vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
return *this;
}
template <class _Tp>
@@ -2636,7 +2639,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
{
__r.__begin_ =
__r.__end_ =
static_cast<result_type*>(::operator new(__n * sizeof(result_type)));
static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
::new (__r.__end_) result_type(__expr_[__i]);
}
@@ -2670,7 +2673,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
{
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2695,7 +2698,7 @@ valarray<_Tp>::valarray(const valarray& __v)
{
if (__v.size())
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__v.size() * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2736,7 +2739,7 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
size_t __n = __il.size();
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2764,7 +2767,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
size_t __n = __sa.__size_;
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2790,7 +2793,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
size_t __n = __ga.__1d_.size();
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2819,7 +2822,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
size_t __n = __ma.__1d_.size();
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -2848,7 +2851,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
size_t __n = __ia.__1d_.size();
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
@@ -3133,7 +3136,7 @@ valarray<_Tp>::operator+() const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(+*__p);
}
@@ -3150,7 +3153,7 @@ valarray<_Tp>::operator-() const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(-*__p);
}
@@ -3167,7 +3170,7 @@ valarray<_Tp>::operator~() const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(~*__p);
}
@@ -3184,7 +3187,7 @@ valarray<_Tp>::operator!() const
{
__r.__begin_ =
__r.__end_ =
static_cast<bool*>(::operator new(__n * sizeof(bool)));
static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) bool(!*__p);
}
@@ -3504,7 +3507,7 @@ valarray<_Tp>::shift(int __i) const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
const value_type* __sb;
value_type* __tb;
value_type* __te;
@@ -3542,7 +3545,7 @@ valarray<_Tp>::cshift(int __i) const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
__i %= static_cast<int>(__n);
const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
@@ -3563,7 +3566,7 @@ valarray<_Tp>::apply(value_type __f(value_type)) const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(__f(*__p));
}
@@ -3580,7 +3583,7 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const
{
__r.__begin_ =
__r.__end_ =
static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
::new (__r.__end_) value_type(__f(*__p));
}
@@ -3595,12 +3598,12 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
{
while (__end_ != __begin_)
(--__end_)->~value_type();
::operator delete(__begin_);
_VSTD::__deallocate(__begin_);
__begin_ = __end_ = nullptr;
}
if (__n)
{
__begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
__begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{

View File

@@ -483,6 +483,7 @@ class _LIBCPP_TYPE_VIS_ONLY vector
{
private:
typedef __vector_base<_Tp, _Allocator> __base;
typedef allocator<_Tp> __default_allocator_type;
public:
typedef vector __self;
typedef _Tp value_type;
@@ -749,7 +750,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{
size_type __old_size = size();
__base::clear();
__annotate_shrink(__old_size);
__invalidate_all_iterators();
}
@@ -816,7 +819,9 @@ private:
}
__get_db()->unlock();
#endif
size_type __old_size = size();
__base::__destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
template <class _Up>
void
@@ -830,17 +835,52 @@ private:
void
__emplace_back_slow_path(_Args&&... __args);
#endif
// The following functions are no-ops outside of AddressSanitizer mode.
// We call annotatations only for the default Allocator because other allocators
// may not meet the AddressSanitizer alignment constraints.
// See the documentation for __sanitizer_annotate_contiguous_container for more details.
void __annotate_contiguous_container
(const void *__beg, const void *__end, const void *__old_mid, const void *__new_mid)
{
#ifndef _LIBCPP_HAS_NO_ASAN
if (__beg && is_same<allocator_type, __default_allocator_type>::value)
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
#endif
}
void __annotate_new(size_type __current_size)
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + capacity(), data() + __current_size);
}
void __annotate_delete()
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + capacity());
}
void __annotate_increase(size_type __n)
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + size() + __n);
}
void __annotate_shrink(size_type __old_size)
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + __old_size, data() + size());
}
};
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
{
__annotate_delete();
__alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
__invalidate_all_iterators();
}
@@ -848,6 +888,7 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::pointer
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
{
__annotate_delete();
pointer __r = __v.__begin_;
__alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_);
__alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_);
@@ -855,6 +896,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
__invalidate_all_iterators();
return __r;
}
@@ -874,6 +916,7 @@ vector<_Tp, _Allocator>::allocate(size_type __n)
this->__throw_length_error();
this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
this->__end_cap() = this->__begin_ + __n;
__annotate_new(0);
}
template <class _Tp, class _Allocator>
@@ -920,6 +963,7 @@ void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
allocator_type& __a = this->__alloc();
__annotate_increase(__n);
do
{
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
@@ -940,6 +984,7 @@ void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
allocator_type& __a = this->__alloc();
__annotate_increase(__n);
do
{
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x);
@@ -960,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
allocator_type& __a = this->__alloc();
for (; __first != __last; ++__first)
{
__annotate_increase(1);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
++this->__end_;
}
@@ -972,6 +1018,7 @@ vector<_Tp, _Allocator>::__move_construct_at_end(pointer __first, pointer __last
allocator_type& __a = this->__alloc();
for (; __first != __last; ++__first)
{
__annotate_increase(1);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
_VSTD::move(*__first));
++this->__end_;
@@ -1284,10 +1331,10 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
deallocate();
__base::__move_assign_alloc(__c); // this can throw
this->__begin_ = __c.__begin_;
this->__end_ = __c.__end_;
this->__end_cap() = __c.__end_cap();
__base::__move_assign_alloc(__c);
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->swap(this, &__c);
@@ -1535,6 +1582,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
{
if (this->__end_ != this->__end_cap())
{
__annotate_increase(1);
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_), __x);
++this->__end_;
@@ -1552,6 +1600,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
{
if (this->__end_ < this->__end_cap())
{
__annotate_increase(1);
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::move(__x));
@@ -1584,6 +1633,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
if (this->__end_ < this->__end_cap())
{
__annotate_increase(1);
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::forward<_Args>(__args)...);
@@ -1666,6 +1716,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
pointer __p = this->__begin_ + (__position - begin());
if (this->__end_ < this->__end_cap())
{
__annotate_increase(1);
if (__p == this->__end_)
{
__alloc_traits::construct(this->__alloc(),
@@ -1705,6 +1756,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
pointer __p = this->__begin_ + (__position - begin());
if (this->__end_ < this->__end_cap())
{
__annotate_increase(1);
if (__p == this->__end_)
{
__alloc_traits::construct(this->__alloc(),
@@ -1743,6 +1795,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
pointer __p = this->__begin_ + (__position - begin());
if (this->__end_ < this->__end_cap())
{
__annotate_increase(1);
if (__p == this->__end_)
{
__alloc_traits::construct(this->__alloc(),
@@ -1794,6 +1847,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
}
if (__n > 0)
{
__annotate_increase(__n);
__move_range(__p, __old_last, __p + __old_n);
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
if (__p <= __xr && __xr < this->__end_)
@@ -1904,6 +1958,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
}
if (__n > 0)
{
__annotate_increase(__n);
__move_range(__p, __old_last, __p + __old_n);
_VSTD::copy(__first, __m, __p);
}
@@ -2297,7 +2352,7 @@ private:
void deallocate() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static size_type __align_it(size_type __new_size) _NOEXCEPT
{return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);};
{return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);};
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
_LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
template <class _ForwardIterator>
@@ -2796,10 +2851,10 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
deallocate();
__move_assign_alloc(__c);
this->__begin_ = __c.__begin_;
this->__size_ = __c.__size_;
this->__cap() = __c.__cap();
__move_assign_alloc(__c);
__c.__begin_ = nullptr;
__c.__cap() = __c.__size_ = 0;
}

View File

@@ -32,7 +32,7 @@ else()
endif()
if (DEFINED LIBCXX_CXX_ABI_DEPS)
add_dependencies(cxx ${LIBCXX_CXX_ABI_DEPS})
add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
endif()
# Generate library list.
@@ -54,7 +54,7 @@ if ( APPLE )
list(APPEND compile_flags "-U__STRICT_ANSI__")
list(APPEND link_flags
"-compatibility_version 1"
"-current_version ${LIBCXX_VERSION}"
"-current_version 1"
"-install_name /usr/lib/libc++.1.dylib"
"-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
@@ -84,6 +84,7 @@ if ( APPLE )
endif()
endif()
string(REPLACE ";" " " compile_flags "${compile_flags}")
string(REPLACE ";" " " link_flags "${link_flags}")
set_target_properties(cxx
@@ -96,6 +97,6 @@ set_target_properties(cxx
)
install(TARGETS cxx
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
)

View File

@@ -50,7 +50,7 @@ case $TRIPLE in
RC_CFLAGS="-arch i386 -arch x86_64"
fi
SOEXT=dylib
if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ]
if [ "$MACOSX_DEPLOYMENT_TARGET" = "10.6" ]
then
EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__"
LDSHARED_FLAGS="-o libc++.1.dylib \
@@ -106,7 +106,7 @@ case $TRIPLE in
hostOS=`echo $hostOS | sed -e "s/\s+$//"`
hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'`
if [ $hostOS == "linux" ]
if [ $hostOS = "linux" ]
then
LDSHARED_FLAGS="-o libc++.so.1 \
-qmkshrobj -Wl,-soname,libc++.so.1 \
@@ -158,7 +158,7 @@ case $TRIPLE in
*-*-mingw*)
;;
*-ibm-*)
if [ $hostOS == "linux" ]
if [ $hostOS = "linux" ]
then
rm -f libc++.so
ln -s libc++.so.1 libc++.so

View File

@@ -136,7 +136,7 @@ const unsigned indices[] =
// The algorithm creates a list of small primes, plus an open-ended list of
// potential primes. All prime numbers are potential prime numbers. However
// some potential prime numbers are not prime. In an ideal world, all potential
// prime numbers would be prime. Candiate prime numbers are chosen as the next
// prime numbers would be prime. Candidate prime numbers are chosen as the next
// highest potential prime. Then this number is tested for prime by dividing it
// by all potential prime numbers less than the sqrt of the candidate.
//

View File

@@ -305,7 +305,7 @@ void
ios_base::copyfmt(const ios_base& rhs)
{
// If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
// Don't alter *this until all needed resources are aquired
// Don't alter *this until all needed resources are acquired
unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
unique_ptr<int, void (*)(void*)> new_ints(0, free);
unique_ptr<long, void (*)(void*)> new_longs(0, free);

View File

@@ -49,7 +49,7 @@ random_device::operator()()
random_device::random_device(const string& __token)
: __f_(open(__token.c_str(), O_RDONLY))
{
if (__f_ <= 0)
if (__f_ < 0)
__throw_system_error(errno, ("random_device failed to open " + __token).c_str());
}
@@ -62,7 +62,22 @@ unsigned
random_device::operator()()
{
unsigned r;
read(__f_, &r, sizeof(r));
size_t n = sizeof(r);
char* p = reinterpret_cast<char*>(&r);
while (n > 0)
{
ssize_t s = read(__f_, p, n);
if (s == 0)
__throw_system_error(ENODATA, "random_device got EOF");
if (s == -1)
{
if (errno != EINTR)
__throw_system_error(errno, "random_device got an unexpected error");
continue;
}
n -= static_cast<size_t>(s);
p += static_cast<size_t>(s);
}
return r;
}
#endif // defined(_WIN32)

View File

@@ -107,8 +107,8 @@ size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
// Converts max_source_chars from the wide character buffer pointer to by *src,
// into the multi byte character sequence buffer stored at dst which must be
// dst_size_bytes bytes in size.
// Returns >= 0: the number of bytes in the sequence sequence
// converted frome *src, excluding the null terminator.
// Returns >= 0: the number of bytes in the sequence
// converted from *src, excluding the null terminator.
// Returns size_t(-1) if an error occurs, also sets errno.
// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst
// and no "out" parameters are updated.

View File

@@ -121,7 +121,9 @@ sleep_for(const chrono::nanoseconds& ns)
ts.tv_sec = ts_sec_max;
ts.tv_nsec = giga::num - 1;
}
nanosleep(&ts, 0);
while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
;
}
}

View File

@@ -14,7 +14,7 @@ if(PYTHONINTERP_FOUND)
set(LIT_EXECUTABLE "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
endif()
set(LIT_ARGS_DEFAULT "-sv")
set(LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail")
if (MSVC OR XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
@@ -28,7 +28,6 @@ if(PYTHONINTERP_FOUND)
set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")

View File

@@ -23,6 +23,9 @@
#endif
#include "test_iterators.h"
#include "counting_predicates.hpp"
bool equal2 ( int i ) { return i == 2; }
template <class Iter>
void
@@ -30,7 +33,9 @@ test()
{
int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int* r = std::remove_if(ia, ia+sa, std::bind2nd(std::equal_to<int>(), 2));
// int* r = std::remove_if(ia, ia+sa, std::bind2nd(std::equal_to<int>(), 2));
unary_counting_predicate<bool(*)(int), int> cp(equal2);
int* r = std::remove_if(ia, ia+sa, std::ref(cp));
assert(r == ia + sa-3);
assert(ia[0] == 0);
assert(ia[1] == 1);
@@ -38,6 +43,7 @@ test()
assert(ia[3] == 4);
assert(ia[4] == 3);
assert(ia[5] == 4);
assert(cp.count() == sa);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -17,6 +17,9 @@
#include <algorithm>
#include <functional>
#include <cassert>
#include "counting_predicates.hpp"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -32,11 +35,43 @@ struct indirect_less
void test(unsigned N)
{
int* ia = new int [N];
{
for (int i = 0; i < N; ++i)
ia[i] = i;
std::random_shuffle(ia, ia+N);
std::make_heap(ia, ia+N, std::greater<int>());
assert(std::is_heap(ia, ia+N, std::greater<int>()));
}
// Ascending
{
binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
for (int i = 0; i < N; ++i)
ia[i] = i;
std::make_heap(ia, ia+N, std::ref(pred));
assert(pred.count() <= 3*N);
assert(std::is_heap(ia, ia+N, pred));
}
// Descending
{
binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
for (int i = 0; i < N; ++i)
ia[N-1-i] = i;
std::make_heap(ia, ia+N, std::ref(pred));
assert(pred.count() <= 3*N);
assert(std::is_heap(ia, ia+N, pred));
}
// Random
{
binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
std::random_shuffle(ia, ia+N);
std::make_heap(ia, ia+N, std::ref(pred));
assert(pred.count() <= 3*N);
assert(std::is_heap(ia, ia+N, pred));
}
delete [] ia;
}
@@ -48,6 +83,8 @@ int main()
test(3);
test(10);
test(1000);
test(10000);
test(100000);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{

View File

@@ -27,12 +27,12 @@ test()
int ia[] = {1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[] = {1, 2, 3};
assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+2));
assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa));
assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3));
assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa));
assert(std::lexicographical_compare(ia, ia+sa, ib+1, ib+3));
assert(!std::lexicographical_compare(ib+1, ib+3, ia, ia+sa));
assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+2)));
assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+2), Iter2(ia), Iter2(ia+sa)));
assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+3)));
assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+3), Iter2(ia), Iter2(ia+sa)));
assert( std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib+1), Iter2(ib+3)));
assert(!std::lexicographical_compare(Iter1(ib+1), Iter1(ib+3), Iter2(ia), Iter2(ia+sa)));
}
int main()

View File

@@ -31,12 +31,12 @@ test()
int ib[] = {1, 2, 3};
typedef std::greater<int> C;
C c;
assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+2, c));
assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa, c));
assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3, c));
assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa, c));
assert(!std::lexicographical_compare(ia, ia+sa, ib+1, ib+3, c));
assert(std::lexicographical_compare(ib+1, ib+3, ia, ia+sa, c));
assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+2), c));
assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+2), Iter2(ia), Iter2(ia+sa), c));
assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+3), c));
assert( std::lexicographical_compare(Iter1(ib), Iter1(ib+3), Iter2(ia), Iter2(ia+sa), c));
assert(!std::lexicographical_compare(Iter1(ia), Iter1(ia+sa), Iter2(ib+1), Iter2(ib+3), c));
assert( std::lexicographical_compare(Iter1(ib+1), Iter1(ib+3), Iter2(ia), Iter2(ia+sa), c));
}
int main()

View File

@@ -58,10 +58,28 @@ test()
test<Iter>(1000);
}
template <class Iter, class Pred>
void test_eq0(Iter first, Iter last, Pred p)
{
assert(first == std::max_element(first, last, p));
}
void test_eq()
{
const size_t N = 10;
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 10; // all the same
test_eq0(a, a+N, std::less<int>());
test_eq0(a, a+N, std::greater<int>());
delete [] a;
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test_eq();
}

View File

@@ -58,10 +58,28 @@ test()
test<Iter>(1000);
}
template <class Iter, class Pred>
void test_eq0(Iter first, Iter last, Pred p)
{
assert(first == std::min_element(first, last, p));
}
void test_eq()
{
const size_t N = 10;
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 10; // all the same
test_eq0(a, a+N, std::less<int>());
test_eq0(a, a+N, std::greater<int>());
delete [] a;
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test_eq();
}

View File

@@ -48,7 +48,7 @@ int main()
#if _LIBCPP_STD_VER > 11
{
// Note that you can't take a reference to a local var, since
// it's address is not a compile-time constant.
// its address is not a compile-time constant.
constexpr static int x = 1;
constexpr static int y = 0;
constexpr auto p1 = std::minmax (x, y);

View File

@@ -51,7 +51,7 @@ int main()
#if _LIBCPP_STD_VER > 11
{
// Note that you can't take a reference to a local var, since
// it's address is not a compile-time constant.
// its address is not a compile-time constant.
constexpr static int x = 1;
constexpr static int y = 0;
constexpr auto p1 = std::minmax(x, y, std::greater<>());

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <atomic>
// template <class T>
// struct atomic
// {
// bool is_lock_free() const volatile noexcept;
// bool is_lock_free() const noexcept;
// void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
// void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
// T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
// T load(memory_order m = memory_order_seq_cst) const noexcept;
// operator T() const volatile noexcept;
// operator T() const noexcept;
// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
// T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
// bool compare_exchange_weak(T& expc, T desr,
// memory_order s, memory_order f) volatile noexcept;
// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order s, memory_order f) volatile noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order s, memory_order f) noexcept;
// bool compare_exchange_weak(T& expc, T desr,
// memory_order m = memory_order_seq_cst) volatile noexcept;
// bool compare_exchange_weak(T& expc, T desr,
// memory_order m = memory_order_seq_cst) noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order m = memory_order_seq_cst) volatile noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order m = memory_order_seq_cst) noexcept;
//
// atomic() noexcept = default;
// constexpr atomic(T desr) noexcept;
// atomic(const atomic&) = delete;
// atomic& operator=(const atomic&) = delete;
// atomic& operator=(const atomic&) volatile = delete;
// T operator=(T) volatile noexcept;
// T operator=(T) noexcept;
// };
#include <atomic>
#include <new>
#include <cassert>
#include <thread> // for thread_id
#include <chrono> // for nanoseconds
struct NotTriviallyCopyable {
NotTriviallyCopyable ( int i ) : i_(i) {}
NotTriviallyCopyable ( const NotTriviallyCopyable &rhs) : i_(rhs.i_) {}
int i_;
};
template <class T>
void test ( T t ) {
std::atomic<T> t0(t);
}
int main()
{
test(NotTriviallyCopyable(42));
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <atomic>
// template <class T>
// struct atomic
// {
// bool is_lock_free() const volatile noexcept;
// bool is_lock_free() const noexcept;
// void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
// void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
// T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
// T load(memory_order m = memory_order_seq_cst) const noexcept;
// operator T() const volatile noexcept;
// operator T() const noexcept;
// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
// T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
// bool compare_exchange_weak(T& expc, T desr,
// memory_order s, memory_order f) volatile noexcept;
// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order s, memory_order f) volatile noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order s, memory_order f) noexcept;
// bool compare_exchange_weak(T& expc, T desr,
// memory_order m = memory_order_seq_cst) volatile noexcept;
// bool compare_exchange_weak(T& expc, T desr,
// memory_order m = memory_order_seq_cst) noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order m = memory_order_seq_cst) volatile noexcept;
// bool compare_exchange_strong(T& expc, T desr,
// memory_order m = memory_order_seq_cst) noexcept;
//
// atomic() noexcept = default;
// constexpr atomic(T desr) noexcept;
// atomic(const atomic&) = delete;
// atomic& operator=(const atomic&) = delete;
// atomic& operator=(const atomic&) volatile = delete;
// T operator=(T) volatile noexcept;
// T operator=(T) noexcept;
// };
#include <atomic>
#include <new>
#include <cassert>
#include <thread> // for thread_id
#include <chrono> // for nanoseconds
struct TriviallyCopyable {
TriviallyCopyable ( int i ) : i_(i) {}
int i_;
};
template <class T>
void test ( T t ) {
std::atomic<T> t0(t);
}
int main()
{
test(TriviallyCopyable(42));
test(std::this_thread::get_id());
test(std::chrono::nanoseconds(2));
}

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
@@ -96,4 +97,77 @@ int main()
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<const int, double> V;
typedef std::map<int, double, std::less <>> M;
typedef M::size_type R;
V ar[] =
{
V(5, 5),
V(6, 6),
V(7, 7),
V(8, 8),
V(9, 9),
V(10, 10),
V(11, 11),
V(12, 12)
};
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
R r = m.count(5);
assert(r == 1);
r = m.count(6);
assert(r == 1);
r = m.count(7);
assert(r == 1);
r = m.count(8);
assert(r == 1);
r = m.count(9);
assert(r == 1);
r = m.count(10);
assert(r == 1);
r = m.count(11);
assert(r == 1);
r = m.count(12);
assert(r == 1);
r = m.count(4);
assert(r == 0);
}
{
typedef PrivateConstructor PC;
typedef std::map<PC, double, std::less<>> M;
typedef M::size_type R;
M m;
m [ PC::make(5) ] = 5;
m [ PC::make(6) ] = 6;
m [ PC::make(7) ] = 7;
m [ PC::make(8) ] = 8;
m [ PC::make(9) ] = 9;
m [ PC::make(10) ] = 10;
m [ PC::make(11) ] = 11;
m [ PC::make(12) ] = 12;
R r = m.count(5);
assert(r == 1);
r = m.count(6);
assert(r == 1);
r = m.count(7);
assert(r == 1);
r = m.count(8);
assert(r == 1);
r = m.count(9);
assert(r == 1);
r = m.count(10);
assert(r == 1);
r = m.count(11);
assert(r == 1);
r = m.count(12);
assert(r == 1);
r = m.count(4);
assert(r == 0);
}
#endif
}

View File

@@ -37,31 +37,34 @@
int main()
{
{
static_assert((std::is_same<std::map<int, double>::key_type, int>::value), "");
static_assert((std::is_same<std::map<int, double>::mapped_type, double>::value), "");
static_assert((std::is_same<std::map<int, double>::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<std::map<int, double>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::map<int, double>::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<std::map<int, double>::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::map<int, double>::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::map<int, double>::pointer, std::pair<const int, double>*>::value), "");
static_assert((std::is_same<std::map<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
static_assert((std::is_same<std::map<int, double>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::map<int, double>::difference_type, std::ptrdiff_t>::value), "");
typedef std::map<int, double> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::mapped_type, double>::value), "");
static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#if __cplusplus >= 201103L
{
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::key_type, int>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::mapped_type, double>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::pointer, min_pointer<std::pair<const int, double>>>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::difference_type, std::ptrdiff_t>::value), "");
typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::mapped_type, double>::value), "");
static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
@@ -89,4 +90,70 @@ int main()
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef std::multimap<int, double, std::less<>> M;
typedef M::size_type R;
V ar[] =
{
V(5, 1),
V(5, 2),
V(5, 3),
V(7, 1),
V(7, 2),
V(7, 3),
V(9, 1),
V(9, 2),
V(9, 3)
};
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
R r = m.count(4);
assert(r == 0);
r = m.count(5);
assert(r == 3);
r = m.count(6);
assert(r == 0);
r = m.count(7);
assert(r == 3);
r = m.count(8);
assert(r == 0);
r = m.count(9);
assert(r == 3);
r = m.count(10);
assert(r == 0);
}
{
typedef PrivateConstructor PC;
typedef std::multimap<PC, double, std::less<>> M;
typedef M::size_type R;
M m;
m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
R r = m.count(4);
assert(r == 0);
r = m.count(5);
assert(r == 3);
r = m.count(6);
assert(r == 0);
r = m.count(7);
assert(r == 3);
r = m.count(8);
assert(r == 0);
r = m.count(9);
assert(r == 3);
r = m.count(10);
assert(r == 0);
}
#endif
}

View File

@@ -37,31 +37,34 @@
int main()
{
{
static_assert((std::is_same<std::multimap<int, double>::key_type, int>::value), "");
static_assert((std::is_same<std::multimap<int, double>::mapped_type, double>::value), "");
static_assert((std::is_same<std::multimap<int, double>::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<std::multimap<int, double>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::multimap<int, double>::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<std::multimap<int, double>::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::multimap<int, double>::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::multimap<int, double>::pointer, std::pair<const int, double>*>::value), "");
static_assert((std::is_same<std::multimap<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
static_assert((std::is_same<std::multimap<int, double>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::multimap<int, double>::difference_type, std::ptrdiff_t>::value), "");
typedef std::multimap<int, double> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::mapped_type, double>::value), "");
static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#if __cplusplus >= 201103L
{
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::key_type, int>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::mapped_type, double>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::pointer, min_pointer<std::pair<const int, double>>>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::difference_type, std::ptrdiff_t>::value), "");
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::mapped_type, double>::value), "");
static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
@@ -90,4 +91,70 @@ int main()
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::multiset<int, std::less<>> M;
typedef M::size_type R;
V ar[] =
{
5,
5,
5,
5,
7,
7,
7,
9,
9
};
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
R r = m.count(4);
assert(r == 0);
r = m.count(5);
assert(r == 4);
r = m.count(6);
assert(r == 0);
r = m.count(7);
assert(r == 3);
r = m.count(8);
assert(r == 0);
r = m.count(9);
assert(r == 2);
r = m.count(10);
assert(r == 0);
}
{
typedef PrivateConstructor V;
typedef std::multiset<V, std::less<>> M;
typedef M::size_type R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 9 ));
R r = m.count(4);
assert(r == 0);
r = m.count(5);
assert(r == 4);
r = m.count(6);
assert(r == 0);
r = m.count(7);
assert(r == 3);
r = m.count(8);
assert(r == 0);
r = m.count(9);
assert(r == 2);
r = m.count(10);
assert(r == 0);
}
#endif
}

View File

@@ -37,31 +37,34 @@
int main()
{
{
static_assert((std::is_same<std::multiset<int>::key_type, int>::value), "");
static_assert((std::is_same<std::multiset<int>::value_type, int>::value), "");
static_assert((std::is_same<std::multiset<int>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::multiset<int>::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::multiset<int>::allocator_type, std::allocator<int> >::value), "");
static_assert((std::is_same<std::multiset<int>::reference, int&>::value), "");
static_assert((std::is_same<std::multiset<int>::const_reference, const int&>::value), "");
static_assert((std::is_same<std::multiset<int>::pointer, int*>::value), "");
static_assert((std::is_same<std::multiset<int>::const_pointer, const int*>::value), "");
static_assert((std::is_same<std::multiset<int>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::multiset<int>::difference_type, std::ptrdiff_t>::value), "");
typedef std::multiset<int> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::value_type, int>::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
static_assert((std::is_same<C::reference, int&>::value), "");
static_assert((std::is_same<C::const_reference, const int&>::value), "");
static_assert((std::is_same<C::pointer, int*>::value), "");
static_assert((std::is_same<C::const_pointer, const int*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#if __cplusplus >= 201103L
{
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::key_type, int>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::value_type, int>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::allocator_type, min_allocator<int>>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::reference, int&>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::const_reference, const int&>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::multiset<int, std::less<int>, min_allocator<int>>::difference_type, std::ptrdiff_t>::value), "");
typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::value_type, int>::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<int>>::value), "");
static_assert((std::is_same<C::reference, int&>::value), "");
static_assert((std::is_same<C::const_reference, const int&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
@@ -92,4 +93,76 @@ int main()
assert(r == 0);
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::set<int, std::less<>> M;
typedef M::size_type R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
12
};
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
R r = m.count(5);
assert(r == 1);
r = m.count(6);
assert(r == 1);
r = m.count(7);
assert(r == 1);
r = m.count(8);
assert(r == 1);
r = m.count(9);
assert(r == 1);
r = m.count(10);
assert(r == 1);
r = m.count(11);
assert(r == 1);
r = m.count(12);
assert(r == 1);
r = m.count(4);
assert(r == 0);
}
{
typedef PrivateConstructor V;
typedef std::set<V, std::less<>> M;
typedef M::size_type R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 6 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 8 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 10 ));
m.insert ( V::make ( 11 ));
m.insert ( V::make ( 12 ));
R r = m.count(5);
assert(r == 1);
r = m.count(6);
assert(r == 1);
r = m.count(7);
assert(r == 1);
r = m.count(8);
assert(r == 1);
r = m.count(9);
assert(r == 1);
r = m.count(10);
assert(r == 1);
r = m.count(11);
assert(r == 1);
r = m.count(12);
assert(r == 1);
r = m.count(4);
assert(r == 0);
}
#endif
}

View File

@@ -37,31 +37,34 @@
int main()
{
{
static_assert((std::is_same<std::set<int>::key_type, int>::value), "");
static_assert((std::is_same<std::set<int>::value_type, int>::value), "");
static_assert((std::is_same<std::set<int>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::set<int>::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::set<int>::allocator_type, std::allocator<int> >::value), "");
static_assert((std::is_same<std::set<int>::reference, int&>::value), "");
static_assert((std::is_same<std::set<int>::const_reference, const int&>::value), "");
static_assert((std::is_same<std::set<int>::pointer, int*>::value), "");
static_assert((std::is_same<std::set<int>::const_pointer, const int*>::value), "");
static_assert((std::is_same<std::set<int>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::set<int>::difference_type, std::ptrdiff_t>::value), "");
typedef std::set<int> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::value_type, int>::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
static_assert((std::is_same<C::reference, int&>::value), "");
static_assert((std::is_same<C::const_reference, const int&>::value), "");
static_assert((std::is_same<C::pointer, int*>::value), "");
static_assert((std::is_same<C::const_pointer, const int*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#if __cplusplus >= 201103L
{
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::key_type, int>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::value_type, int>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::reference, int&>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::const_reference, const int&>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::set<int, std::less<int>, min_allocator<int>>::difference_type, std::ptrdiff_t>::value), "");
typedef std::set<int, std::less<int>, min_allocator<int>> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::value_type, int>::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
static_assert((std::is_same<C::reference, int&>::value), "");
static_assert((std::is_same<C::const_reference, const int&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -43,7 +43,7 @@ void
test(C& c1, int size)
{
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
typename C::size_type c1_osize = c1.size();
c1.resize(size);
assert(c1.size() == size);
assert(distance(c1.begin(), c1.end()) == c1.size());

View File

@@ -43,7 +43,7 @@ void
test(C& c1, int size, int x)
{
typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
typename C::size_type c1_osize = c1.size();
c1.resize(size, x);
assert(c1.size() == size);
assert(distance(c1.begin(), c1.end()) == c1.size());

View File

@@ -82,7 +82,8 @@ int main()
static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif

View File

@@ -17,6 +17,17 @@
#include "min_allocator.h"
struct S {
S(int i) : i_(new int(i)) {}
S(const S &rhs) : i_(new int(*rhs.i_)) {}
S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
~S () { delete i_; i_ = NULL; }
bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
int get () const { return *i_; }
int *i_;
};
int main()
{
{
@@ -66,6 +77,32 @@ int main()
c1.remove(0);
assert(c1 == c2);
}
{ // LWG issue #526
typedef int T;
typedef std::forward_list<T> C;
int t1[] = {1, 2, 1, 3, 5, 8, 11};
int t2[] = { 2, 3, 5, 8, 11};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove(c1.front());
assert(c1 == c2);
}
{
typedef S T;
typedef std::forward_list<T> C;
int t1[] = {1, 2, 1, 3, 5, 8, 11, 1};
int t2[] = { 2, 3, 5, 8, 11 };
C c;
for(int *ip = std::end(t1); ip != std::begin(t1);)
c.push_front(S(*--ip));
c.remove(c.front());
C::const_iterator it = c.begin();
for(int *ip = std::begin(t2); ip != std::end(t2); ++ip, ++it) {
assert ( it != c.end());
assert ( *ip == it->get());
}
assert ( it == c.end ());
}
#if __cplusplus >= 201103L
{
typedef int T;

View File

@@ -16,6 +16,8 @@
#include <cassert>
#include "min_allocator.h"
#include "counting_predicates.hpp"
bool g(int i)
{
@@ -26,98 +28,128 @@ int main()
{
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T> C;
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T> C;
const T t1[] = {0, 0, 0, 0};
C c1(std::begin(t1), std::end(t1));
C c2;
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T> C;
const T t1[] = {5, 5, 5};
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T> C;
C c1;
C c2;
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == 0);
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T> C;
const T t1[] = {5, 5, 5, 0};
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
#if __cplusplus >= 201103L
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {0, 5, 5, 0, 0, 0, 5};
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {0, 0, 0, 0};
C c1(std::begin(t1), std::end(t1));
C c2;
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {5, 5, 5};
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T, min_allocator<T>> C;
C c1;
C c2;
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == 0);
}
{
typedef int T;
typedef unary_counting_predicate<bool(*)(T), T> Predicate;
typedef std::forward_list<T, min_allocator<T>> C;
const T t1[] = {5, 5, 5, 0};
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
c1.remove_if(g);
Predicate cp(g);
c1.remove_if(std::ref(cp));
assert(c1 == c2);
assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
}
#endif
}

View File

@@ -32,22 +32,29 @@
int main()
{
static_assert((std::is_same<std::forward_list<char>::value_type, char>::value), "");
static_assert((std::is_same<std::forward_list<char>::allocator_type, std::allocator<char> >::value), "");
static_assert((std::is_same<std::forward_list<char>::reference, char&>::value), "");
static_assert((std::is_same<std::forward_list<char>::const_reference, const char&>::value), "");
static_assert((std::is_same<std::forward_list<char>::pointer, char*>::value), "");
static_assert((std::is_same<std::forward_list<char>::const_pointer, const char*>::value), "");
static_assert((std::is_same<std::forward_list<char>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::forward_list<char>::difference_type, std::ptrdiff_t>::value), "");
{
typedef std::forward_list<char> C;
static_assert((std::is_same<C::value_type, char>::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<char> >::value), "");
static_assert((std::is_same<C::reference, char&>::value), "");
static_assert((std::is_same<C::const_reference, const char&>::value), "");
static_assert((std::is_same<C::pointer, char*>::value), "");
static_assert((std::is_same<C::const_pointer, const char*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#if __cplusplus >= 201103L
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::value_type, char>::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::allocator_type, min_allocator<char> >::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::reference, char&>::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::const_reference, const char&>::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::pointer, min_pointer<char>>::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::const_pointer, min_pointer<const char>>::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::forward_list<char, min_allocator<char>>::difference_type, std::ptrdiff_t>::value), "");
{
typedef std::forward_list<char, min_allocator<char>> C;
static_assert((std::is_same<C::value_type, char>::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<char> >::value), "");
static_assert((std::is_same<C::reference, char&>::value), "");
static_assert((std::is_same<C::const_reference, const char&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<char>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const char>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -16,6 +16,17 @@
#include "min_allocator.h"
struct S {
S(int i) : i_(new int(i)) {}
S(const S &rhs) : i_(new int(*rhs.i_)) {}
S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
~S () { delete i_; i_ = NULL; }
bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
int get () const { return *i_; }
int *i_;
};
int main()
{
{
@@ -25,6 +36,27 @@ int main()
c.remove(3);
assert(c == std::list<int>(a2, a2+3));
}
{ // LWG issue #526
int a1[] = {1, 2, 1, 3, 5, 8, 11};
int a2[] = { 2, 3, 5, 8, 11};
std::list<int> c(a1, a1+7);
c.remove(c.front());
assert(c == std::list<int>(a2, a2+5));
}
{
int a1[] = {1, 2, 1, 3, 5, 8, 11, 1};
int a2[] = { 2, 3, 5, 8, 11 };
std::list<S> c;
for(int *ip = a1; ip < a1+8; ++ip)
c.push_back(S(*ip));
c.remove(c.front());
std::list<S>::const_iterator it = c.begin();
for(int *ip = a2; ip < a2+5; ++ip, ++it) {
assert ( it != c.end());
assert ( *ip == it->get());
}
assert ( it == c.end ());
}
#if __cplusplus >= 201103L
{
int a1[] = {1, 2, 3, 4};

View File

@@ -16,28 +16,49 @@
#include <functional>
#include "min_allocator.h"
#include "counting_predicates.hpp"
bool even(int i)
{
return i % 2 == 0;
}
bool g(int i)
{
return i < 3;
}
typedef unary_counting_predicate<bool(*)(int), int> Predicate;
int main()
{
{
int a1[] = {1, 2, 3, 4};
int a2[] = {3, 4};
std::list<int> c(a1, a1+4);
c.remove_if(g);
Predicate cp(g);
c.remove_if(std::ref(cp));
assert(c == std::list<int>(a2, a2+2));
assert(cp.count() == 4);
}
{
int a1[] = {1, 2, 3, 4};
int a2[] = {1, 3};
std::list<int> c(a1, a1+4);
Predicate cp(even);
c.remove_if(std::ref(cp));
assert(c == std::list<int>(a2, a2+2));
assert(cp.count() == 4);
}
#if __cplusplus >= 201103L
{
int a1[] = {1, 2, 3, 4};
int a2[] = {3, 4};
std::list<int, min_allocator<int>> c(a1, a1+4);
c.remove_if(g);
Predicate cp(g);
c.remove_if(std::ref(cp));
assert((c == std::list<int, min_allocator<int>>(a2, a2+2)));
assert(cp.count() == 4);
}
#endif
}

View File

@@ -25,6 +25,7 @@ int main()
std::vector<bool> b(i,true);
std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false);
assert(j-b.begin() == i);
assert(b.end() == j);
}
}
{
@@ -33,6 +34,7 @@ int main()
std::vector<bool> b(i,false);
std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true);
assert(j-b.begin() == i);
assert(b.end() == j);
}
}
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <vector>
// reference operator[](size_type n);
#include <vector>
#include <cassert>
#include <cstdlib>
#include "min_allocator.h"
#include "asan_testing.h"
#ifndef _LIBCPP_HAS_NO_ASAN
extern "C" void __asan_set_error_exit_code(int);
int main()
{
#if __cplusplus >= 201103L
{
typedef int T;
typedef std::vector<T, min_allocator<T>> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t), std::end(t));
c.reserve(2*c.size());
T foo = c[c.size()]; // bad, but not caught by ASAN
}
#endif
__asan_set_error_exit_code(0);
{
typedef int T;
typedef std::vector<T> C;
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t), std::end(t));
c.reserve(2*c.size());
assert(is_contiguous_container_asan_correct(c));
assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity()));
T foo = c[c.size()]; // should trigger ASAN
assert(false); // if we got here, ASAN didn't trigger
}
}
#else
int main () { return 0; }
#endif

View File

@@ -15,29 +15,34 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
{
std::vector<int> v;
assert(v.capacity() == 0);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int> v(100);
assert(v.capacity() == 100);
v.push_back(0);
assert(v.capacity() > 101);
assert(is_contiguous_container_asan_correct(v));
}
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v;
assert(v.capacity() == 0);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, min_allocator<int>> v(100);
assert(v.capacity() == 100);
v.push_back(0);
assert(v.capacity() > 101);
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -22,6 +23,7 @@ int main()
std::vector<int> v;
v.reserve(10);
assert(v.capacity() >= 10);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int> v(100);
@@ -32,6 +34,7 @@ int main()
v.reserve(150);
assert(v.size() == 100);
assert(v.capacity() == 150);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, stack_allocator<int, 250> > v(100);
@@ -42,12 +45,14 @@ int main()
v.reserve(150);
assert(v.size() == 100);
assert(v.capacity() == 150);
assert(is_contiguous_container_asan_correct(v));
}
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v;
v.reserve(10);
assert(v.capacity() >= 10);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, min_allocator<int>> v(100);
@@ -58,6 +63,7 @@ int main()
v.reserve(150);
assert(v.size() == 100);
assert(v.capacity() == 150);
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -16,6 +16,7 @@
#include "../../../stack_allocator.h"
#include "../../../MoveOnly.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -25,18 +26,22 @@ int main()
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
@@ -44,18 +49,22 @@ int main()
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, stack_allocator<int, 300> > v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if __cplusplus >= 201103L
@@ -64,9 +73,11 @@ int main()
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -27,6 +28,7 @@ int main()
v.resize(200, 1);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
for (unsigned i = 0; i < 50; ++i)
assert(v[i] == 0);
for (unsigned i = 50; i < 200; ++i)
@@ -40,6 +42,7 @@ int main()
v.resize(200, 1);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#if __cplusplus >= 201103L
{
@@ -47,10 +50,12 @@ int main()
v.resize(50, 1);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
assert((v == std::vector<int, min_allocator<int>>(50)));
v.resize(200, 1);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
for (unsigned i = 0; i < 50; ++i)
assert(v[i] == 0);
for (unsigned i = 50; i < 200; ++i)
@@ -61,9 +66,11 @@ int main()
v.resize(50, 1);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200, 1);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -15,39 +15,48 @@
#include <cassert>
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
{
std::vector<int> v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
v.shrink_to_fit();
assert(v.capacity() == 101);
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, stack_allocator<int, 401> > v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
v.shrink_to_fit();
assert(v.capacity() == 101);
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
}
#ifndef _LIBCPP_NO_EXCEPTIONS
{
std::vector<int, stack_allocator<int, 400> > v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
v.shrink_to_fit();
assert(v.capacity() == 200);
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
}
#endif
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
v.shrink_to_fit();
assert(v.capacity() == 101);
assert(v.size() == 101);
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -15,27 +15,36 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
{
std::vector<int> v1(100);
std::vector<int> v2(200);
assert(is_contiguous_container_asan_correct(v1));
assert(is_contiguous_container_asan_correct(v2));
v1.swap(v2);
assert(v1.size() == 200);
assert(v1.capacity() == 200);
assert(is_contiguous_container_asan_correct(v1));
assert(v2.size() == 100);
assert(v2.capacity() == 100);
assert(is_contiguous_container_asan_correct(v2));
}
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v1(100);
std::vector<int, min_allocator<int>> v2(200);
assert(is_contiguous_container_asan_correct(v1));
assert(is_contiguous_container_asan_correct(v2));
v1.swap(v2);
assert(v1.size() == 200);
assert(v1.capacity() == 200);
assert(is_contiguous_container_asan_correct(v1));
assert(v2.size() == 100);
assert(v2.capacity() == 100);
assert(is_contiguous_container_asan_correct(v2));
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -23,6 +24,7 @@ int main()
std::vector<int> d;
d.assign({3, 4, 5, 6});
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
@@ -33,6 +35,7 @@ int main()
std::vector<int, min_allocator<int>> d;
d.assign({3, 4, 5, 6});
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);

View File

@@ -16,6 +16,7 @@
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -28,54 +29,72 @@ int main()
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
l2 = std::move(l);
assert(l2 == lo);
assert(!l.empty());
assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
assert(is_contiguous_container_asan_correct(l2));
}
{
std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
#if __cplusplus >= 201103L
{
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -18,6 +18,7 @@
#include "../../../NotConstructible.h"
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
template <class C>
void
@@ -27,11 +28,13 @@ test0()
assert(c.__invariants());
assert(c.empty());
assert(c.get_allocator() == typename C::allocator_type());
assert(is_contiguous_container_asan_correct(c));
#if __cplusplus >= 201103L
C c1 = {};
assert(c1.__invariants());
assert(c1.empty());
assert(c1.get_allocator() == typename C::allocator_type());
assert(is_contiguous_container_asan_correct(c1));
#endif
}
@@ -43,6 +46,7 @@ test1(const typename C::allocator_type& a)
assert(c.__invariants());
assert(c.empty());
assert(c.get_allocator() == a);
assert(is_contiguous_container_asan_correct(c));
}
int main()

View File

@@ -17,6 +17,7 @@
#include "test_iterators.h"
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
template <class C, class Iterator>
void
@@ -25,6 +26,7 @@ test(Iterator first, Iterator last)
C c(first, last);
assert(c.__invariants());
assert(c.size() == std::distance(first, last));
assert(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
assert(*i == *first);
}

View File

@@ -18,6 +18,7 @@
#include "test_iterators.h"
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
template <class C, class Iterator, class A>
void
@@ -26,6 +27,7 @@ test(Iterator first, Iterator last, const A& a)
C c(first, last, a);
assert(c.__invariants());
assert(c.size() == std::distance(first, last));
assert(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
assert(*i == *first);
}

View File

@@ -17,6 +17,7 @@
#include "DefaultOnly.h"
#include "min_allocator.h"
#include "test_allocator.h"
#include "asan_testing.h"
template <class C>
void
@@ -27,6 +28,7 @@ test2(typename C::size_type n, typename C::allocator_type const& a = typename C:
assert(c.__invariants());
assert(c.size() == n);
assert(c.get_allocator() == a);
assert(is_contiguous_container_asan_correct(c));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
assert(*i == typename C::value_type());
@@ -42,6 +44,7 @@ test1(typename C::size_type n)
assert(c.__invariants());
assert(c.size() == n);
assert(c.get_allocator() == typename C::allocator_type());
assert(is_contiguous_container_asan_correct(c));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
assert(*i == typename C::value_type());

View File

@@ -16,6 +16,7 @@
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
template <class C>
void
@@ -24,6 +25,7 @@ test(typename C::size_type n, const typename C::value_type& x)
C c(n, x);
assert(c.__invariants());
assert(c.size() == n);
assert(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
assert(*i == x);
}

View File

@@ -14,6 +14,7 @@
#include <vector>
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
template <class C>
void
@@ -24,6 +25,7 @@ test(typename C::size_type n, const typename C::value_type& x,
assert(c.__invariants());
assert(a == c.get_allocator());
assert(c.size() == n);
assert(is_contiguous_container_asan_correct(c));
for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
assert(*i == x);
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
template <class C>
void
@@ -25,6 +26,7 @@ test(const C& x)
assert(c.__invariants());
assert(c.size() == s);
assert(c == x);
assert(is_contiguous_container_asan_correct(c));
}
int main()
@@ -37,15 +39,23 @@ int main()
{
std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
std::vector<int, test_allocator<int> > v2 = v;
assert(is_contiguous_container_asan_correct(v));
assert(is_contiguous_container_asan_correct(v2));
assert(v2 == v);
assert(v2.get_allocator() == v.get_allocator());
assert(is_contiguous_container_asan_correct(v));
assert(is_contiguous_container_asan_correct(v2));
}
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
std::vector<int, other_allocator<int> > v2 = v;
assert(is_contiguous_container_asan_correct(v));
assert(is_contiguous_container_asan_correct(v2));
assert(v2 == v);
assert(v2.get_allocator() == other_allocator<int>(-2));
assert(is_contiguous_container_asan_correct(v));
assert(is_contiguous_container_asan_correct(v2));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if __cplusplus >= 201103L
@@ -57,8 +67,12 @@ int main()
{
std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>());
std::vector<int, min_allocator<int> > v2 = v;
assert(is_contiguous_container_asan_correct(v));
assert(is_contiguous_container_asan_correct(v2));
assert(v2 == v);
assert(v2.get_allocator() == v.get_allocator());
assert(is_contiguous_container_asan_correct(v));
assert(is_contiguous_container_asan_correct(v2));
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
template <class C>
void
@@ -25,6 +26,7 @@ test(const C& x, const typename C::allocator_type& a)
assert(c.__invariants());
assert(c.size() == s);
assert(c == x);
assert(is_contiguous_container_asan_correct(c));
}
int main()

View File

@@ -14,6 +14,7 @@
#include <vector>
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -21,6 +22,7 @@ int main()
{
std::vector<int> d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
@@ -30,6 +32,7 @@ int main()
{
std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);

View File

@@ -16,6 +16,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -24,6 +25,7 @@ int main()
std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
assert(d.get_allocator() == test_allocator<int>(3));
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
@@ -34,6 +36,7 @@ int main()
std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
assert(d.get_allocator() == min_allocator<int>());
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);

View File

@@ -16,6 +16,7 @@
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -23,58 +24,79 @@ int main()
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
{
std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
{
int a1[] = {1, 3, 7, 9, 10};
std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
assert(is_contiguous_container_asan_correct(c1));
std::vector<int>::const_iterator i = c1.begin();
std::vector<int> c2 = std::move(c1);
assert(is_contiguous_container_asan_correct(c2));
std::vector<int>::iterator j = c2.erase(i);
assert(*j == 3);
assert(is_contiguous_container_asan_correct(c2));
}
#if __cplusplus >= 201103L
{
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
{
int a1[] = {1, 3, 7, 9, 10};
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
assert(is_contiguous_container_asan_correct(c1));
std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
std::vector<int, min_allocator<int>> c2 = std::move(c1);
assert(is_contiguous_container_asan_correct(c2));
std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
assert(*j == 3);
assert(is_contiguous_container_asan_correct(c2));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -16,6 +16,7 @@
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -23,55 +24,75 @@ int main()
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
assert(l2 == lo);
assert(!l.empty());
assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
assert(is_contiguous_container_asan_correct(l2));
}
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l2));
}
{
std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
assert(l2 == lo);
assert(!l.empty());
assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
assert(is_contiguous_container_asan_correct(l2));
}
#if __cplusplus >= 201103L
{
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
for (int i = 1; i <= 3; ++i)
{
l.push_back(i);
lo.push_back(i);
}
assert(is_contiguous_container_asan_correct(l));
assert(is_contiguous_container_asan_correct(lo));
std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
assert(l2 == lo);
assert(l.empty());
assert(l2.get_allocator() == min_allocator<MoveOnly>());
assert(is_contiguous_container_asan_correct(l2));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -23,6 +24,7 @@ int main()
std::vector<int> d;
d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
@@ -33,6 +35,7 @@ int main()
std::vector<int, min_allocator<int>> d;
d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(is_contiguous_container_asan_correct(d));
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);

View File

@@ -15,25 +15,30 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
{
std::vector<int> v;
assert(v.data() == 0);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int> v(100);
assert(v.data() == &v.front());
assert(is_contiguous_container_asan_correct(v));
}
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v;
assert(v.data() == 0);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, min_allocator<int>> v(100);
assert(v.data() == &v.front());
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -15,25 +15,30 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
{
const std::vector<int> v;
assert(v.data() == 0);
assert(is_contiguous_container_asan_correct(v));
}
{
const std::vector<int> v(100);
assert(v.data() == &v.front());
assert(is_contiguous_container_asan_correct(v));
}
#if __cplusplus >= 201103L
{
const std::vector<int, min_allocator<int>> v;
assert(v.data() == 0);
assert(is_contiguous_container_asan_correct(v));
}
{
const std::vector<int, min_allocator<int>> v(100);
assert(v.data() == &v.front());
assert(is_contiguous_container_asan_correct(v));
}
#endif
}

View File

@@ -19,6 +19,7 @@
#include <cassert>
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -66,6 +67,7 @@ int main()
assert(c.size() == 1);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
i = c.emplace(c.cend(), 3, 4.5);
assert(i == c.end()-1);
assert(c.size() == 2);
@@ -73,6 +75,7 @@ int main()
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
i = c.emplace(c.cbegin()+1, 4, 6.5);
assert(i == c.begin()+1);
assert(c.size() == 3);
@@ -82,6 +85,7 @@ int main()
assert(c[1].getd() == 6.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
{
std::vector<A, stack_allocator<A, 7> > c;
@@ -90,6 +94,7 @@ int main()
assert(c.size() == 1);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
i = c.emplace(c.cend(), 3, 4.5);
assert(i == c.end()-1);
assert(c.size() == 2);
@@ -97,6 +102,7 @@ int main()
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
i = c.emplace(c.cbegin()+1, 4, 6.5);
assert(i == c.begin()+1);
assert(c.size() == 3);
@@ -106,6 +112,7 @@ int main()
assert(c[1].getd() == 6.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
#if _LIBCPP_DEBUG >= 1
{

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "../../../stack_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -61,12 +62,14 @@ int main()
assert(c.size() == 1);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
c.emplace_back(3, 4.5);
assert(c.size() == 2);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
{
std::vector<A, stack_allocator<A, 4> > c;
@@ -74,12 +77,14 @@ int main()
assert(c.size() == 1);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
c.emplace_back(3, 4.5);
assert(c.size() == 2);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
#if __cplusplus >= 201103L
{
@@ -88,12 +93,14 @@ int main()
assert(c.size() == 1);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(is_contiguous_container_asan_correct(c));
c.emplace_back(3, 4.5);
assert(c.size() == 2);
assert(c.front().geti() == 2);
assert(c.front().getd() == 3.5);
assert(c.back().geti() == 3);
assert(c.back().getd() == 4.5);
assert(is_contiguous_container_asan_correct(c));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -22,31 +23,39 @@ int main()
{
std::vector<int> v;
v.reserve(3);
assert(is_contiguous_container_asan_correct(v));
v = { 1, 2, 3 };
v.emplace(v.begin(), v.back());
assert(v[0] == 3);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int> v;
v.reserve(4);
assert(is_contiguous_container_asan_correct(v));
v = { 1, 2, 3 };
v.emplace(v.begin(), v.back());
assert(v[0] == 3);
assert(is_contiguous_container_asan_correct(v));
}
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v;
v.reserve(3);
assert(is_contiguous_container_asan_correct(v));
v = { 1, 2, 3 };
v.emplace(v.begin(), v.back());
assert(v[0] == 3);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<int, min_allocator<int>> v;
v.reserve(4);
assert(is_contiguous_container_asan_correct(v));
v = { 1, 2, 3 };
v.emplace(v.begin(), v.back());
assert(v[0] == 3);
assert(is_contiguous_container_asan_correct(v));
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -22,6 +23,7 @@ int main()
int a1[] = {1, 2, 3};
std::vector<int> l1(a1, a1+3);
std::vector<int>::const_iterator i = l1.begin();
assert(is_contiguous_container_asan_correct(l1));
++i;
std::vector<int>::iterator j = l1.erase(i);
assert(l1.size() == 2);
@@ -29,21 +31,25 @@ int main()
assert(*j == 3);
assert(*l1.begin() == 1);
assert(*next(l1.begin()) == 3);
assert(is_contiguous_container_asan_correct(l1));
j = l1.erase(j);
assert(j == l1.end());
assert(l1.size() == 1);
assert(distance(l1.begin(), l1.end()) == 1);
assert(*l1.begin() == 1);
assert(is_contiguous_container_asan_correct(l1));
j = l1.erase(l1.begin());
assert(j == l1.end());
assert(l1.size() == 0);
assert(distance(l1.begin(), l1.end()) == 0);
assert(is_contiguous_container_asan_correct(l1));
}
#if __cplusplus >= 201103L
{
int a1[] = {1, 2, 3};
std::vector<int, min_allocator<int>> l1(a1, a1+3);
std::vector<int, min_allocator<int>>::const_iterator i = l1.begin();
assert(is_contiguous_container_asan_correct(l1));
++i;
std::vector<int, min_allocator<int>>::iterator j = l1.erase(i);
assert(l1.size() == 2);
@@ -51,15 +57,18 @@ int main()
assert(*j == 3);
assert(*l1.begin() == 1);
assert(*next(l1.begin()) == 3);
assert(is_contiguous_container_asan_correct(l1));
j = l1.erase(j);
assert(j == l1.end());
assert(l1.size() == 1);
assert(distance(l1.begin(), l1.end()) == 1);
assert(*l1.begin() == 1);
assert(is_contiguous_container_asan_correct(l1));
j = l1.erase(l1.begin());
assert(j == l1.end());
assert(l1.size() == 0);
assert(distance(l1.begin(), l1.end()) == 0);
assert(is_contiguous_container_asan_correct(l1));
}
#endif
}

View File

@@ -15,84 +15,113 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
int a1[] = {1, 2, 3};
{
std::vector<int> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
assert(l1.size() == 3);
assert(distance(l1.cbegin(), l1.cend()) == 3);
assert(i == l1.begin());
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<int> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
assert(l1.size() == 2);
assert(distance(l1.cbegin(), l1.cend()) == 2);
assert(i == l1.begin());
assert(l1 == std::vector<int>(a1+1, a1+3));
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<int> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
assert(l1.size() == 1);
assert(distance(l1.cbegin(), l1.cend()) == 1);
assert(i == l1.begin());
assert(l1 == std::vector<int>(a1+2, a1+3));
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<int> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
assert(l1.size() == 0);
assert(distance(l1.cbegin(), l1.cend()) == 0);
assert(i == l1.begin());
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<std::vector<int> > outer(2, std::vector<int>(1));
assert(is_contiguous_container_asan_correct(outer));
assert(is_contiguous_container_asan_correct(outer[0]));
assert(is_contiguous_container_asan_correct(outer[1]));
outer.erase(outer.begin(), outer.begin());
assert(outer.size() == 2);
assert(outer[0].size() == 1);
assert(outer[1].size() == 1);
assert(is_contiguous_container_asan_correct(outer));
assert(is_contiguous_container_asan_correct(outer[0]));
assert(is_contiguous_container_asan_correct(outer[1]));
}
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
assert(l1.size() == 3);
assert(distance(l1.cbegin(), l1.cend()) == 3);
assert(i == l1.begin());
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<int, min_allocator<int>> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
assert(l1.size() == 2);
assert(distance(l1.cbegin(), l1.cend()) == 2);
assert(i == l1.begin());
assert((l1 == std::vector<int, min_allocator<int>>(a1+1, a1+3)));
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<int, min_allocator<int>> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
assert(l1.size() == 1);
assert(distance(l1.cbegin(), l1.cend()) == 1);
assert(i == l1.begin());
assert((l1 == std::vector<int, min_allocator<int>>(a1+2, a1+3)));
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<int, min_allocator<int>> l1(a1, a1+3);
assert(is_contiguous_container_asan_correct(l1));
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
assert(l1.size() == 0);
assert(distance(l1.cbegin(), l1.cend()) == 0);
assert(i == l1.begin());
assert(is_contiguous_container_asan_correct(l1));
}
{
std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1));
assert(is_contiguous_container_asan_correct(outer));
assert(is_contiguous_container_asan_correct(outer[0]));
assert(is_contiguous_container_asan_correct(outer[1]));
outer.erase(outer.begin(), outer.begin());
assert(outer.size() == 2);
assert(outer[0].size() == 1);
assert(outer[1].size() == 1);
assert(is_contiguous_container_asan_correct(outer));
assert(is_contiguous_container_asan_correct(outer[0]));
assert(is_contiguous_container_asan_correct(outer[1]));
}
#endif
}

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -23,6 +24,7 @@ int main()
std::vector<int> d(10, 1);
std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
assert(d.size() == 14);
assert(is_contiguous_container_asan_correct(d));
assert(i == d.begin() + 2);
assert(d[0] == 1);
assert(d[1] == 1);
@@ -44,6 +46,7 @@ int main()
std::vector<int, min_allocator<int>> d(10, 1);
std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
assert(d.size() == 14);
assert(is_contiguous_container_asan_correct(d));
assert(i == d.begin() + 2);
assert(d[0] == 1);
assert(d[1] == 1);

View File

@@ -21,6 +21,7 @@
#include "../../../stack_allocator.h"
#include "test_iterators.h"
#include "min_allocator.h"
#include "asan_testing.h"
int main()
{
@@ -31,6 +32,7 @@ int main()
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
input_iterator<const int*>(a+N));
assert(v.size() == 100 + N);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
@@ -47,6 +49,7 @@ int main()
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
forward_iterator<const int*>(a+N));
assert(v.size() == 100 + N);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
@@ -63,6 +66,7 @@ int main()
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
input_iterator<const int*>(a+N));
assert(v.size() == 100 + N);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
@@ -79,6 +83,7 @@ int main()
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
forward_iterator<const int*>(a+N));
assert(v.size() == 100 + N);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
@@ -107,6 +112,7 @@ int main()
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
input_iterator<const int*>(a+N));
assert(v.size() == 100 + N);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
@@ -123,6 +129,7 @@ int main()
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
forward_iterator<const int*>(a+N));
assert(v.size() == 100 + N);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)

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