Import libc++ r188413. More support for current C++ development and
various bugfixes.
This commit is contained in:
parent
77f07e0bd7
commit
a3a22d9cef
|
@ -76,6 +76,10 @@ N: Bjorn Reese
|
|||
E: breese@users.sourceforge.net
|
||||
D: Initial regex prototype
|
||||
|
||||
N: Nico Rieck
|
||||
E: nico.rieck@gmail.com
|
||||
D: Windows fixes
|
||||
|
||||
N: Jonathan Sauer
|
||||
D: Minor patches, mostly related to constexpr
|
||||
|
||||
|
@ -105,6 +109,14 @@ N: Zhang Xiongpang
|
|||
E: zhangxiongpang@gmail.com
|
||||
D: Minor patches and bug fixes.
|
||||
|
||||
N: Xing Xue
|
||||
E: xingxue@ca.ibm.com
|
||||
D: AIX port
|
||||
|
||||
N: Zhihao Yuan
|
||||
E: lichray@gmail.com
|
||||
D: Standard compatibility fixes.
|
||||
|
||||
N: Jeffrey Yasskin
|
||||
E: jyasskin@gmail.com
|
||||
E: jyasskin@google.com
|
||||
|
|
|
@ -45,6 +45,93 @@ test_int()
|
|||
assert(ia[3] == 1);
|
||||
}
|
||||
|
||||
void
|
||||
test_int_array()
|
||||
{
|
||||
const unsigned n = 4;
|
||||
int ia[n] = {0};
|
||||
assert(std::fill_n(ia, n, static_cast<char>(1)) == std::next(ia, n));
|
||||
assert(ia[0] == 1);
|
||||
assert(ia[1] == 1);
|
||||
assert(ia[2] == 1);
|
||||
assert(ia[3] == 1);
|
||||
}
|
||||
|
||||
struct source {
|
||||
source() : i(0) { }
|
||||
|
||||
operator int() const { return i++; }
|
||||
mutable int i;
|
||||
};
|
||||
|
||||
void
|
||||
test_int_array_struct_source()
|
||||
{
|
||||
const unsigned n = 4;
|
||||
int ia[n] = {0};
|
||||
assert(std::fill_n(ia, n, source()) == std::next(ia, n));
|
||||
assert(ia[0] == 0);
|
||||
assert(ia[1] == 1);
|
||||
assert(ia[2] == 2);
|
||||
assert(ia[3] == 3);
|
||||
}
|
||||
|
||||
struct test1 {
|
||||
test1() : c(0) { }
|
||||
test1(char c) : c(c + 1) { }
|
||||
char c;
|
||||
};
|
||||
|
||||
void
|
||||
test_struct_array()
|
||||
{
|
||||
const unsigned n = 4;
|
||||
test1 test1a[n] = {0};
|
||||
assert(std::fill_n(test1a, n, static_cast<char>(10)) == std::next(test1a, n));
|
||||
assert(test1a[0].c == 11);
|
||||
assert(test1a[1].c == 11);
|
||||
assert(test1a[2].c == 11);
|
||||
assert(test1a[3].c == 11);
|
||||
}
|
||||
|
||||
class A
|
||||
{
|
||||
char a_;
|
||||
public:
|
||||
A() {}
|
||||
explicit A(char a) : a_(a) {}
|
||||
operator unsigned char() const {return 'b';}
|
||||
|
||||
friend bool operator==(const A& x, const A& y)
|
||||
{return x.a_ == y.a_;}
|
||||
};
|
||||
|
||||
void
|
||||
test5()
|
||||
{
|
||||
A a[3];
|
||||
assert(std::fill_n(&a[0], 3, A('a')) == a+3);
|
||||
assert(a[0] == A('a'));
|
||||
assert(a[1] == A('a'));
|
||||
assert(a[2] == A('a'));
|
||||
}
|
||||
|
||||
struct Storage
|
||||
{
|
||||
union
|
||||
{
|
||||
unsigned char a;
|
||||
unsigned char b;
|
||||
};
|
||||
};
|
||||
|
||||
void test6()
|
||||
{
|
||||
Storage foo[5];
|
||||
std::fill_n(&foo[0], 5, Storage());
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_char<forward_iterator<char*> >();
|
||||
|
@ -56,4 +143,11 @@ int main()
|
|||
test_int<bidirectional_iterator<int*> >();
|
||||
test_int<random_access_iterator<int*> >();
|
||||
test_int<int*>();
|
||||
|
||||
test_int_array();
|
||||
test_int_array_struct_source();
|
||||
test_struct_array();
|
||||
|
||||
test5();
|
||||
test6();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int main()
|
||||
|
|
|
@ -22,15 +22,15 @@
|
|||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int comparison_count = 0;
|
||||
template <typename T>
|
||||
bool counting_equals ( const T &a, const T &b ) {
|
||||
++comparison_count;
|
||||
return a == b;
|
||||
}
|
||||
++comparison_count;
|
||||
return a == b;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "test_iterators.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#define HAS_FOUR_ITERATOR_VERSION
|
||||
#endif
|
||||
|
||||
int main()
|
||||
|
|
|
@ -12,6 +12,10 @@ import errno
|
|||
import time
|
||||
import shlex
|
||||
|
||||
import lit.Test
|
||||
import lit.formats
|
||||
import lit.util
|
||||
|
||||
# FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a
|
||||
# dependency there. What we more ideally would like to do is lift the "xfail"
|
||||
# and "requires" handling to be a core lit framework feature.
|
||||
|
@ -207,7 +211,7 @@ config.suffixes = ['.cpp']
|
|||
config.test_source_root = os.path.dirname(__file__)
|
||||
|
||||
# Gather various compiler parameters.
|
||||
cxx_under_test = lit.params.get('cxx_under_test', None)
|
||||
cxx_under_test = lit_config.params.get('cxx_under_test', None)
|
||||
if cxx_under_test is None:
|
||||
cxx_under_test = getattr(config, 'cxx_under_test', None)
|
||||
|
||||
|
@ -215,52 +219,53 @@ if cxx_under_test is None:
|
|||
clangxx = lit.util.which('clang++', config.environment['PATH'])
|
||||
if clangxx is not None:
|
||||
cxx_under_test = clangxx
|
||||
lit.note("inferred cxx_under_test as: %r" % (cxx_under_test,))
|
||||
lit_config.note("inferred cxx_under_test as: %r" % (cxx_under_test,))
|
||||
if cxx_under_test is None:
|
||||
lit.fatal('must specify user parameter cxx_under_test '
|
||||
'(e.g., --param=cxx_under_test=clang++)')
|
||||
lit_config.fatal('must specify user parameter cxx_under_test '
|
||||
'(e.g., --param=cxx_under_test=clang++)')
|
||||
|
||||
libcxx_src_root = lit.params.get('libcxx_src_root', None)
|
||||
libcxx_src_root = lit_config.params.get('libcxx_src_root', None)
|
||||
if libcxx_src_root is None:
|
||||
libcxx_src_root = getattr(config, 'libcxx_src_root', None)
|
||||
if libcxx_src_root is None:
|
||||
libcxx_src_root = os.path.dirname(config.test_source_root)
|
||||
|
||||
libcxx_obj_root = lit.params.get('libcxx_obj_root', None)
|
||||
libcxx_obj_root = lit_config.params.get('libcxx_obj_root', None)
|
||||
if libcxx_obj_root is None:
|
||||
libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
|
||||
if libcxx_obj_root is None:
|
||||
libcxx_obj_root = libcxx_src_root
|
||||
|
||||
cxx_has_stdcxx0x_flag_str = lit.params.get('cxx_has_stdcxx0x_flag', None)
|
||||
cxx_has_stdcxx0x_flag_str = lit_config.params.get('cxx_has_stdcxx0x_flag', None)
|
||||
if cxx_has_stdcxx0x_flag_str is not None:
|
||||
if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'):
|
||||
cxx_has_stdcxx0x_flag = True
|
||||
elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'):
|
||||
cxx_has_stdcxx0x_flag = False
|
||||
else:
|
||||
lit.fatal('user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
|
||||
lit_config.fatal(
|
||||
'user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
|
||||
else:
|
||||
cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True)
|
||||
|
||||
# This test suite supports testing against either the system library or the
|
||||
# locally built one; the former mode is useful for testing ABI compatibility
|
||||
# between the current headers and a shipping dynamic library.
|
||||
use_system_lib_str = lit.params.get('use_system_lib', None)
|
||||
use_system_lib_str = lit_config.params.get('use_system_lib', None)
|
||||
if use_system_lib_str is not None:
|
||||
if use_system_lib_str.lower() in ('1', 'true'):
|
||||
use_system_lib = True
|
||||
elif use_system_lib_str.lower() in ('', '0', 'false'):
|
||||
use_system_lib = False
|
||||
else:
|
||||
lit.fatal('user parameter use_system_lib should be 0 or 1')
|
||||
lit_config.fatal('user parameter use_system_lib should be 0 or 1')
|
||||
else:
|
||||
# Default to testing against the locally built libc++ library.
|
||||
use_system_lib = False
|
||||
lit.note("inferred use_system_lib as: %r" % (use_system_lib,))
|
||||
lit_config.note("inferred use_system_lib as: %r" % (use_system_lib,))
|
||||
|
||||
link_flags = []
|
||||
link_flags_str = lit.params.get('link_flags', None)
|
||||
link_flags_str = lit_config.params.get('link_flags', None)
|
||||
if link_flags_str is None:
|
||||
link_flags_str = getattr(config, 'link_flags', None)
|
||||
if link_flags_str is None:
|
||||
|
@ -270,8 +275,8 @@ if link_flags_str is None:
|
|||
link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread',
|
||||
'-lrt', '-lgcc_s']
|
||||
else:
|
||||
lit.fatal("unrecognized system")
|
||||
lit.note("inferred link_flags as: %r" % (link_flags,))
|
||||
lit_config.fatal("unrecognized system")
|
||||
lit_config.note("inferred link_flags as: %r" % (link_flags,))
|
||||
if not link_flags_str is None:
|
||||
link_flags += shlex.split(link_flags_str)
|
||||
|
||||
|
@ -294,7 +299,7 @@ elif sys.platform == 'linux2':
|
|||
compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS',
|
||||
'-D__STDC_CONSTANT_MACROS']
|
||||
else:
|
||||
lit.fatal("unrecognized system")
|
||||
lit_config.fatal("unrecognized system")
|
||||
|
||||
config.test_format = LibcxxTestFormat(
|
||||
cxx_under_test,
|
||||
|
@ -303,12 +308,12 @@ config.test_format = LibcxxTestFormat(
|
|||
exec_env = exec_env)
|
||||
|
||||
# Get or infer the target triple.
|
||||
config.target_triple = lit.params.get('target_triple', None)
|
||||
config.target_triple = lit_config.params.get('target_triple', None)
|
||||
# If no target triple was given, try to infer it from the compiler under test.
|
||||
if config.target_triple is None:
|
||||
config.target_triple = lit.util.capture(
|
||||
[cxx_under_test, '-dumpmachine']).strip()
|
||||
lit.note("inferred target_triple as: %r" % (config.target_triple,))
|
||||
lit_config.note("inferred target_triple as: %r" % (config.target_triple,))
|
||||
|
||||
# Write an "available feature" that combines the triple when use_system_lib is
|
||||
# enabled. This is so that we can easily write XFAIL markers for tests that are
|
||||
|
|
|
@ -7,4 +7,4 @@ config.python_executable = "@PYTHON_EXECUTABLE@"
|
|||
config.enable_shared = @LIBCXX_ENABLE_SHARED@
|
||||
|
||||
# Let the main config do the real work.
|
||||
lit.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
|
||||
lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
|
||||
|
|
|
@ -45,14 +45,14 @@ int main()
|
|||
test_buf f(bs.rdbuf());
|
||||
assert(f.sbumpc() == L'1');
|
||||
assert(f.sgetc() == L'2');
|
||||
assert(f.pbackfail(L'a') == -1);
|
||||
assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
|
||||
}
|
||||
{
|
||||
std::fstream bs("underflow.dat");
|
||||
test_buf f(bs.rdbuf());
|
||||
assert(f.sbumpc() == L'1');
|
||||
assert(f.sgetc() == L'2');
|
||||
assert(f.pbackfail(L'a') == -1);
|
||||
assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
|
||||
assert(f.sbumpc() == L'2');
|
||||
assert(f.sgetc() == L'3');
|
||||
}
|
||||
|
|
|
@ -79,6 +79,6 @@ int main()
|
|||
assert(f.sbumpc() == 0x4E51);
|
||||
assert(f.sbumpc() == 0x4E52);
|
||||
assert(f.sbumpc() == 0x4E53);
|
||||
assert(f.sbumpc() == -1);
|
||||
assert(f.sbumpc() == test_buf::traits_type::eof());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,29 +19,41 @@
|
|||
|
||||
#include "../cases.h"
|
||||
|
||||
template <class T>
|
||||
template <class T, int x>
|
||||
void
|
||||
test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
|
||||
test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
|
||||
{
|
||||
static_assert((std::is_same<decltype(std::imag(x)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::imag(T(x))), double>::value), "");
|
||||
assert(std::imag(x) == 0);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr T val {x};
|
||||
static_assert(std::imag(val) == 0, "");
|
||||
constexpr std::complex<T> t{val, val};
|
||||
static_assert(t.imag() == x, "" );
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class T, int x>
|
||||
void
|
||||
test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
|
||||
test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
|
||||
{
|
||||
static_assert((std::is_same<decltype(std::imag(x)), T>::value), "");
|
||||
static_assert((std::is_same<decltype(std::imag(T(x))), T>::value), "");
|
||||
assert(std::imag(x) == 0);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr T val {x};
|
||||
static_assert(std::imag(val) == 0, "");
|
||||
constexpr std::complex<T> t{val, val};
|
||||
static_assert(t.imag() == x, "" );
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<T>(0);
|
||||
test<T>(1);
|
||||
test<T>(10);
|
||||
test<T, 0>();
|
||||
test<T, 1>();
|
||||
test<T, 10>();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -19,29 +19,41 @@
|
|||
|
||||
#include "../cases.h"
|
||||
|
||||
template <class T>
|
||||
template <class T, int x>
|
||||
void
|
||||
test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
|
||||
test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
|
||||
{
|
||||
static_assert((std::is_same<decltype(std::real(x)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::real(T(x))), double>::value), "");
|
||||
assert(std::real(x) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr T val {x};
|
||||
static_assert(std::real(val) == val, "");
|
||||
constexpr std::complex<T> t{val, val};
|
||||
static_assert(t.real() == x, "" );
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class T, int x>
|
||||
void
|
||||
test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
|
||||
test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
|
||||
{
|
||||
static_assert((std::is_same<decltype(std::real(x)), T>::value), "");
|
||||
static_assert((std::is_same<decltype(std::real(T(x))), T>::value), "");
|
||||
assert(std::real(x) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr T val {x};
|
||||
static_assert(std::real(val) == val, "");
|
||||
constexpr std::complex<T> t{val, val};
|
||||
static_assert(t.real() == x, "" );
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
{
|
||||
test<T>(0);
|
||||
test<T>(1);
|
||||
test<T>(10);
|
||||
test<T, 0>();
|
||||
test<T, 1>();
|
||||
test<T, 10>();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -28,6 +28,21 @@ test()
|
|||
c /= c2;
|
||||
assert(c.real() == 1);
|
||||
assert(c.imag() == 0);
|
||||
|
||||
std::complex<T> c3;
|
||||
|
||||
c3 = c;
|
||||
std::complex<int> ic (1,1);
|
||||
c3 /= ic;
|
||||
assert(c3.real() == 0.5);
|
||||
assert(c3.imag() == -0.5);
|
||||
|
||||
c3 = c;
|
||||
std::complex<float> fc (1,1);
|
||||
c3 /= fc;
|
||||
assert(c3.real() == 0.5);
|
||||
assert(c3.imag() == -0.5);
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -28,6 +28,20 @@ test()
|
|||
c -= c2;
|
||||
assert(c.real() == -3);
|
||||
assert(c.imag() == -5);
|
||||
|
||||
std::complex<T> c3;
|
||||
|
||||
c3 = c;
|
||||
std::complex<int> ic (1,1);
|
||||
c3 -= ic;
|
||||
assert(c3.real() == -4);
|
||||
assert(c3.imag() == -6);
|
||||
|
||||
c3 = c;
|
||||
std::complex<float> fc (1,1);
|
||||
c3 -= fc;
|
||||
assert(c3.real() == -4);
|
||||
assert(c3.imag() == -6);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -28,6 +28,20 @@ test()
|
|||
c += c2;
|
||||
assert(c.real() == 3);
|
||||
assert(c.imag() == 5);
|
||||
|
||||
std::complex<T> c3;
|
||||
|
||||
c3 = c;
|
||||
std::complex<int> ic (1,1);
|
||||
c3 += ic;
|
||||
assert(c3.real() == 4);
|
||||
assert(c3.imag() == 6);
|
||||
|
||||
c3 = c;
|
||||
std::complex<float> fc (1,1);
|
||||
c3 += fc;
|
||||
assert(c3.real() == 4);
|
||||
assert(c3.imag() == 6);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -28,6 +28,20 @@ test()
|
|||
c *= c2;
|
||||
assert(c.real() == -4);
|
||||
assert(c.imag() == 7.5);
|
||||
|
||||
std::complex<T> c3;
|
||||
|
||||
c3 = c;
|
||||
std::complex<int> ic (1,1);
|
||||
c3 *= ic;
|
||||
assert(c3.real() == -11.5);
|
||||
assert(c3.imag() == 3.5);
|
||||
|
||||
c3 = c;
|
||||
std::complex<float> fc (1,1);
|
||||
c3 *= fc;
|
||||
assert(c3.real() == -11.5);
|
||||
assert(c3.imag() == 3.5);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
|
@ -15,6 +15,23 @@
|
|||
#include <complex>
|
||||
#include <cassert>
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test_constexpr()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr std::complex<T> c1;
|
||||
static_assert(c1.real() == 0, "");
|
||||
static_assert(c1.imag() == 0, "");
|
||||
constexpr std::complex<T> c2(3);
|
||||
static_assert(c2.real() == 3, "");
|
||||
static_assert(c2.imag() == 0, "");
|
||||
constexpr std::complex<T> c3(3, 4);
|
||||
static_assert(c3.real() == 3, "");
|
||||
static_assert(c3.imag() == 4, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
|
@ -34,6 +51,8 @@ test()
|
|||
c.imag(-5.5);
|
||||
assert(c.real() == -4.5);
|
||||
assert(c.imag() == -5.5);
|
||||
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -41,4 +60,5 @@ int main()
|
|||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
test_constexpr<int> ();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,20 @@
|
|||
|
||||
template <class T>
|
||||
void
|
||||
test(const std::complex<T>& lhs, const std::complex<T>& rhs, bool x)
|
||||
test_constexpr()
|
||||
{
|
||||
assert((lhs == rhs) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr std::complex<T> rhs(1.5, -2.5);
|
||||
static_assert( !(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr std::complex<T> rhs(1.5, 2.5);
|
||||
static_assert(lhs == rhs, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -30,13 +41,14 @@ test()
|
|||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
std::complex<T> rhs(1.5, -2.5);
|
||||
test(lhs, rhs, false);
|
||||
assert( !(lhs == rhs));
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
std::complex<T> rhs(1.5, 2.5);
|
||||
test(lhs, rhs, true);
|
||||
assert(lhs == rhs);
|
||||
}
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -44,4 +56,5 @@ int main()
|
|||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
// test_constexpr<int> ();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,30 @@
|
|||
|
||||
template <class T>
|
||||
void
|
||||
test(const std::complex<T>& lhs, const T& rhs, bool x)
|
||||
test_constexpr()
|
||||
{
|
||||
assert((lhs == rhs) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr T rhs(-2.5);
|
||||
static_assert(!(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 0);
|
||||
constexpr T rhs(-2.5);
|
||||
static_assert(!(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr T rhs(1.5);
|
||||
static_assert(!(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 0);
|
||||
constexpr T rhs(1.5);
|
||||
static_assert( (lhs == rhs), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -30,28 +51,31 @@ test()
|
|||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
T rhs(-2.5);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs == rhs));
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 0);
|
||||
std::complex<T> lhs(1.5, 0);
|
||||
T rhs(-2.5);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs == rhs));
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
T rhs(1.5);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs == rhs));
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 0);
|
||||
T rhs(1.5);
|
||||
test(lhs, rhs, true);
|
||||
assert( (lhs == rhs));
|
||||
}
|
||||
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
// test_constexpr<int> ();
|
||||
}
|
||||
|
|
|
@ -18,11 +18,23 @@
|
|||
|
||||
template <class T>
|
||||
void
|
||||
test(const std::complex<T>& lhs, const std::complex<T>& rhs, bool x)
|
||||
test_constexpr()
|
||||
{
|
||||
assert((lhs != rhs) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr std::complex<T> rhs(1.5, -2.5);
|
||||
static_assert(lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr std::complex<T> rhs(1.5, 2.5);
|
||||
static_assert(!(lhs != rhs), "" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
|
@ -30,18 +42,21 @@ test()
|
|||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
std::complex<T> rhs(1.5, -2.5);
|
||||
test(lhs, rhs, true);
|
||||
assert(lhs != rhs);
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
std::complex<T> rhs(1.5, 2.5);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs != rhs));
|
||||
}
|
||||
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
// test_constexpr<int> ();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,30 @@
|
|||
|
||||
template <class T>
|
||||
void
|
||||
test(const std::complex<T>& lhs, const T& rhs, bool x)
|
||||
test_constexpr()
|
||||
{
|
||||
assert((lhs != rhs) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr T rhs(-2.5);
|
||||
static_assert(lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 0);
|
||||
constexpr T rhs(-2.5);
|
||||
static_assert(lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 2.5);
|
||||
constexpr T rhs(1.5);
|
||||
static_assert(lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr std::complex<T> lhs(1.5, 0);
|
||||
constexpr T rhs(1.5);
|
||||
static_assert( !(lhs != rhs), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -30,23 +51,25 @@ test()
|
|||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
T rhs(-2.5);
|
||||
test(lhs, rhs, true);
|
||||
assert(lhs != rhs);
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 0);
|
||||
T rhs(-2.5);
|
||||
test(lhs, rhs, true);
|
||||
assert(lhs != rhs);
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 2.5);
|
||||
T rhs(1.5);
|
||||
test(lhs, rhs, true);
|
||||
assert(lhs != rhs);
|
||||
}
|
||||
{
|
||||
std::complex<T> lhs(1.5, 0);
|
||||
T rhs(1.5);
|
||||
test(lhs, rhs, false);
|
||||
assert( !(lhs != rhs));
|
||||
}
|
||||
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -54,4 +77,5 @@ int main()
|
|||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
}
|
||||
// test_constexpr<int> ();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,30 @@
|
|||
|
||||
template <class T>
|
||||
void
|
||||
test(const T& lhs, const std::complex<T>& rhs, bool x)
|
||||
test_constexpr()
|
||||
{
|
||||
assert((lhs == rhs) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr T lhs(-2.5);
|
||||
constexpr std::complex<T> rhs(1.5, 2.5);
|
||||
static_assert(!(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr T lhs(-2.5);
|
||||
constexpr std::complex<T> rhs(1.5, 0);
|
||||
static_assert(!(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr T lhs(1.5);
|
||||
constexpr std::complex<T> rhs(1.5, 2.5);
|
||||
static_assert(!(lhs == rhs), "");
|
||||
}
|
||||
{
|
||||
constexpr T lhs(1.5);
|
||||
constexpr std::complex<T> rhs(1.5, 0);
|
||||
static_assert(lhs == rhs, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -30,23 +51,25 @@ test()
|
|||
{
|
||||
T lhs(-2.5);
|
||||
std::complex<T> rhs(1.5, 2.5);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs == rhs));
|
||||
}
|
||||
{
|
||||
T lhs(-2.5);
|
||||
std::complex<T> rhs(1.5, 0);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs == rhs));
|
||||
}
|
||||
{
|
||||
T lhs(1.5);
|
||||
std::complex<T> rhs(1.5, 2.5);
|
||||
test(lhs, rhs, false);
|
||||
assert(!(lhs == rhs));
|
||||
}
|
||||
{
|
||||
T lhs(1.5);
|
||||
std::complex<T> rhs(1.5, 0);
|
||||
test(lhs, rhs, true);
|
||||
assert(lhs == rhs);
|
||||
}
|
||||
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -54,4 +77,5 @@ int main()
|
|||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
// test_constexpr<int>();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,30 @@
|
|||
|
||||
template <class T>
|
||||
void
|
||||
test(const T& lhs, const std::complex<T>& rhs, bool x)
|
||||
test_constexpr()
|
||||
{
|
||||
assert((lhs != rhs) == x);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr T lhs(-2.5);
|
||||
constexpr std::complex<T> rhs(1.5, 2.5);
|
||||
static_assert (lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr T lhs(-2.5);
|
||||
constexpr std::complex<T> rhs(1.5, 0);
|
||||
static_assert (lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr T lhs(1.5);
|
||||
constexpr std::complex<T> rhs(1.5, 2.5);
|
||||
static_assert (lhs != rhs, "");
|
||||
}
|
||||
{
|
||||
constexpr T lhs(1.5);
|
||||
constexpr std::complex<T> rhs(1.5, 0);
|
||||
static_assert (!(lhs != rhs), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -30,28 +51,31 @@ test()
|
|||
{
|
||||
T lhs(-2.5);
|
||||
std::complex<T> rhs(1.5, 2.5);
|
||||
test(lhs, rhs, true);
|
||||
assert (lhs != rhs);
|
||||
}
|
||||
{
|
||||
T lhs(-2.5);
|
||||
std::complex<T> rhs(1.5, 0);
|
||||
test(lhs, rhs, true);
|
||||
assert (lhs != rhs);
|
||||
}
|
||||
{
|
||||
T lhs(1.5);
|
||||
std::complex<T> rhs(1.5, 2.5);
|
||||
test(lhs, rhs, true);
|
||||
assert (lhs != rhs);
|
||||
}
|
||||
{
|
||||
T lhs(1.5);
|
||||
std::complex<T> rhs(1.5, 0);
|
||||
test(lhs, rhs, false);
|
||||
assert (!(lhs != rhs));
|
||||
}
|
||||
|
||||
test_constexpr<T> ();
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<float>();
|
||||
test<double>();
|
||||
test<long double>();
|
||||
// test_constexpr<int>();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ inline
|
|||
std::string
|
||||
get_temp_file_name()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef _LIBCPP_MSVCRT
|
||||
char* p = _tempnam( NULL, NULL );
|
||||
if (p == nullptr)
|
||||
abort();
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef __PRIVATE_CONSTRUCTOR__H
|
||||
#define __PRIVATE_CONSTRUCTOR__H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
struct PrivateConstructor {
|
||||
|
||||
PrivateConstructor static make ( int v ) { return PrivateConstructor(v); }
|
||||
int get () const { return val; }
|
||||
private:
|
||||
PrivateConstructor ( int v ) : val(v) {}
|
||||
int val;
|
||||
};
|
||||
|
||||
bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); }
|
||||
|
||||
bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; }
|
||||
bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); }
|
||||
|
||||
std::ostream & operator << ( std::ostream &os, const PrivateConstructor &foo ) { return os << foo.get (); }
|
||||
|
||||
#endif
|
|
@ -290,7 +290,7 @@ inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
|
|||
template <class Iter>
|
||||
inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
|
||||
|
||||
template <class Iter> // everything else
|
||||
template <class Iter> // everything else
|
||||
inline Iter base(Iter i) { return i; }
|
||||
|
||||
#endif // ITERATORS_H
|
||||
|
|
|
@ -21,4 +21,11 @@ int main()
|
|||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(36, 4) == 9);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::divides<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36, 4) == 9);
|
||||
assert(f2(36.0, 4) == 9);
|
||||
assert(f2(18, 4.0) == 4.5); // exact in binary
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,4 +21,11 @@ int main()
|
|||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(3, 2) == 1);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::minus<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(3,2) == 1);
|
||||
assert(f2(3.0, 2) == 1);
|
||||
assert(f2(3, 2.5) == 0.5);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,4 +21,11 @@ int main()
|
|||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(36, 8) == 4);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::modulus<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36, 8) == 4);
|
||||
assert(f2(36L, 8) == 4);
|
||||
assert(f2(36, 8L) == 4);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,4 +21,11 @@ int main()
|
|||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(3, 2) == 6);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::multiplies<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(3,2) == 6);
|
||||
assert(f2(3.0, 2) == 6);
|
||||
assert(f2(3, 2.5) == 7.5); // exact in binary
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,4 +21,11 @@ int main()
|
|||
const F f = F();
|
||||
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
|
||||
assert(f(36) == -36);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::negate<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36) == -36);
|
||||
assert(f2(36L) == -36);
|
||||
assert(f2(36.0) == -36);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,4 +21,11 @@ int main()
|
|||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
assert(f(3, 2) == 5);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::plus<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(3,2) == 5);
|
||||
assert(f2(3.0, 2) == 5);
|
||||
assert(f2(3, 2.5) == 5.5);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
template <class _Tp>
|
||||
struct is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
|
||||
int main () {
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
static_assert ( !is_transparent<std::plus<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::plus<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::plus<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::plus<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::minus<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::minus<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::minus<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::minus<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::multiplies<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::multiplies<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::multiplies<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::divides<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::divides<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::divides<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::divides<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::modulus<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::modulus<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::modulus<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::modulus<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::negate<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::negate<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::negate<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::negate<>>::value, "" );
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -25,4 +25,27 @@ int main()
|
|||
assert(f(0x58D3, 0xEA95) == 0x4891);
|
||||
assert(f(0x58D3, 0) == 0);
|
||||
assert(f(0xFFFF, 0x58D3) == 0x58D3);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::bit_and<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(0xEA95, 0xEA95) == 0xEA95);
|
||||
assert(f2(0xEA95L, 0xEA95) == 0xEA95);
|
||||
assert(f2(0xEA95, 0xEA95L) == 0xEA95);
|
||||
|
||||
assert(f2(0xEA95, 0x58D3) == 0x4891);
|
||||
assert(f2(0xEA95L, 0x58D3) == 0x4891);
|
||||
assert(f2(0xEA95, 0x58D3L) == 0x4891);
|
||||
|
||||
assert(f2(0x58D3, 0xEA95) == 0x4891);
|
||||
assert(f2(0x58D3L, 0xEA95) == 0x4891);
|
||||
assert(f2(0x58D3, 0xEA95L) == 0x4891);
|
||||
|
||||
assert(f2(0x58D3, 0) == 0);
|
||||
assert(f2(0x58D3L, 0) == 0);
|
||||
assert(f2(0x58D3, 0L) == 0);
|
||||
|
||||
assert(f2(0xFFFF, 0x58D3) == 0x58D3);
|
||||
assert(f2(0xFFFFL, 0x58D3) == 0x58D3);
|
||||
assert(f2(0xFFFF, 0x58D3L) == 0x58D3);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// bit_not
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::bit_not<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
|
||||
assert((f(0xEA95) & 0xFFFF ) == 0x156A);
|
||||
assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
|
||||
assert((f(0) & 0xFFFF ) == 0xFFFF);
|
||||
assert((f(0xFFFF) & 0xFFFF ) == 0);
|
||||
|
||||
typedef std::bit_not<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert((f2(0xEA95) & 0xFFFF ) == 0x156A);
|
||||
assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
|
||||
assert((f2(0x58D3) & 0xFFFF ) == 0xA72C);
|
||||
assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
|
||||
assert((f2(0) & 0xFFFF ) == 0xFFFF);
|
||||
assert((f2(0L) & 0xFFFF ) == 0xFFFF);
|
||||
assert((f2(0xFFFF) & 0xFFFF ) == 0);
|
||||
assert((f2(0xFFFFL) & 0xFFFF ) == 0);
|
||||
#endif
|
||||
}
|
|
@ -25,4 +25,27 @@ int main()
|
|||
assert(f(0x58D3, 0xEA95) == 0xFAD7);
|
||||
assert(f(0x58D3, 0) == 0x58D3);
|
||||
assert(f(0xFFFF, 0x58D3) == 0xFFFF);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::bit_or<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(0xEA95, 0xEA95) == 0xEA95);
|
||||
assert(f2(0xEA95L, 0xEA95) == 0xEA95);
|
||||
assert(f2(0xEA95, 0xEA95L) == 0xEA95);
|
||||
|
||||
assert(f2(0xEA95, 0x58D3) == 0xFAD7);
|
||||
assert(f2(0xEA95L, 0x58D3) == 0xFAD7);
|
||||
assert(f2(0xEA95, 0x58D3L) == 0xFAD7);
|
||||
|
||||
assert(f2(0x58D3, 0xEA95) == 0xFAD7);
|
||||
assert(f2(0x58D3L, 0xEA95) == 0xFAD7);
|
||||
assert(f2(0x58D3, 0xEA95L) == 0xFAD7);
|
||||
|
||||
assert(f2(0x58D3, 0) == 0x58D3);
|
||||
assert(f2(0x58D3L, 0) == 0x58D3);
|
||||
assert(f2(0x58D3, 0L) == 0x58D3);
|
||||
|
||||
assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
|
||||
assert(f2(0xFFFFL, 0x58D3) == 0xFFFF);
|
||||
assert(f2(0xFFFF, 0x58D3L) == 0xFFFF);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -25,4 +25,27 @@ int main()
|
|||
assert(f(0x58D3, 0xEA95) == 0xB246);
|
||||
assert(f(0x58D3, 0) == 0x58D3);
|
||||
assert(f(0xFFFF, 0x58D3) == 0xA72C);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::bit_xor<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f(0xEA95, 0xEA95) == 0);
|
||||
assert(f(0xEA95L, 0xEA95) == 0);
|
||||
assert(f(0xEA95, 0xEA95L) == 0);
|
||||
|
||||
assert(f(0xEA95, 0x58D3) == 0xB246);
|
||||
assert(f(0xEA95L, 0x58D3) == 0xB246);
|
||||
assert(f(0xEA95, 0x58D3L) == 0xB246);
|
||||
|
||||
assert(f(0x58D3, 0xEA95) == 0xB246);
|
||||
assert(f(0x58D3L, 0xEA95) == 0xB246);
|
||||
assert(f(0x58D3, 0xEA95L) == 0xB246);
|
||||
|
||||
assert(f(0x58D3, 0) == 0x58D3);
|
||||
assert(f(0x58D3L, 0) == 0x58D3);
|
||||
assert(f(0x58D3, 0L) == 0x58D3);
|
||||
|
||||
assert(f(0xFFFF, 0x58D3) == 0xA72C);
|
||||
assert(f(0xFFFFL, 0x58D3) == 0xA72C);
|
||||
assert(f(0xFFFF, 0x58D3L) == 0xA72C);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
template <class _Tp>
|
||||
struct is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
|
||||
int main () {
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
static_assert ( !is_transparent<std::bit_and<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::bit_and<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_and<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_and<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::bit_or<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::bit_or<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_or<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_or<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::bit_xor<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::bit_xor<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_xor<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_xor<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::bit_not<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::bit_not<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_not<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::bit_not<>>::value, "" );
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -22,4 +22,12 @@ int main()
|
|||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
assert(f(36, 36));
|
||||
assert(!f(36, 6));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::equal_to<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36, 36));
|
||||
assert(!f2(36, 6));
|
||||
assert(f2(36, 36.0));
|
||||
assert(f2(36.0, 36L));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,4 +23,15 @@ int main()
|
|||
assert(!f(36, 36));
|
||||
assert(f(36, 6));
|
||||
assert(!f(6, 36));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::greater<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(!f2(36, 36));
|
||||
assert(f2(36, 6));
|
||||
assert(!f2(6, 36));
|
||||
assert( f2(36, 6.0));
|
||||
assert( f2(36.0, 6));
|
||||
assert(!f2(6, 36.0));
|
||||
assert(!f2(6.0, 36));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,4 +23,15 @@ int main()
|
|||
assert(f(36, 36));
|
||||
assert(f(36, 6));
|
||||
assert(!f(6, 36));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::greater_equal<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(f2(36, 36));
|
||||
assert(f2(36, 6));
|
||||
assert(!f2(6, 36));
|
||||
assert( f2(36, 6.0));
|
||||
assert( f2(36.0, 6));
|
||||
assert(!f2(6, 36.0));
|
||||
assert(!f2(6.0, 36));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,4 +23,15 @@ int main()
|
|||
assert(!f(36, 36));
|
||||
assert(!f(36, 6));
|
||||
assert(f(6, 36));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::less<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(!f2(36, 36));
|
||||
assert(!f2(36, 6));
|
||||
assert( f2(6, 36));
|
||||
assert(!f2(36, 6.0));
|
||||
assert(!f2(36.0, 6));
|
||||
assert( f2(6, 36.0));
|
||||
assert( f2(6.0, 36));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,4 +23,15 @@ int main()
|
|||
assert(f(36, 36));
|
||||
assert(!f(36, 6));
|
||||
assert(f(6, 36));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::less_equal<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert( f2(36, 36));
|
||||
assert(!f2(36, 6));
|
||||
assert( f2(6, 36));
|
||||
assert(!f2(36, 6.0));
|
||||
assert(!f2(36.0, 6));
|
||||
assert( f2(6, 36.0));
|
||||
assert( f2(6.0, 36));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,4 +22,14 @@ int main()
|
|||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
assert(!f(36, 36));
|
||||
assert(f(36, 6));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::not_equal_to<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(!f2(36, 36));
|
||||
assert( f2(36, 6));
|
||||
assert( f2(36, 6.0));
|
||||
assert( f2(36.0, 6));
|
||||
assert(!f2(36.0, 36));
|
||||
assert(!f2(36, 36.0));
|
||||
#endif
|
||||
}
|
||||
|
|
52
external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/transparent.pass.cpp
vendored
Normal file
52
external/bsd/libc++/dist/libcxx/test/utilities/function.objects/comparisons/transparent.pass.cpp
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
template <class _Tp>
|
||||
struct is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
|
||||
int main () {
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
static_assert ( !is_transparent<std::less<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::less<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::less<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::less<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::less_equal<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::less_equal<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::less_equal<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::less_equal<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::equal_to<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::equal_to<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::equal_to<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::equal_to<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::not_equal_to<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::not_equal_to<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::not_equal_to<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::not_equal_to<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::greater<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::greater<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::greater<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::greater<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::greater_equal<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::greater_equal<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::greater_equal<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::greater_equal<>>::value, "" );
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -18,10 +18,10 @@
|
|||
#include <functional>
|
||||
|
||||
struct X{
|
||||
typedef std::function<void(X&)> callback_type;
|
||||
virtual ~X() {}
|
||||
typedef std::function<void(X&)> callback_type;
|
||||
virtual ~X() {}
|
||||
private:
|
||||
callback_type _cb;
|
||||
callback_type _cb;
|
||||
};
|
||||
|
||||
int main()
|
||||
|
|
|
@ -24,4 +24,19 @@ int main()
|
|||
assert(!f(36, 0));
|
||||
assert(!f(0, 36));
|
||||
assert(!f(0, 0));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::logical_and<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert( f2(36, 36));
|
||||
assert( f2(36, 36L));
|
||||
assert( f2(36L, 36));
|
||||
assert(!f2(36, 0));
|
||||
assert(!f2(0, 36));
|
||||
assert( f2(36, 36L));
|
||||
assert(!f2(36, 0L));
|
||||
assert(!f2(0, 36L));
|
||||
assert( f2(36L, 36));
|
||||
assert(!f2(36L, 0));
|
||||
assert(!f2(0L, 36));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,4 +22,12 @@ int main()
|
|||
static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
|
||||
assert(!f(36));
|
||||
assert(f(0));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::logical_not<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert(!f2(36));
|
||||
assert( f2(0));
|
||||
assert(!f2(36L));
|
||||
assert( f2(0L));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -24,4 +24,18 @@ int main()
|
|||
assert(f(36, 0));
|
||||
assert(f(0, 36));
|
||||
assert(!f(0, 0));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::logical_or<> F2;
|
||||
const F2 f2 = F2();
|
||||
assert( f2(36, 36));
|
||||
assert( f2(36, 36L));
|
||||
assert( f2(36L, 36));
|
||||
assert( f2(36, 0));
|
||||
assert( f2(0, 36));
|
||||
assert( f2(36, 0L));
|
||||
assert( f2(0, 36L));
|
||||
assert(!f2(0, 0));
|
||||
assert(!f2(0, 0L));
|
||||
assert(!f2(0L, 0));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
template <class _Tp>
|
||||
struct is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
|
||||
int main () {
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
static_assert ( !is_transparent<std::logical_and<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::logical_and<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::logical_and<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::logical_and<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::logical_or<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::logical_or<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::logical_or<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::logical_or<>>::value, "" );
|
||||
|
||||
static_assert ( !is_transparent<std::logical_not<int>>::value, "" );
|
||||
static_assert ( !is_transparent<std::logical_not<std::string>>::value, "" );
|
||||
static_assert ( is_transparent<std::logical_not<void>>::value, "" );
|
||||
static_assert ( is_transparent<std::logical_not<>>::value, "" );
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -26,6 +26,11 @@ int main()
|
|||
assert(_5() == 5);
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
static_assert ( _5{}() == 5, "" );
|
||||
static_assert ( std::true_type{}(), "" );
|
||||
#endif
|
||||
|
||||
static_assert(std::false_type::value == false, "");
|
||||
static_assert((std::is_same<std::false_type::value_type, bool>::value), "");
|
||||
static_assert((std::is_same<std::false_type::type, std::false_type>::value), "");
|
||||
|
|
|
@ -134,8 +134,8 @@ int main()
|
|||
test_is_not_convertible<char, Array> ();
|
||||
test_is_not_convertible<char, Array&> ();
|
||||
|
||||
test_is_convertible<char, char> ();
|
||||
|
||||
test_is_convertible<char, char> ();
|
||||
|
||||
static_assert((!std::is_convertible<char, char&>::value), "");
|
||||
static_assert(( std::is_convertible<char, const char&>::value), "");
|
||||
static_assert((!std::is_convertible<const char, char&>::value), "");
|
||||
|
@ -151,8 +151,8 @@ int main()
|
|||
test_is_not_convertible<char&, Array> ();
|
||||
test_is_not_convertible<char&, Array&> ();
|
||||
|
||||
test_is_convertible<char&, char> ();
|
||||
|
||||
test_is_convertible<char&, char> ();
|
||||
|
||||
static_assert(( std::is_convertible<char&, char&>::value), "");
|
||||
static_assert(( std::is_convertible<char&, const char&>::value), "");
|
||||
static_assert((!std::is_convertible<const char&, char&>::value), "");
|
||||
|
@ -168,9 +168,9 @@ int main()
|
|||
test_is_not_convertible<char*, Array> ();
|
||||
test_is_not_convertible<char*, Array&> ();
|
||||
|
||||
test_is_not_convertible<char*, char> ();
|
||||
test_is_not_convertible<char*, char&> ();
|
||||
|
||||
test_is_not_convertible<char*, char> ();
|
||||
test_is_not_convertible<char*, char&> ();
|
||||
|
||||
static_assert(( std::is_convertible<char*, char*>::value), "");
|
||||
static_assert(( std::is_convertible<char*, const char*>::value), "");
|
||||
static_assert((!std::is_convertible<const char*, char*>::value), "");
|
||||
|
|
|
@ -43,8 +43,8 @@ int main()
|
|||
test_make_signed< unsigned long, long >();
|
||||
test_make_signed< long long, signed long long >();
|
||||
test_make_signed< unsigned long long, signed long long >();
|
||||
test_make_signed< wchar_t, int >();
|
||||
test_make_signed< const wchar_t, const int >();
|
||||
test_make_signed< wchar_t, std::conditional<sizeof(wchar_t) == 4, int, short>::type >();
|
||||
test_make_signed< const wchar_t, std::conditional<sizeof(wchar_t) == 4, const int, const short>::type >();
|
||||
test_make_signed< const Enum, const int >();
|
||||
test_make_signed< BigEnum, std::conditional<sizeof(long) == 4, long long, long>::type >();
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ int main()
|
|||
test_make_unsigned<unsigned long, unsigned long> ();
|
||||
test_make_unsigned<long long, unsigned long long> ();
|
||||
test_make_unsigned<unsigned long long, unsigned long long> ();
|
||||
test_make_unsigned<wchar_t, unsigned int> ();
|
||||
test_make_unsigned<const wchar_t, const unsigned int> ();
|
||||
test_make_unsigned<wchar_t, std::conditional<sizeof(wchar_t) == 4, unsigned int, unsigned short>::type> ();
|
||||
test_make_unsigned<const wchar_t, std::conditional<sizeof(wchar_t) == 4, const unsigned int, const unsigned short>::type> ();
|
||||
test_make_unsigned<const Enum, const unsigned int> ();
|
||||
test_make_unsigned<BigEnum,
|
||||
std::conditional<sizeof(long) == 4, unsigned long long, unsigned long>::type> ();
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// alignment_of
|
||||
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
|
||||
template <class T, unsigned A>
|
||||
void test_alignment_of()
|
||||
|
@ -32,8 +33,8 @@ int main()
|
|||
{
|
||||
test_alignment_of<int&, 4>();
|
||||
test_alignment_of<Class, 1>();
|
||||
test_alignment_of<int*, sizeof(long) == 4 ? 4 : 8>();
|
||||
test_alignment_of<const int*, sizeof(long) == 4 ? 4 : 8>();
|
||||
test_alignment_of<int*, sizeof(intptr_t)>();
|
||||
test_alignment_of<const int*, sizeof(intptr_t)>();
|
||||
test_alignment_of<char[3], 1>();
|
||||
test_alignment_of<int, 4>();
|
||||
test_alignment_of<double, 8>();
|
||||
|
|
|
@ -69,7 +69,9 @@ int main()
|
|||
test_is_destructible<const int*>();
|
||||
test_is_destructible<char[3]>();
|
||||
test_is_destructible<bit_zero>();
|
||||
test_is_destructible<int[3]>();
|
||||
|
||||
test_is_not_destructible<int[]>();
|
||||
test_is_not_destructible<void>();
|
||||
test_is_not_destructible<Abstract>();
|
||||
#if __has_feature(cxx_access_control_sfinae)
|
||||
|
|
|
@ -27,7 +27,7 @@ test()
|
|||
D d;
|
||||
assert(d.count() == typename D::rep());
|
||||
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||
constexpr D d2;
|
||||
constexpr D d2 = D();
|
||||
static_assert(d2.count() == typename D::rep(), "");
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <chrono>
|
||||
|
||||
#include <chrono>
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
// Make sure the types are right
|
||||
static_assert ( std::is_same<decltype( 3h ), std::chrono::hours>::value, "" );
|
||||
static_assert ( std::is_same<decltype( 3min ), std::chrono::minutes>::value, "" );
|
||||
static_assert ( std::is_same<decltype( 3s ), std::chrono::seconds>::value, "" );
|
||||
static_assert ( std::is_same<decltype( 3ms ), std::chrono::milliseconds>::value, "" );
|
||||
static_assert ( std::is_same<decltype( 3us ), std::chrono::microseconds>::value, "" );
|
||||
static_assert ( std::is_same<decltype( 3ns ), std::chrono::nanoseconds>::value, "" );
|
||||
|
||||
std::chrono::hours h = 4h;
|
||||
assert ( h == std::chrono::hours(4));
|
||||
auto h2 = 4.0h;
|
||||
assert ( h == h2 );
|
||||
|
||||
std::chrono::minutes min = 36min;
|
||||
assert ( min == std::chrono::minutes(36));
|
||||
auto min2 = 36.0min;
|
||||
assert ( min == min2 );
|
||||
|
||||
std::chrono::seconds s = 24s;
|
||||
assert ( s == std::chrono::seconds(24));
|
||||
auto s2 = 24.0s;
|
||||
assert ( s == s2 );
|
||||
|
||||
std::chrono::milliseconds ms = 247ms;
|
||||
assert ( ms == std::chrono::milliseconds(247));
|
||||
auto ms2 = 247.0ms;
|
||||
assert ( ms == ms2 );
|
||||
|
||||
std::chrono::microseconds us = 867us;
|
||||
assert ( us == std::chrono::microseconds(867));
|
||||
auto us2 = 867.0us;
|
||||
assert ( us == us2 );
|
||||
|
||||
std::chrono::nanoseconds ns = 645ns;
|
||||
assert ( ns == std::chrono::nanoseconds(645));
|
||||
auto ns2 = 645.ns;
|
||||
assert ( ns == ns2 );
|
||||
#endif
|
||||
}
|
|
@ -26,11 +26,27 @@ test(const FromDuration& df, const ToDuration& d)
|
|||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
|
||||
typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
|
||||
{
|
||||
FromTimePoint f(df);
|
||||
ToTimePoint t(d);
|
||||
typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
|
||||
static_assert((std::is_same<R, ToTimePoint>::value), "");
|
||||
assert(std::chrono::time_point_cast<ToDuration>(f) == t);
|
||||
}
|
||||
}
|
||||
|
||||
template<class FromDuration, long long From, class ToDuration, long long To>
|
||||
void test_constexpr ()
|
||||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
|
||||
typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
|
||||
{
|
||||
constexpr FromTimePoint f{FromDuration{From}};
|
||||
constexpr ToTimePoint t{ToDuration{To}};
|
||||
static_assert(std::chrono::time_point_cast<ToDuration>(f) == t, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -45,4 +61,16 @@ int main()
|
|||
std::chrono::duration<double, std::ratio<3600> >(7265./3600));
|
||||
test(std::chrono::duration<int, std::ratio<2, 3> >(9),
|
||||
std::chrono::duration<int, std::ratio<3, 5> >(10));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::hours, 2> ();
|
||||
test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::minutes,121> ();
|
||||
test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::seconds,7265> ();
|
||||
test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::milliseconds,7265000> ();
|
||||
test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::microseconds,7265000000LL> ();
|
||||
test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::nanoseconds,7265000000000LL> ();
|
||||
typedef std::chrono::duration<int, std::ratio<3, 5>> T1;
|
||||
test_constexpr<std::chrono::duration<int, std::ratio<2, 3>>, 9, T1, 10> ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -54,4 +54,31 @@ int main()
|
|||
assert(!(t1 == t2));
|
||||
assert( (t1 != t2));
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T1 t2(Duration1(3));
|
||||
static_assert( (t1 == t2), "");
|
||||
static_assert(!(t1 != t2), "");
|
||||
}
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T1 t2(Duration1(4));
|
||||
static_assert(!(t1 == t2), "");
|
||||
static_assert( (t1 != t2), "");
|
||||
}
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T2 t2(Duration2(3000));
|
||||
static_assert( (t1 == t2), "");
|
||||
static_assert(!(t1 != t2), "");
|
||||
}
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T2 t2(Duration2(3001));
|
||||
static_assert(!(t1 == t2), "");
|
||||
static_assert( (t1 != t2), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -70,4 +70,39 @@ int main()
|
|||
assert( (t1 <= t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T1 t2(Duration1(3));
|
||||
static_assert(!(t1 < t2), "");
|
||||
static_assert(!(t1 > t2), "");
|
||||
static_assert( (t1 <= t2), "");
|
||||
static_assert( (t1 >= t2), "");
|
||||
}
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T1 t2(Duration1(4));
|
||||
static_assert( (t1 < t2), "");
|
||||
static_assert(!(t1 > t2), "");
|
||||
static_assert( (t1 <= t2), "");
|
||||
static_assert(!(t1 >= t2), "");
|
||||
}
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T2 t2(Duration2(3000));
|
||||
static_assert(!(t1 < t2), "");
|
||||
static_assert(!(t1 > t2), "");
|
||||
static_assert( (t1 <= t2), "");
|
||||
static_assert( (t1 >= t2), "");
|
||||
}
|
||||
{
|
||||
constexpr T1 t1(Duration1(3));
|
||||
constexpr T2 t2(Duration2(3001));
|
||||
static_assert( (t1 < t2), "");
|
||||
static_assert(!(t1 > t2), "");
|
||||
static_assert( (t1 <= t2), "");
|
||||
static_assert(!(t1 >= t2), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -27,4 +27,11 @@ int main()
|
|||
std::chrono::time_point<Clock, Duration1> t1 = t2;
|
||||
assert(t1.time_since_epoch() == Duration1(3000));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
|
||||
constexpr std::chrono::time_point<Clock, Duration1> t1 = t2;
|
||||
static_assert(t1.time_since_epoch() == Duration1(3000), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,6 +22,14 @@ int main()
|
|||
{
|
||||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::duration<Rep, std::milli> Duration;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration> t;
|
||||
assert(t.time_since_epoch() == Duration::zero());
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration> t;
|
||||
static_assert(t.time_since_epoch() == Duration::zero(), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -28,4 +28,14 @@ int main()
|
|||
std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
|
||||
assert(t.time_since_epoch() == Duration(3000));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration> t(Duration(3));
|
||||
static_assert(t.time_since_epoch() == Duration(3), "");
|
||||
}
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
|
||||
static_assert(t.time_since_epoch() == Duration(3000), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -27,9 +27,20 @@ int main()
|
|||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
|
||||
assert(t2.time_since_epoch() == Duration2(3005));
|
||||
t2 = Duration2(6) + t1;
|
||||
assert(t2.time_since_epoch() == Duration2(3006));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
|
||||
static_assert(t2.time_since_epoch() == Duration2(3005), "");
|
||||
constexpr std::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1;
|
||||
static_assert(t3.time_since_epoch() == Duration2(3006), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,7 +23,16 @@ int main()
|
|||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
|
||||
assert(t2.time_since_epoch() == Duration2(2995));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
|
||||
static_assert(t2.time_since_epoch() == Duration2(2995), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,7 +23,16 @@ int main()
|
|||
typedef std::chrono::system_clock Clock;
|
||||
typedef std::chrono::milliseconds Duration1;
|
||||
typedef std::chrono::microseconds Duration2;
|
||||
{
|
||||
std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
|
||||
assert((t1 - t2) == Duration2(2995));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
|
||||
constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
|
||||
static_assert((t1 - t2) == Duration2(2995), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -19,6 +19,17 @@
|
|||
|
||||
#include "../MoveOnly.h"
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
struct Empty {};
|
||||
struct A
|
||||
{
|
||||
int id_;
|
||||
explicit constexpr A(int i) : id_(i) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -52,4 +63,13 @@ int main()
|
|||
assert(std::get<1>(t) == MoveOnly());
|
||||
assert(std::get<2>(t) == MoveOnly());
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::tuple<Empty> t0{Empty()};
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<A, A> t(3, 2);
|
||||
static_assert(std::get<0>(t).id_ == 3, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,11 +23,28 @@ int main()
|
|||
std::tuple<int> t(2);
|
||||
assert(std::get<0>(t) == 2);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::tuple<int> t(2);
|
||||
static_assert(std::get<0>(t) == 2, "");
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<int> t;
|
||||
static_assert(std::get<0>(t) == 0, "");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
std::tuple<int, char*> t(2, 0);
|
||||
assert(std::get<0>(t) == 2);
|
||||
assert(std::get<1>(t) == nullptr);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::tuple<int, char*> t(2, nullptr);
|
||||
static_assert(std::get<0>(t) == 2, "");
|
||||
static_assert(std::get<1>(t) == nullptr, "");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
std::tuple<int, char*> t(2, nullptr);
|
||||
assert(std::get<0>(t) == 2);
|
||||
|
|
|
@ -27,4 +27,16 @@ int main()
|
|||
assert(std::get<0>(t1) == 2);
|
||||
assert(std::get<1>(t1) == short('a'));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<double, char> P0;
|
||||
typedef std::tuple<int, short> T1;
|
||||
constexpr P0 p0(2.5, 'a');
|
||||
constexpr T1 t1 = p0;
|
||||
static_assert(std::get<0>(t1) != std::get<0>(p0), "");
|
||||
static_assert(std::get<1>(t1) == std::get<1>(p0), "");
|
||||
static_assert(std::get<0>(t1) == 2, "");
|
||||
static_assert(std::get<1>(t1) == short('a'), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -30,6 +30,26 @@ struct D
|
|||
explicit D(int i) : B(i) {}
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
struct A
|
||||
{
|
||||
int id_;
|
||||
|
||||
constexpr A(int i) : id_(i) {}
|
||||
friend constexpr bool operator==(const A& x, const A& y) {return x.id_ == y.id_;}
|
||||
};
|
||||
|
||||
struct C
|
||||
{
|
||||
int id_;
|
||||
|
||||
constexpr explicit C(int i) : id_(i) {}
|
||||
friend constexpr bool operator==(const C& x, const C& y) {return x.id_ == y.id_;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -39,6 +59,22 @@ int main()
|
|||
T1 t1 = t0;
|
||||
assert(std::get<0>(t1) == 2);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::tuple<double> T0;
|
||||
typedef std::tuple<A> T1;
|
||||
constexpr T0 t0(2.5);
|
||||
constexpr T1 t1 = t0;
|
||||
static_assert(std::get<0>(t1) == 2, "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int> T0;
|
||||
typedef std::tuple<C> T1;
|
||||
constexpr T0 t0(2);
|
||||
constexpr T1 t1{t0};
|
||||
static_assert(std::get<0>(t1) == C(2), "");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
typedef std::tuple<double, char> T0;
|
||||
typedef std::tuple<int, int> T1;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
struct Empty {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -45,4 +47,17 @@ int main()
|
|||
assert(std::get<1>(t) == 'a');
|
||||
assert(std::get<2>(t) == "some text");
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
constexpr T t0(2);
|
||||
constexpr T t = t0;
|
||||
static_assert(std::get<0>(t) == 2, "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<Empty> T;
|
||||
constexpr T t0;
|
||||
constexpr T t = t0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -38,4 +38,13 @@ int main()
|
|||
assert(i == 0);
|
||||
assert(j == 0);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr auto t1 = std::make_tuple(0, 1, 3.14);
|
||||
constexpr int i1 = std::get<1>(t1);
|
||||
constexpr double d1 = std::get<2>(t1);
|
||||
static_assert (i1 == 1, "" );
|
||||
static_assert (d1 == 3.14, "" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -36,12 +36,38 @@ int main()
|
|||
{
|
||||
std::tuple<> t = std::tuple_cat(std::array<int, 0>());
|
||||
}
|
||||
|
||||
{
|
||||
std::tuple<int> t1(1);
|
||||
std::tuple<int> t = std::tuple_cat(t1);
|
||||
assert(std::get<0>(t) == 1);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
constexpr std::tuple<> t = std::tuple_cat();
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<> t1;
|
||||
constexpr std::tuple<> t2 = std::tuple_cat(t1);
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<> t = std::tuple_cat(std::tuple<>());
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<> t = std::tuple_cat(std::array<int, 0>());
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<int> t1(1);
|
||||
constexpr std::tuple<int> t = std::tuple_cat(t1);
|
||||
static_assert(std::get<0>(t) == 1, "");
|
||||
}
|
||||
{
|
||||
constexpr std::tuple<int> t1(1);
|
||||
constexpr std::tuple<int, int> t = std::tuple_cat(t1, t1);
|
||||
static_assert(std::get<0>(t) == 1, "");
|
||||
static_assert(std::get<1>(t) == 1, "");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
std::tuple<int, MoveOnly> t =
|
||||
std::tuple_cat(std::tuple<int, MoveOnly>(1, 2));
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
struct Empty {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -32,6 +34,19 @@ int main()
|
|||
assert(std::get<0>(t) == "high");
|
||||
assert(std::get<1>(t) == 5);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::tuple<double, int> T;
|
||||
constexpr T t(2.718, 5);
|
||||
static_assert(std::get<0>(t) == 2.718, "");
|
||||
static_assert(std::get<1>(t) == 5, "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<Empty> T;
|
||||
constexpr T t{Empty()};
|
||||
constexpr Empty e = std::get<0>(t);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
typedef std::tuple<double&, std::string, int> T;
|
||||
double d = 1.5;
|
||||
|
|
|
@ -19,6 +19,20 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
|
||||
struct Empty {};
|
||||
|
||||
struct S {
|
||||
std::tuple<int, Empty> a;
|
||||
int k;
|
||||
Empty e;
|
||||
constexpr S() : a{1,Empty{}}, k(std::get<0>(a)), e(std::get<1>(a)) {}
|
||||
};
|
||||
|
||||
constexpr std::tuple<int, int> getP () { return { 3, 4 }; }
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -53,4 +67,15 @@ int main()
|
|||
assert(std::get<2>(t) == 4);
|
||||
assert(d == 2.5);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{ // get on an rvalue tuple
|
||||
static_assert ( std::get<0> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 0, "" );
|
||||
static_assert ( std::get<1> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 1, "" );
|
||||
static_assert ( std::get<2> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 2, "" );
|
||||
static_assert ( std::get<3> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 3, "" );
|
||||
static_assert(S().k == 1, "");
|
||||
static_assert(std::get<1>(getP()) == 4, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
{
|
||||
auto t1 = std::tuple<int, std::string, cf> { 42, "Hi", { 1,2 }};
|
||||
assert ( std::get<int>(t1) == 42 ); // find at the beginning
|
||||
assert ( std::get<std::string>(t1) == "Hi" ); // find in the middle
|
||||
assert ( std::get<cf>(t1).real() == 1 ); // find at the end
|
||||
assert ( std::get<cf>(t1).imag() == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto t2 = std::tuple<int, std::string, int, cf> { 42, "Hi", 23, { 1,2 }};
|
||||
// get<int> would fail!
|
||||
assert ( std::get<std::string>(t2) == "Hi" );
|
||||
assert (( std::get<cf>(t2) == cf{ 1,2 } ));
|
||||
}
|
||||
|
||||
{
|
||||
constexpr std::tuple<int, const int, double, double> p5 { 1, 2, 3.4, 5.6 };
|
||||
static_assert ( std::get<int>(p5) == 1, "" );
|
||||
static_assert ( std::get<const int>(p5) == 2, "" );
|
||||
}
|
||||
|
||||
{
|
||||
const std::tuple<int, const int, double, double> p5 { 1, 2, 3.4, 5.6 };
|
||||
const int &i1 = std::get<int>(p5);
|
||||
const int &i2 = std::get<const int>(p5);
|
||||
assert ( i1 == 1 );
|
||||
assert ( i2 == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::unique_ptr<int> upint;
|
||||
std::tuple<upint> t(upint(new int(4)));
|
||||
upint p = std::get<upint>(std::move(t)); // get rvalue
|
||||
assert(*p == 4);
|
||||
assert(std::get<0>(t) == nullptr); // has been moved from
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
auto t1 = std::make_tuple<int, std::string> ( 42, "Hi" );
|
||||
assert ( std::get<cf>(t1) == cf {1,2} ); // no such type
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
auto t1 = std::make_tuple<int, int, std::string, cf> ( 42, 21, "Hi", { 1,2 } );
|
||||
assert ( std::get<int>(t1) == 42 ); // two ints here
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
auto t1 = std::make_tuple<double, int, std::string, cf, int> ( 42, 21, "Hi", { 1,2 } );
|
||||
assert ( std::get<int>(t1) == 42 ); // two ints here (one at the end)
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::unique_ptr<int> upint;
|
||||
std::tuple<upint> t(upint(new int(4)));
|
||||
upint p = std::get<upint>(t);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -141,4 +141,14 @@ int main()
|
|||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
constexpr T1 t1(1, 2, 3);
|
||||
constexpr T2 t2(1.1, 3, 2);
|
||||
static_assert(!(t1 == t2), "");
|
||||
static_assert(t1 != t2, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -193,4 +193,16 @@ int main()
|
|||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
constexpr T1 t1(1, 2, 3);
|
||||
constexpr T2 t2(1, 2, 4);
|
||||
static_assert( (t1 < t2), "");
|
||||
static_assert( (t1 <= t2), "");
|
||||
static_assert(!(t1 > t2), "");
|
||||
static_assert(!(t1 >= t2), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
58
external/bsd/libc++/dist/libcxx/test/utilities/utility/exchange/exchange.pass.cpp
vendored
Normal file
58
external/bsd/libc++/dist/libcxx/test/utilities/utility/exchange/exchange.pass.cpp
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// utilities
|
||||
|
||||
// exchange
|
||||
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
int v = 12;
|
||||
assert ( std::exchange ( v, 23 ) == 12 );
|
||||
assert ( v == 23 );
|
||||
assert ( std::exchange ( v, 67.2 ) == 23 );
|
||||
assert ( v == 67 );
|
||||
|
||||
assert ((std::exchange<int, float> ( v, {} )) == 67 );
|
||||
assert ( v == 0 );
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
bool b = false;
|
||||
assert ( !std::exchange ( b, true ));
|
||||
assert ( b );
|
||||
}
|
||||
|
||||
{
|
||||
const std::string s1 ( "Hi Mom!" );
|
||||
const std::string s2 ( "Yo Dad!" );
|
||||
std::string s3 = s1; // Mom
|
||||
assert ( std::exchange ( s3, s2 ) == s1 );
|
||||
assert ( s3 == s2 );
|
||||
assert ( std::exchange ( s3, "Hi Mom!" ) == s2 );
|
||||
assert ( s3 == s1 );
|
||||
|
||||
s3 = s2; // Dad
|
||||
assert ( std::exchange ( s3, {} ) == s2 );
|
||||
assert ( s3.size () == 0 );
|
||||
|
||||
s3 = s2; // Dad
|
||||
assert ( std::exchange ( s3, "" ) == s2 );
|
||||
assert ( s3.size () == 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
|
@ -70,4 +70,11 @@ int main()
|
|||
static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
|
||||
static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr int i1 = std::move(23);
|
||||
static_assert(i1 == 23, "" );
|
||||
constexpr int i2 = std::forward<int>(42);
|
||||
static_assert(i2 == 42, "" );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -60,4 +60,10 @@ int main()
|
|||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
constexpr int i1 = 23;
|
||||
constexpr int i2 = std::move_if_noexcept(i1);
|
||||
static_assert(i2 == 23, "" );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -26,4 +26,13 @@ int main()
|
|||
assert(std::get<0>(p) == 3);
|
||||
assert(std::get<1>(p) == 4);
|
||||
}
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
{
|
||||
typedef std::pair<int, short> P;
|
||||
constexpr P p1(3, 4);
|
||||
static_assert(std::get<0>(p1) == 3, "");
|
||||
static_assert(std::get<1>(p1) == 4, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,6 +18,16 @@
|
|||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
struct S {
|
||||
std::pair<int, int> a;
|
||||
int k;
|
||||
constexpr S() : a{1,2}, k(std::get<0>(a)) {}
|
||||
};
|
||||
|
||||
constexpr std::pair<int, int> getP () { return { 3, 4 }; }
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -30,4 +40,12 @@ int main()
|
|||
assert(std::get<0>(p) == 5);
|
||||
assert(std::get<1>(p) == 6);
|
||||
}
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
{
|
||||
static_assert(S().k == 1, "");
|
||||
static_assert(std::get<1>(getP()) == 4, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
44
external/bsd/libc++/dist/libcxx/test/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
vendored
Normal file
44
external/bsd/libc++/dist/libcxx/test/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
{
|
||||
auto t1 = std::make_pair<int, cf> ( 42, { 1,2 } );
|
||||
assert ( std::get<int>(t1) == 42 );
|
||||
assert ( std::get<cf>(t1).real() == 1 );
|
||||
assert ( std::get<cf>(t1).imag() == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
const std::pair<int, const int> p1 { 1, 2 };
|
||||
const int &i1 = std::get<int>(p1);
|
||||
const int &i2 = std::get<const int>(p1);
|
||||
assert ( i1 == 1 );
|
||||
assert ( i2 == 2 );
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::unique_ptr<int> upint;
|
||||
std::pair<upint, int> t(upint(new int(4)), 42);
|
||||
upint p = std::get<0>(std::move(t)); // get rvalue
|
||||
assert(*p == 4);
|
||||
assert(std::get<0>(t) == nullptr); // has been moved from
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <utility>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
auto t1 = std::make_pair<int, double> ( 42, 3.4 );
|
||||
assert ( std::get<cf>(t1) == cf {1,2} ); // no such type
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <utility>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::complex<float> cf;
|
||||
auto t1 = std::make_pair<int, int> ( 42, 43 );
|
||||
assert ( std::get<int>(t1) == 42 ); // two ints
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <utility>
|
||||
#include <complex>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::unique_ptr<int> upint;
|
||||
std::pair<upint, int> t(upint(new int(4)), 23);
|
||||
upint p = std::get<upint>(t);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
|
@ -22,9 +22,20 @@ class A
|
|||
public:
|
||||
A(int data) : data_(data) {}
|
||||
|
||||
bool operator==(const A& a) {return data_ == a.data_;}
|
||||
bool operator==(const A& a) const {return data_ == a.data_;}
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
class AC
|
||||
{
|
||||
int data_;
|
||||
public:
|
||||
constexpr AC(int data) : data_(data) {}
|
||||
|
||||
constexpr bool operator==(const AC& a) const {return data_ == a.data_;}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -39,4 +50,19 @@ int main()
|
|||
assert(p.first == A(1));
|
||||
assert(p.second == 2);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<float, short*> P;
|
||||
constexpr P p(3.5f, 0);
|
||||
static_assert(p.first == 3.5f, "");
|
||||
static_assert(p.second == nullptr, "");
|
||||
}
|
||||
{
|
||||
typedef std::pair<AC, int> P;
|
||||
constexpr P p(1, 2);
|
||||
static_assert(p.first == AC(1), "");
|
||||
static_assert(p.second == 2, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -26,4 +26,15 @@ int main()
|
|||
assert(p2.first == 3);
|
||||
assert(p2.second == 4);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<int, short> P1;
|
||||
typedef std::pair<double, long> P2;
|
||||
constexpr P1 p1(3, 4);
|
||||
constexpr P2 p2 = p1;
|
||||
static_assert(p2.first == 3, "");
|
||||
static_assert(p2.second == 4, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -25,4 +25,14 @@ int main()
|
|||
assert(p2.first == 3);
|
||||
assert(p2.second == 4);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<int, short> P1;
|
||||
constexpr P1 p1(3, 4);
|
||||
constexpr P1 p2 = p1;
|
||||
static_assert(p2.first == 3, "");
|
||||
static_assert(p2.second == 4, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,8 +18,19 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<float, short*> P;
|
||||
P p;
|
||||
assert(p.first == 0.0f);
|
||||
assert(p.second == nullptr);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<float, short*> P;
|
||||
constexpr P p;
|
||||
static_assert(p.first == 0.0f, "");
|
||||
static_assert(p.second == nullptr, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -78,4 +78,18 @@ int main()
|
|||
assert( (p1 > p2));
|
||||
assert( (p1 >= p2));
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<int, short> P;
|
||||
constexpr P p1(3, 4);
|
||||
constexpr P p2(3, 2);
|
||||
static_assert(!(p1 == p2), "");
|
||||
static_assert( (p1 != p2), "");
|
||||
static_assert(!(p1 < p2), "");
|
||||
static_assert(!(p1 <= p2), "");
|
||||
static_assert( (p1 > p2), "");
|
||||
static_assert( (p1 >= p2), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ int main()
|
|||
assert(p1.first == 3);
|
||||
assert(p1.second == 4);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::pair<std::unique_ptr<int>, short> P1;
|
||||
|
@ -37,4 +38,14 @@ int main()
|
|||
assert(p1.second == 4);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
{
|
||||
typedef std::pair<int, short> P1;
|
||||
constexpr P1 p1 = std::make_pair(3, 4);
|
||||
static_assert(p1.first == 3, "");
|
||||
static_assert(p1.second == 4, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue