am 4dc5b219: Merge to upstream r226192.

* commit '4dc5b2198d1aa4ab585a3d4a87ee9626d681f9f7':
  Merge to upstream r226192.
This commit is contained in:
Dan Albert
2015-01-16 06:07:32 +00:00
committed by Android Git Automerger
144 changed files with 470 additions and 206 deletions

View File

@@ -1420,7 +1420,7 @@ protected:
// template <class charT> class numpunct_byname // template <class charT> class numpunct_byname
template <class charT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname; template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname;
template <> template <>
class _LIBCPP_TYPE_VIS numpunct_byname<char> class _LIBCPP_TYPE_VIS numpunct_byname<char>

View File

@@ -551,26 +551,26 @@ typedef enum memory_order
#if _GNUC_VER >= 407 #if _GNUC_VER >= 407
namespace __gcc_atomic { namespace __gcc_atomic {
template <typename T> template <typename _Tp>
struct __gcc_atomic_t { struct __gcc_atomic_t {
__gcc_atomic_t() _NOEXCEPT {} __gcc_atomic_t() _NOEXCEPT {}
explicit __gcc_atomic_t(T value) _NOEXCEPT : __a_value(value) {} explicit __gcc_atomic_t(_Tp value) _NOEXCEPT : __a_value(value) {}
T __a_value; _Tp __a_value;
}; };
#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x> #define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
template <typename T> T __create(); template <typename _Tp> _Tp __create();
template <typename __Tp, typename __Td> template <typename _Tp, typename _Td>
typename enable_if<sizeof(__Tp()->__a_value = __create<__Td>()), char>::type typename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type
__test_atomic_assignable(int); __test_atomic_assignable(int);
template <typename T, typename U> template <typename _Tp, typename _Up>
__two __test_atomic_assignable(...); __two __test_atomic_assignable(...);
template <typename __Tp, typename __Td> template <typename _Tp, typename _Td>
struct __can_assign { struct __can_assign {
static const bool value = static const bool value =
sizeof(__test_atomic_assignable<__Tp, __Td>(1)) == sizeof(char); sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char);
}; };
static inline constexpr int __to_gcc_order(memory_order __order) { static inline constexpr int __to_gcc_order(memory_order __order) {

View File

@@ -120,6 +120,24 @@ inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {ret
inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);} inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
#endif // putc #endif // putc
#ifdef clearerr
inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); }
#undef clearerr
inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); }
#endif // clearerr
#ifdef feof
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); }
#undef feof
inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); }
#endif // feof
#ifdef ferror
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); }
#undef ferror
inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); }
#endif // ferror
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
using ::FILE; using ::FILE;

View File

@@ -2608,9 +2608,7 @@ public:
assign(_ForwardIterator __first, _ForwardIterator __last, assign(_ForwardIterator __first, _ForwardIterator __last,
flag_type __f = regex_constants::ECMAScript) flag_type __f = regex_constants::ECMAScript)
{ {
__member_init(__f); return assign(basic_regex(__first, __last, __f));
__parse(__first, __last);
return *this;
} }
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -1433,11 +1433,11 @@ template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
#ifdef _LIBCPP_HAS_NO_VARIADICS #ifdef _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Up = void, class V = void> template <class _Tp, class _Up = void, class _Vp = void>
struct _LIBCPP_TYPE_VIS_ONLY common_type struct _LIBCPP_TYPE_VIS_ONLY common_type
{ {
public: public:
typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type; typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
}; };
template <class _Tp> template <class _Tp>

View File

@@ -23,6 +23,9 @@ if(PYTHONINTERP_FOUND)
set(LIT_ARGS "${LLVM_LIT_ARGS}") set(LIT_ARGS "${LLVM_LIT_ARGS}")
separate_arguments(LIT_ARGS) separate_arguments(LIT_ARGS)
set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
"Configuration variant to use for LIT.")
pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS) pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXX_ENABLE_RTTI) pythonize_bool(LIBCXX_ENABLE_RTTI)
pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXX_ENABLE_SHARED)

View File

@@ -17,13 +17,13 @@ class Configuration(object):
self.lit_config = lit_config self.lit_config = lit_config
self.config = config self.config = config
self.cxx = None self.cxx = None
self.src_root = None self.libcxx_src_root = None
self.obj_root = None self.obj_root = None
self.library_root = None self.cxx_library_root = None
self.env = {} self.env = {}
self.compile_flags = [] self.compile_flags = []
self.link_flags = [] self.link_flags = []
self.use_system_lib = False self.use_system_cxx_lib = False
self.use_clang_verify = False self.use_clang_verify = False
self.use_ccache = False self.use_ccache = False
self.long_tests = None self.long_tests = None
@@ -56,8 +56,8 @@ class Configuration(object):
self.configure_triple() self.configure_triple()
self.configure_src_root() self.configure_src_root()
self.configure_obj_root() self.configure_obj_root()
self.configure_library_root() self.configure_cxx_library_root()
self.configure_use_system_lib() self.configure_use_system_cxx_lib()
self.configure_use_clang_verify() self.configure_use_clang_verify()
self.configure_ccache() self.configure_ccache()
self.configure_env() self.configure_env()
@@ -137,27 +137,28 @@ class Configuration(object):
compiler_name, major_ver, minor_ver)) compiler_name, major_ver, minor_ver))
def configure_src_root(self): def configure_src_root(self):
self.src_root = self.get_lit_conf( self.libcxx_src_root = self.get_lit_conf(
'libcxx_src_root', os.path.dirname(self.config.test_source_root)) 'libcxx_src_root', os.path.dirname(self.config.test_source_root))
def configure_obj_root(self): def configure_obj_root(self):
self.obj_root = self.get_lit_conf('libcxx_obj_root', self.src_root) self.obj_root = self.get_lit_conf('libcxx_obj_root',
self.libcxx_src_root)
def configure_library_root(self): def configure_cxx_library_root(self):
self.library_root = self.get_lit_conf('libcxx_library_root', self.cxx_library_root = self.get_lit_conf('cxx_library_root',
self.obj_root) self.obj_root)
def configure_use_system_lib(self): def configure_use_system_cxx_lib(self):
# This test suite supports testing against either the system library or # This test suite supports testing against either the system library or
# the locally built one; the former mode is useful for testing ABI # the locally built one; the former mode is useful for testing ABI
# compatibility between the current headers and a shipping dynamic # compatibility between the current headers and a shipping dynamic
# library. # library.
self.use_system_lib = self.get_lit_bool('use_system_lib') self.use_system_cxx_lib = self.get_lit_bool('use_system_cxx_lib')
if self.use_system_lib is None: if self.use_system_cxx_lib is None:
# Default to testing against the locally built libc++ library. # Default to testing against the locally built libc++ library.
self.use_system_lib = False self.use_system_cxx_lib = False
self.lit_config.note( self.lit_config.note(
"inferred use_system_lib as: %r" % self.use_system_lib) "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib)
def configure_use_clang_verify(self): def configure_use_clang_verify(self):
'''If set, run clang with -verify on failing tests.''' '''If set, run clang with -verify on failing tests.'''
@@ -228,12 +229,12 @@ class Configuration(object):
locale.setlocale(locale.LC_ALL, default_locale) locale.setlocale(locale.LC_ALL, default_locale)
# Write an "available feature" that combines the triple when # Write an "available feature" that combines the triple when
# use_system_lib is enabled. This is so that we can easily write XFAIL # use_system_cxx_lib is enabled. This is so that we can easily write XFAIL
# markers for tests that are known to fail with versions of libc++ as # markers for tests that are known to fail with versions of libc++ as
# were shipped with a particular triple. # were shipped with a particular triple.
if self.use_system_lib: if self.use_system_cxx_lib:
self.config.available_features.add( self.config.available_features.add(
'with_system_lib=%s' % self.config.target_triple) 'with_system_cxx_lib=%s' % self.config.target_triple)
# Some linux distributions have different locale data than others. # Some linux distributions have different locale data than others.
# Insert the distributions name and name-version into the available # Insert the distributions name and name-version into the available
@@ -268,28 +269,14 @@ class Configuration(object):
self.config.available_features.add(std) self.config.available_features.add(std)
# Configure include paths # Configure include paths
self.compile_flags += ['-nostdinc++'] self.compile_flags += ['-nostdinc++']
self.compile_flags += ['-I' + self.src_root + '/test/support'] self.configure_compile_flags_header_includes()
libcxx_headers = self.get_lit_conf('libcxx_headers',
self.src_root + '/include')
if not os.path.isdir(libcxx_headers):
self.lit_config.fatal("libcxx_headers='%s' is not a directory."
% libcxx_headers)
self.compile_flags += ['-I' + libcxx_headers]
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
self.compile_flags += ['-D__STDC_FORMAT_MACROS', self.compile_flags += ['-D__STDC_FORMAT_MACROS',
'-D__STDC_LIMIT_MACROS', '-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS'] '-D__STDC_CONSTANT_MACROS']
# Configure feature flags. # Configure feature flags.
enable_exceptions = self.get_lit_bool('enable_exceptions', True) self.configure_compile_flags_exceptions()
if enable_exceptions: self.configure_compile_flags_rtti()
self.config.available_features.add('exceptions')
else:
self.compile_flags += ['-fno-exceptions']
enable_rtti = self.get_lit_bool('enable_rtti', True)
if enable_rtti:
self.config.available_features.add('rtti')
else:
self.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI']
enable_32bit = self.get_lit_bool('enable_32bit', False) enable_32bit = self.get_lit_bool('enable_32bit', False)
if enable_32bit: if enable_32bit:
self.compile_flags += ['-m32'] self.compile_flags += ['-m32']
@@ -298,12 +285,9 @@ class Configuration(object):
enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock', enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock',
True) True)
if not enable_threads: if not enable_threads:
self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS'] self.configure_compile_flags_no_threads()
self.config.available_features.add('libcpp-has-no-threads')
if not enable_monotonic_clock: if not enable_monotonic_clock:
self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'] self.configure_compile_flags_no_monotonic_clock()
self.config.available_features.add(
'libcpp-has-no-monotonic-clock')
elif not enable_monotonic_clock: elif not enable_monotonic_clock:
self.lit_config.fatal('enable_monotonic_clock cannot be false when' self.lit_config.fatal('enable_monotonic_clock cannot be false when'
' enable_threads is true.') ' enable_threads is true.')
@@ -313,8 +297,53 @@ class Configuration(object):
compile_flags_str = self.get_lit_conf('compile_flags', '') compile_flags_str = self.get_lit_conf('compile_flags', '')
self.compile_flags += shlex.split(compile_flags_str) self.compile_flags += shlex.split(compile_flags_str)
def configure_compile_flags_header_includes(self):
self.compile_flags += ['-I' + self.libcxx_src_root + '/test/support']
libcxx_headers = self.get_lit_conf('libcxx_headers',
self.libcxx_src_root + '/include')
if not os.path.isdir(libcxx_headers):
self.lit_config.fatal("libcxx_headers='%s' is not a directory."
% libcxx_headers)
self.compile_flags += ['-I' + libcxx_headers]
def configure_compile_flags_exceptions(self):
enable_exceptions = self.get_lit_bool('enable_exceptions', True)
if enable_exceptions:
self.config.available_features.add('exceptions')
else:
self.compile_flags += ['-fno-exceptions']
def configure_compile_flags_rtti(self):
enable_rtti = self.get_lit_bool('enable_rtti', True)
if enable_rtti:
self.config.available_features.add('rtti')
else:
self.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI']
def configure_compile_flags_no_threads(self):
self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
self.config.available_features.add('libcpp-has-no-threads')
def configure_compile_flags_no_monotonic_clock(self):
self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK']
self.config.available_features.add('libcpp-has-no-monotonic-clock')
def configure_link_flags(self): def configure_link_flags(self):
self.link_flags += ['-nodefaultlibs'] self.link_flags += ['-nodefaultlibs']
# Configure library path
self.configure_link_flags_cxx_library_path()
self.configure_link_flags_abi_library_path()
# Configure libraries
self.configure_link_flags_cxx_library()
self.configure_link_flags_abi_library()
self.configure_extra_library_flags()
link_flags_str = self.get_lit_conf('link_flags', '')
self.link_flags += shlex.split(link_flags_str)
def configure_link_flags_cxx_library_path(self):
libcxx_library = self.get_lit_conf('libcxx_library') libcxx_library = self.get_lit_conf('libcxx_library')
# Configure libc++ library paths. # Configure libc++ library paths.
if libcxx_library is not None: if libcxx_library is not None:
@@ -323,25 +352,31 @@ class Configuration(object):
self.lit_config.fatal( self.lit_config.fatal(
"libcxx_library='%s' is not a valid file." % "libcxx_library='%s' is not a valid file." %
libcxx_library) libcxx_library)
if self.use_system_lib: if self.use_system_cxx_lib:
self.lit_config.fatal( self.lit_config.fatal(
"Conflicting options: 'libcxx_library' cannot be used " "Conflicting options: 'libcxx_library' cannot be used "
"with 'use_system_lib=true'") "with 'use_system_cxx_lib=true'")
self.link_flags += ['-Wl,-rpath,' + self.link_flags += ['-Wl,-rpath,' +
os.path.dirname(libcxx_library)] os.path.dirname(libcxx_library)]
elif not self.use_system_lib: elif not self.use_system_cxx_lib:
self.link_flags += ['-L' + self.library_root, self.link_flags += ['-L' + self.cxx_library_root,
'-Wl,-rpath,' + self.library_root] '-Wl,-rpath,' + self.cxx_library_root]
def configure_link_flags_abi_library_path(self):
# Configure ABI library paths. # Configure ABI library paths.
abi_library_path = self.get_lit_conf('abi_library_path', '') abi_library_path = self.get_lit_conf('abi_library_path', '')
if abi_library_path: if abi_library_path:
self.link_flags += ['-L' + abi_library_path, self.link_flags += ['-L' + abi_library_path,
'-Wl,-rpath,' + abi_library_path] '-Wl,-rpath,' + abi_library_path]
# Configure libraries
def configure_link_flags_cxx_library(self):
libcxx_library = self.get_lit_conf('libcxx_library')
if libcxx_library: if libcxx_library:
self.link_flags += [libcxx_library] self.link_flags += [libcxx_library]
else: else:
self.link_flags += ['-lc++'] self.link_flags += ['-lc++']
def configure_link_flags_abi_library(self):
cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
if cxx_abi == 'libstdc++': if cxx_abi == 'libstdc++':
self.link_flags += ['-lstdc++'] self.link_flags += ['-lstdc++']
@@ -356,20 +391,28 @@ class Configuration(object):
else: else:
self.lit_config.fatal( self.lit_config.fatal(
'C++ ABI setting %s unsupported for tests' % cxx_abi) 'C++ ABI setting %s unsupported for tests' % cxx_abi)
# Configure extra libraries.
def configure_extra_library_flags(self):
enable_threads = self.get_lit_bool('enable_threads', True)
llvm_unwinder = self.get_lit_conf('llvm_unwinder', False)
if sys.platform == 'darwin': if sys.platform == 'darwin':
self.link_flags += ['-lSystem'] self.link_flags += ['-lSystem']
elif sys.platform.startswith('linux'): elif sys.platform.startswith('linux'):
self.link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread', if not llvm_unwinder:
'-lrt', '-lgcc_s'] self.link_flags += ['-lgcc_eh']
self.link_flags += ['-lc', '-lm']
if enable_threads:
self.link_flags += ['-lpthread']
self.link_flags += ['-lrt']
if llvm_unwinder:
self.link_flags += ['-lunwind', '-ldl']
else:
self.link_flags += ['-lgcc_s']
elif sys.platform.startswith('freebsd'): elif sys.platform.startswith('freebsd'):
self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s'] self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s']
else: else:
self.lit_config.fatal("unrecognized system: %r" % sys.platform) self.lit_config.fatal("unrecognized system: %r" % sys.platform)
link_flags_str = self.get_lit_conf('link_flags', '')
self.link_flags += shlex.split(link_flags_str)
def configure_sanitizer(self): def configure_sanitizer(self):
san = self.get_lit_conf('use_sanitizer', '').strip() san = self.get_lit_conf('use_sanitizer', '').strip()
if san: if san:
@@ -409,7 +452,7 @@ class Configuration(object):
self.config.available_features.add('tsan') self.config.available_features.add('tsan')
else: else:
self.lit_config.fatal('unsupported value for ' self.lit_config.fatal('unsupported value for '
'libcxx_use_san: {0}'.format(san)) 'use_sanitizer: {0}'.format(san))
def configure_triple(self): def configure_triple(self):
# Get or infer the target triple. # Get or infer the target triple.
@@ -437,10 +480,10 @@ class Configuration(object):
"inferred target_triple as: %r" % self.config.target_triple) "inferred target_triple as: %r" % self.config.target_triple)
def configure_env(self): def configure_env(self):
if sys.platform == 'darwin' and not self.use_system_lib: if sys.platform == 'darwin' and not self.use_system_cxx_lib:
libcxx_library = self.get_lit_conf('libcxx_library') libcxx_library = self.get_lit_conf('libcxx_library')
if libcxx_library: if libcxx_library:
library_root = os.path.dirname(libcxx_library) cxx_library_root = os.path.dirname(libcxx_library)
else: else:
library_root = self.library_root cxx_library_root = self.cxx_library_root
self.env['DYLD_LIBRARY_PATH'] = library_root self.env['DYLD_LIBRARY_PATH'] = cxx_library_root

View File

@@ -3,7 +3,7 @@ config.cxx_under_test = "@LIBCXX_COMPILER@"
config.std = "@LIBCXX_STD_VERSION@" config.std = "@LIBCXX_STD_VERSION@"
config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@" config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@" config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
config.libcxx_library_root = "@LIBCXX_LIBRARY_DIR@" config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@"
config.enable_exceptions = "@LIBCXX_ENABLE_EXCEPTIONS@" config.enable_exceptions = "@LIBCXX_ENABLE_EXCEPTIONS@"
config.enable_rtti = "@LIBCXX_ENABLE_RTTI@" config.enable_rtti = "@LIBCXX_ENABLE_RTTI@"
config.enable_shared = "@LIBCXX_ENABLE_SHARED@" config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
@@ -13,6 +13,7 @@ config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@" config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.use_sanitizer = "@LLVM_USE_SANITIZER@" config.use_sanitizer = "@LLVM_USE_SANITIZER@"
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@" config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
config.configuration_variant = "@LIBCXX_LIT_VARIANT@"
# Let the main config do the real work. # Let the main config do the real work.
lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg") lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")

View File

@@ -13,6 +13,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
int main() int main()

View File

@@ -29,8 +29,9 @@ int main()
{ {
typedef std::vector<bool> T; typedef std::vector<bool> T;
typedef std::hash<T> H; typedef std::hash<T> H;
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, static_assert((std::is_same<H::argument_type, T>::value), "" );
H>::value), ""); static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
bool ba[] = {true, false, true, true, false}; bool ba[] = {true, false, true, true, false};
T vb(std::begin(ba), std::end(ba)); T vb(std::begin(ba), std::end(ba));
H h; H h;

View File

@@ -12,6 +12,7 @@
// iterator erase(const_iterator position); // iterator erase(const_iterator position);
#include <vector> #include <vector>
#include <iterator>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -12,6 +12,7 @@
// iterator erase(const_iterator first, const_iterator last); // iterator erase(const_iterator first, const_iterator last);
#include <vector> #include <vector>
#include <iterator>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -13,6 +13,7 @@
// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y); // void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
#include <vector> #include <vector>
#include <iterator>
#include <cassert> #include <cassert>
#include "test_allocator.h" #include "test_allocator.h"
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -10,6 +10,7 @@
// test <stdint.h> // test <stdint.h>
#include <stdint.h> #include <stdint.h>
#include <cstddef>
#include <csignal> #include <csignal>
#include <cwctype> #include <cwctype>
#include <climits> #include <climits>

View File

@@ -27,8 +27,8 @@ test(int i)
{ {
typedef std::error_code T; typedef std::error_code T;
typedef std::hash<T> H; typedef std::hash<T> H;
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, static_assert((std::is_same<H::argument_type, T>::value), "" );
H>::value), ""); static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
H h; H h;
T ec(i, std::system_category()); T ec(i, std::system_category());
assert(h(ec) == i); assert(h(ec) == i);

View File

@@ -29,8 +29,8 @@ void
test() test()
{ {
typedef std::hash<T> H; typedef std::hash<T> H;
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, static_assert((std::is_same<typename H::argument_type, T>::value), "" );
H>::value), ""); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
H h; H h;
// std::string g1 = "1234567890"; // std::string g1 = "1234567890";
// std::string g2 = "1234567891"; // std::string g2 = "1234567891";

View File

@@ -13,5 +13,5 @@
int main() int main()
{ {
std::experimental::erased_type e(); std::experimental::erased_type e;
} }

View File

@@ -18,6 +18,7 @@
#include <iterator> #include <iterator>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <utility>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <cassert> #include <cassert>

View File

@@ -10,6 +10,8 @@
// test <cstdint> // test <cstdint>
#include <cstdint> #include <cstdint>
#include <cstddef>
#include <cwchar>
#include <csignal> #include <csignal>
#include <cwctype> #include <cwctype>
#include <climits> #include <climits>

View File

@@ -9,8 +9,8 @@
// //
// This test uses new symbols that were not defined in the libc++ shipped on // This test uses new symbols that were not defined in the libc++ shipped on
// darwin11 and darwin12: // darwin11 and darwin12:
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <locale> // <locale>

View File

@@ -13,8 +13,8 @@
// charT tolower(charT) const; // charT tolower(charT) const;
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// XFAIL: linux // XFAIL: linux
#include <locale> #include <locale>

View File

@@ -13,8 +13,8 @@
// const charT* tolower(charT* low, const charT* high) const; // const charT* tolower(charT* low, const charT* high) const;
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// XFAIL: linux // XFAIL: linux
#include <locale> #include <locale>

View File

@@ -13,8 +13,8 @@
// charT toupper(charT) const; // charT toupper(charT) const;
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// XFAIL: linux // XFAIL: linux
#include <locale> #include <locale>

View File

@@ -13,8 +13,8 @@
// const charT* toupper(charT* low, const charT* high) const; // const charT* toupper(charT* low, const charT* high) const;
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// XFAIL: linux // XFAIL: linux
#include <locale> #include <locale>

View File

@@ -9,8 +9,8 @@
// //
// This test uses new symbols that were not defined in the libc++ shipped on // This test uses new symbols that were not defined in the libc++ shipped on
// darwin11 and darwin12: // darwin11 and darwin12:
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <locale> // <locale>

View File

@@ -7,6 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// XFAIL: android
// <locale> // <locale>
// class num_put<charT, OutputIterator> // class num_put<charT, OutputIterator>
@@ -15,7 +17,6 @@
// TODO GLIBC uses a different string for positive and negative NAN numbers. // TODO GLIBC uses a different string for positive and negative NAN numbers.
// XFAIL: linux-gnu // XFAIL: linux-gnu
// XFAIL: android
#include <locale> #include <locale>
#include <ios> #include <ios>

View File

@@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <locale> // <locale>

View File

@@ -9,8 +9,8 @@
// //
// This test uses new symbols that were not defined in the libc++ shipped on // This test uses new symbols that were not defined in the libc++ shipped on
// darwin11 and darwin12: // darwin11 and darwin12:
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <locale> // <locale>

View File

@@ -23,4 +23,13 @@ int main()
r2.assign(r1); r2.assign(r1);
assert(r2.flags() == std::regex::ECMAScript); assert(r2.flags() == std::regex::ECMAScript);
assert(r2.mark_count() == 2); assert(r2.mark_count() == 2);
assert(std::regex_search("ab", r2));
bool caught = false;
try { r2.assign("(def", std::regex::extended); }
catch(std::regex_error &) { caught = true; }
assert(caught);
assert(r2.flags() == std::regex::ECMAScript);
assert(r2.mark_count() == 2);
assert(std::regex_search("ab", r2));
} }

View File

@@ -16,8 +16,8 @@
// REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.en_US.UTF-8
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// TODO: investigation needed // TODO: investigation needed
// XFAIL: linux-gnu // XFAIL: linux-gnu

View File

@@ -27,8 +27,8 @@ void
test() test()
{ {
typedef std::hash<T> H; typedef std::hash<T> H;
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, static_assert((std::is_same<typename H::argument_type, T>::value), "" );
H>::value), ""); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
H h; H h;
std::string g1 = "1234567890"; std::string g1 = "1234567890";
std::string g2 = "1234567891"; std::string g2 = "1234567891";

View File

@@ -13,6 +13,7 @@
// assign(basic_string<charT,traits>&& str); // assign(basic_string<charT,traits>&& str);
#include <string> #include <string>
#include <utility>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -18,6 +18,7 @@
// operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs); // operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs);
#include <string> #include <string>
#include <utility>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -18,6 +18,7 @@
// operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs); // operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs);
#include <string> #include <string>
#include <utility>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -18,6 +18,7 @@
// operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs); // operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs);
#include <string> #include <string>
#include <utility>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -18,6 +18,7 @@
// operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs); // operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs);
#include <string> #include <string>
#include <utility>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -30,6 +30,7 @@
// const basic_string<charT,traits,Allocator>&& rhs); // const basic_string<charT,traits,Allocator>&& rhs);
#include <string> #include <string>
#include <utility>
#include <cassert> #include <cassert>
#include "min_allocator.h" #include "min_allocator.h"

View File

@@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <string> // <string>

View File

@@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <string> // <string>

View File

@@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <string> // <string>

View File

@@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <string> // <string>

View File

@@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// <string> // <string>

View File

@@ -12,9 +12,9 @@
// LWG 2056 changed the values of future_errc, so if we're using new headers // LWG 2056 changed the values of future_errc, so if we're using new headers
// with an old library we'll get incorrect messages. // with an old library we'll get incorrect messages.
// //
// XFAIL: with_system_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_lib=x86_64-apple-darwin12 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
// XFAIL: with_system_lib=x86_64-apple-darwin13 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin13
// <future> // <future>

View File

@@ -12,6 +12,7 @@
#include <cstddef> #include <cstddef>
#include <type_traits> #include <type_traits>
#include <utility>
#include <cstdlib> #include <cstdlib>
#include <new> #include <new>
#include <climits> #include <climits>

View File

@@ -28,6 +28,8 @@ int main()
std::thread::id id1; std::thread::id id1;
std::thread::id id2 = std::this_thread::get_id(); std::thread::id id2 = std::this_thread::get_id();
typedef std::hash<std::thread::id> H; typedef std::hash<std::thread::id> H;
static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
H h; H h;
assert(h(id1) != h(id2)); assert(h(id1) != h(id2));
} }

View File

@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include <scoped_allocator> #include <scoped_allocator>
#include <memory>
#include <cassert> #include <cassert>
#if __cplusplus >= 201103L #if __cplusplus >= 201103L

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::divides<int> F; typedef std::divides<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(36, 4) == 9); assert(f(36, 4) == 9);
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::divides<> F2; typedef std::divides<> F2;

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::minus<int> F; typedef std::minus<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(3, 2) == 1); assert(f(3, 2) == 1);
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::minus<> F2; typedef std::minus<> F2;

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::modulus<int> F; typedef std::modulus<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(36, 8) == 4); assert(f(36, 8) == 4);
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::modulus<> F2; typedef std::modulus<> F2;

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::multiplies<int> F; typedef std::multiplies<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(3, 2) == 6); assert(f(3, 2) == 6);
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::multiplies<> F2; typedef std::multiplies<> F2;

View File

@@ -19,7 +19,8 @@ int main()
{ {
typedef std::negate<int> F; typedef std::negate<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), ""); static_assert((std::is_same<F::argument_type, int>::value), "" );
static_assert((std::is_same<F::result_type, int>::value), "" );
assert(f(36) == -36); assert(f(36) == -36);
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::negate<> F2; typedef std::negate<> F2;

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::plus<int> F; typedef std::plus<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(3, 2) == 5); assert(f(3, 2) == 5);
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::plus<> F2; typedef std::plus<> F2;

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::bit_and<int> F; typedef std::bit_and<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(0xEA95, 0xEA95) == 0xEA95); assert(f(0xEA95, 0xEA95) == 0xEA95);
assert(f(0xEA95, 0x58D3) == 0x4891); assert(f(0xEA95, 0x58D3) == 0x4891);
assert(f(0x58D3, 0xEA95) == 0x4891); assert(f(0x58D3, 0xEA95) == 0x4891);

View File

@@ -20,7 +20,8 @@ int main()
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
typedef std::bit_not<int> F; typedef std::bit_not<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), ""); static_assert((std::is_same<F::argument_type, int>::value), "" );
static_assert((std::is_same<F::result_type, int>::value), "" );
assert((f(0xEA95) & 0xFFFF ) == 0x156A); assert((f(0xEA95) & 0xFFFF ) == 0x156A);
assert((f(0x58D3) & 0xFFFF ) == 0xA72C); assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
assert((f(0) & 0xFFFF ) == 0xFFFF); assert((f(0) & 0xFFFF ) == 0xFFFF);

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::bit_or<int> F; typedef std::bit_or<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(0xEA95, 0xEA95) == 0xEA95); assert(f(0xEA95, 0xEA95) == 0xEA95);
assert(f(0xEA95, 0x58D3) == 0xFAD7); assert(f(0xEA95, 0x58D3) == 0xFAD7);
assert(f(0x58D3, 0xEA95) == 0xFAD7); assert(f(0x58D3, 0xEA95) == 0xFAD7);

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::bit_xor<int> F; typedef std::bit_xor<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<int, F::result_type>::value), "" );
assert(f(0xEA95, 0xEA95) == 0); assert(f(0xEA95, 0xEA95) == 0);
assert(f(0xEA95, 0x58D3) == 0xB246); assert(f(0xEA95, 0x58D3) == 0xB246);
assert(f(0x58D3, 0xEA95) == 0xB246); assert(f(0x58D3, 0xEA95) == 0xB246);

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::equal_to<int> F; typedef std::equal_to<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(f(36, 36)); assert(f(36, 36));
assert(!f(36, 6)); assert(!f(36, 6));
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::greater<int> F; typedef std::greater<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(!f(36, 36)); assert(!f(36, 36));
assert(f(36, 6)); assert(f(36, 6));
assert(!f(6, 36)); assert(!f(6, 36));

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::greater_equal<int> F; typedef std::greater_equal<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(f(36, 36)); assert(f(36, 36));
assert(f(36, 6)); assert(f(36, 6));
assert(!f(6, 36)); assert(!f(6, 36));

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::less<int> F; typedef std::less<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(!f(36, 36)); assert(!f(36, 36));
assert(!f(36, 6)); assert(!f(36, 6));
assert(f(6, 36)); assert(f(6, 36));

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::less_equal<int> F; typedef std::less_equal<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(f(36, 36)); assert(f(36, 36));
assert(!f(36, 6)); assert(!f(36, 6));
assert(f(6, 36)); assert(f(6, 36));

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::not_equal_to<int> F; typedef std::not_equal_to<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(!f(36, 36)); assert(!f(36, 36));
assert(f(36, 6)); assert(f(36, 6));
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11

View File

@@ -10,40 +10,99 @@
// <functional> // <functional>
// template<Returnable R, CopyConstructible... ArgTypes> // template<Returnable R, CopyConstructible... ArgTypes>
// class function<R(ArgTypes...)> // class function<R(ArgTypes...)> {
// : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
// // ArgTypes contains T1
// : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
// // ArgTypes contains T1 and T2
// {
// public: // public:
// typedef R result_type; // typedef R result_type;
// ... // typedef T1 argument_type; // iff sizeof...(ArgTypes) == 1 and
// }; // // the type in ArgTypes is T1
// typedef T1 first_argument_type; // iff sizeof...(ArgTypes) == 2 and
// // ArgTypes contains T1 and T2
// typedef T2 second_argument_type; // iff sizeof...(ArgTypes) == 2 and
// // ArgTypes contains T1 and T2
// ...
// };
#include <functional> #include <functional>
#include <type_traits> #include <type_traits>
template <typename T>
class has_argument_type
{
typedef char yes;
typedef long no;
template <typename C> static yes check( typename C::argument_type * );
template <typename C> static no check(...);
public:
enum { value = sizeof(check<T>(0)) == sizeof(yes) };
};
template <typename T>
class has_first_argument_type
{
typedef char yes;
typedef long no;
template <typename C> static yes check( typename C::first_argument_type * );
template <typename C> static no check(...);
public:
enum { value = sizeof(check<T>(0)) == sizeof(yes) };
};
template <typename T>
class has_second_argument_type
{
typedef char yes;
typedef long no;
template <typename C> static yes check( typename C::second_argument_type *);
template <typename C> static no check(...);
public:
enum { value = sizeof(check<T>(0)) == sizeof(yes) };
};
template <class F, class return_type>
void test_nullary_function ()
{
static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
static_assert((!has_argument_type<F>::value), "" );
static_assert((!has_first_argument_type<F>::value), "" );
static_assert((!has_second_argument_type<F>::value), "" );
}
template <class F, class return_type, class arg_type>
void test_unary_function ()
{
static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
static_assert((std::is_same<typename F::argument_type, arg_type>::value), "" );
static_assert((!has_first_argument_type<F>::value), "" );
static_assert((!has_second_argument_type<F>::value), "" );
}
template <class F, class return_type, class arg_type1, class arg_type2>
void test_binary_function ()
{
static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
static_assert((std::is_same<typename F::first_argument_type, arg_type1>::value), "" );
static_assert((std::is_same<typename F::second_argument_type, arg_type2>::value), "" );
static_assert((!has_argument_type<F>::value), "" );
}
template <class F, class return_type>
void test_other_function ()
{
static_assert((std::is_same<typename F::result_type, return_type>::value), "" );
static_assert((!has_argument_type<F>::value), "" );
static_assert((!has_first_argument_type<F>::value), "" );
static_assert((!has_second_argument_type<F>::value), "" );
}
int main() int main()
{ {
static_assert((!std::is_base_of<std::unary_function <int, int>, test_nullary_function<std::function<int()>, int>();
std::function<int()> >::value), ""); test_unary_function <std::function<double(int)>, double, int>();
static_assert((!std::is_base_of<std::binary_function<int, int, int>, test_binary_function <std::function<double(int, char)>, double, int, char>();
std::function<int()> >::value), ""); test_other_function <std::function<double(int, char, double)>, double>();
static_assert(( std::is_same< std::function<int()>::result_type,
int>::value), "");
static_assert(( std::is_base_of<std::unary_function <int, double>,
std::function<double(int)> >::value), "");
static_assert((!std::is_base_of<std::binary_function<int, int, double>,
std::function<double(int)> >::value), "");
static_assert(( std::is_same< std::function<double(int)>::result_type,
double>::value), "");
static_assert((!std::is_base_of<std::unary_function <int, double>,
std::function<double(int, char)> >::value), "");
static_assert(( std::is_base_of<std::binary_function<int, char, double>,
std::function<double(int, char)> >::value), "");
static_assert(( std::is_same< std::function<double(int, char)>::result_type,
double>::value), "");
} }

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::logical_and<int> F; typedef std::logical_and<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(f(36, 36)); assert(f(36, 36));
assert(!f(36, 0)); assert(!f(36, 0));
assert(!f(0, 36)); assert(!f(0, 36));

View File

@@ -19,7 +19,8 @@ int main()
{ {
typedef std::logical_not<int> F; typedef std::logical_not<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), ""); static_assert((std::is_same<F::argument_type, int>::value), "" );
static_assert((std::is_same<F::result_type, bool>::value), "" );
assert(!f(36)); assert(!f(36));
assert(f(0)); assert(f(0));
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::logical_or<int> F; typedef std::logical_or<int> F;
const F f = F(); const F f = F();
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(f(36, 36)); assert(f(36, 36));
assert(f(36, 0)); assert(f(36, 0));
assert(f(0, 36)); assert(f(0, 36));

View File

@@ -19,7 +19,9 @@ int main()
{ {
typedef std::binary_negate<std::logical_and<int> > F; typedef std::binary_negate<std::logical_and<int> > F;
const F f = F(std::logical_and<int>()); const F f = F(std::logical_and<int>());
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); static_assert((std::is_same<int, F::first_argument_type>::value), "" );
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
static_assert((std::is_same<bool, F::result_type>::value), "" );
assert(!f(36, 36)); assert(!f(36, 36));
assert( f(36, 0)); assert( f(36, 0));
assert( f(0, 36)); assert( f(0, 36));

View File

@@ -19,7 +19,8 @@ int main()
{ {
typedef std::unary_negate<std::logical_not<int> > F; typedef std::unary_negate<std::logical_not<int> > F;
const F f = F(std::logical_not<int>()); const F f = F(std::logical_not<int>());
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), ""); static_assert((std::is_same<F::argument_type, int>::value), "" );
static_assert((std::is_same<F::result_type, bool>::value), "" );
assert(f(36)); assert(f(36));
assert(!f(0)); assert(!f(0));
} }

View File

@@ -33,11 +33,12 @@ template <class T>
void void
test() test()
{ {
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, typedef std::hash<T> H;
std::hash<T> >::value), ""); static_assert((std::is_same<typename H::argument_type, T>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
typedef typename std::underlying_type<T>::type under_type; typedef typename std::underlying_type<T>::type under_type;
std::hash<T> h1; H h1;
std::hash<under_type> h2; std::hash<under_type> h2;
for (int i = 0; i <= 5; ++i) for (int i = 0; i <= 5; ++i)
{ {

View File

@@ -28,9 +28,11 @@ template <class T>
void void
test() test()
{ {
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, typedef std::hash<T> H;
std::hash<T> >::value), ""); static_assert((std::is_same<typename H::argument_type, T>::value), "" );
std::hash<T> h; static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
H h;
std::size_t t0 = h(0.); std::size_t t0 = h(0.);
std::size_t tn0 = h(-0.); std::size_t tn0 = h(-0.);
std::size_t tp1 = h(0.1); std::size_t tp1 = h(0.1);

View File

@@ -27,9 +27,11 @@ template <class T>
void void
test() test()
{ {
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, typedef std::hash<T> H;
std::hash<T> >::value), ""); static_assert((std::is_same<typename H::argument_type, T>::value), "" );
std::hash<T> h; static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
H h;
for (int i = 0; i <= 5; ++i) for (int i = 0; i <= 5; ++i)
{ {
T t(i); T t(i);

View File

@@ -27,9 +27,11 @@ template <class T>
void void
test() test()
{ {
static_assert((std::is_base_of<std::unary_function<T, std::size_t>, typedef std::hash<T> H;
std::hash<T> >::value), ""); static_assert((std::is_same<typename H::argument_type, T>::value), "" );
std::hash<T> h; static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
H h;
typedef typename std::remove_pointer<T>::type type; typedef typename std::remove_pointer<T>::type type;
type i; type i;
type j; type j;

View File

@@ -17,6 +17,7 @@
#define DELETER_H #define DELETER_H
#include <type_traits> #include <type_traits>
#include <utility>
#include <cassert> #include <cassert>
template <class T> template <class T>

View File

@@ -14,6 +14,7 @@
// Test unique_ptr move assignment // Test unique_ptr move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't copy from lvalue // Can't copy from lvalue

View File

@@ -17,6 +17,7 @@
// deleter is a reference, not even that. // deleter is a reference, not even that.
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -14,6 +14,7 @@
// Test unique_ptr move assignment // Test unique_ptr move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't copy from const lvalue // Can't copy from const lvalue

View File

@@ -14,6 +14,7 @@
// Test unique_ptr move assignment // Test unique_ptr move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't copy from lvalue // Can't copy from lvalue

View File

@@ -14,6 +14,7 @@
// Test unique_ptr move ctor // Test unique_ptr move ctor
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// test move ctor. Can't copy from const lvalue // test move ctor. Can't copy from const lvalue

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't assign from lvalue // Can't assign from lvalue

View File

@@ -16,6 +16,7 @@
// Can't assign from lvalue // Can't assign from lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -16,6 +16,7 @@
// Can't assign from lvalue // Can't assign from lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't assign from const lvalue // Can't assign from const lvalue

View File

@@ -16,6 +16,7 @@
// Can't assign from const lvalue // Can't assign from const lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -16,6 +16,7 @@
// Can't assign from const lvalue // Can't assign from const lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
struct A struct A

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -16,6 +16,7 @@
// test converting move assignment with reference deleters // test converting move assignment with reference deleters
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../deleter.h" #include "../deleter.h"

View File

@@ -17,6 +17,7 @@
// deleter is a reference, not even that. // deleter is a reference, not even that.
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -17,6 +17,7 @@
// deleter is a reference, not even that. // deleter is a reference, not even that.
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't assign from lvalue // Can't assign from lvalue

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
struct A struct A

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -16,6 +16,7 @@
// Can't assign from lvalue // Can't assign from lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -16,6 +16,7 @@
// test converting move assignment with reference deleters // test converting move assignment with reference deleters
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -14,6 +14,7 @@
// Test unique_ptr converting move assignment // Test unique_ptr converting move assignment
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// Can't assign from const lvalue // Can't assign from const lvalue

View File

@@ -16,6 +16,7 @@
// Can't assign from const lvalue // Can't assign from const lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -16,6 +16,7 @@
// Can't assign from const lvalue // Can't assign from const lvalue
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
#include "../../deleter.h" #include "../../deleter.h"

View File

@@ -16,6 +16,7 @@
// Do not convert from an array unique_ptr // Do not convert from an array unique_ptr
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
struct A struct A

View File

@@ -14,6 +14,7 @@
// Test unique_ptr(pointer) ctor // Test unique_ptr(pointer) ctor
#include <memory> #include <memory>
#include <utility>
#include <cassert> #include <cassert>
// template <class U> explicit unique_ptr(auto_ptr<U>&); // template <class U> explicit unique_ptr(auto_ptr<U>&);

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