summaryrefslogtreecommitdiff
path: root/test/std/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities')
-rw-r--r--test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp72
-rw-r--r--test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp72
-rw-r--r--test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp18
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp39
-rw-r--r--test/std/utilities/function.objects/func.invoke/invoke.pass.cpp1
-rw-r--r--test/std/utilities/function.objects/func.memfn/member_function.pass.cpp3
-rw-r--r--test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp318
-rw-r--r--test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp164
-rw-r--r--test/std/utilities/function.objects/func.require/bullet_5.pass.cpp327
-rw-r--r--test/std/utilities/function.objects/func.require/invoke_helpers.h317
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp6
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp247
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp14
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp382
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp58
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp60
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp67
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp2
-rw-r--r--test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp2
-rw-r--r--test/std/utilities/function.objects/unord.hash/integral.pass.cpp40
-rw-r--r--test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp18
-rw-r--r--test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp6
-rw-r--r--test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp (renamed from test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp)18
-rw-r--r--test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp (renamed from test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp)14
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp4
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp25
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp4
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp15
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp15
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp14
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp14
-rw-r--r--test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp27
-rw-r--r--test/std/utilities/memory/unique.ptr/deleter.h230
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp25
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp22
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp25
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp27
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp43
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp48
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp89
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp44
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp40
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp2
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp16
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp86
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp84
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp140
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp142
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp143
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp171
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp163
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp95
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp123
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp99
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp43
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp66
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp39
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp1
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp40
-rw-r--r--test/std/utilities/meta/meta.logical/conjunction.pass.cpp66
-rw-r--r--test/std/utilities/meta/meta.logical/disjunction.pass.cpp66
-rw-r--r--test/std/utilities/meta/meta.logical/negation.pass.cpp39
-rw-r--r--test/std/utilities/meta/meta.rel/is_base_of.pass.cpp8
-rw-r--r--test/std/utilities/meta/meta.rel/is_convertible.pass.cpp14
-rw-r--r--test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp8
-rw-r--r--test/std/utilities/meta/meta.rel/is_same.pass.cpp18
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp44
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp58
-rw-r--r--test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp36
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp8
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp14
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp8
-rw-r--r--test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp9
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp93
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp98
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp93
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp101
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp98
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp104
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp95
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp97
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp98
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp95
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp94
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp95
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp93
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp92
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp1
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp104
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp95
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp112
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp102
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp101
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp101
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp111
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp12
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp20
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp27
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp77
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp11
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp16
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp11
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp70
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp11
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp16
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp9
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp47
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp7
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp13
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp7
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp27
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp27
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp27
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp39
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp27
-rw-r--r--test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp27
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp3
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp3
-rw-r--r--test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp1
-rw-r--r--test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp1
-rw-r--r--test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp1
-rw-r--r--test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp1
-rw-r--r--test/std/utilities/template.bitset/bitset.members/test.pass.cpp1
-rw-r--r--test/std/utilities/time/date.time/ctime.pass.cpp (renamed from test/std/utilities/date.time/tested_elsewhere.pass.cpp)2
-rw-r--r--test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp27
-rw-r--r--test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp50
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp (renamed from test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp)20
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp51
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp50
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp26
-rw-r--r--test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp50
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp26
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp69
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp26
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp68
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/round.fail.cpp26
-rw-r--r--test/std/utilities/time/time.point/time.point.cast/round.pass.cpp68
-rw-r--r--test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp4
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp34
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp80
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp45
-rw-r--r--test/std/utilities/utility/as_const/as_const.fail.cpp (renamed from test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp)16
-rw-r--r--test/std/utilities/utility/as_const/as_const.pass.cpp46
-rw-r--r--test/std/utilities/utility/declval/declval.pass.cpp6
-rw-r--r--test/std/utilities/utility/forward/move_if_noexcept.pass.cpp15
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp66
-rw-r--r--test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp50
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp164
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp17
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp19
209 files changed, 7332 insertions, 2656 deletions
diff --git a/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp
new file mode 100644
index 000000000000..72f0e867b1d2
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor& other);
+
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a1(A1<int>(3));
+ A aN;
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ aN = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(aN == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a1(A1<int>(4), A2<int>(5));
+ A aN;
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ aN = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(aN == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A aN;
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A3<int>::copy_called = false;
+ A3<int>::move_called = false;
+ aN = a1;
+ assert(A1<int>::copy_called == true);
+ assert(A1<int>::move_called == false);
+ assert(A2<int>::copy_called == true);
+ assert(A2<int>::move_called == false);
+ assert(A3<int>::copy_called == true);
+ assert(A3<int>::move_called == false);
+ assert(aN == a1);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp
new file mode 100644
index 000000000000..0dc479c246c9
--- /dev/null
+++ b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&& other);
+
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>> A;
+ A a1(A1<int>(3));
+ A aN;
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ aN = std::move(a1);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(aN == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+ A a1(A1<int>(4), A2<int>(5));
+ A aN;
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ aN = std::move(a1);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(A2<int>::copy_called == false);
+ assert(A2<int>::move_called == true);
+ assert(aN == a1);
+ }
+ {
+ typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+ A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+ A aN;
+ A1<int>::copy_called = false;
+ A1<int>::move_called = false;
+ A2<int>::copy_called = false;
+ A2<int>::move_called = false;
+ A3<int>::copy_called = false;
+ A3<int>::move_called = false;
+ aN = std::move(a1);
+ assert(A1<int>::copy_called == false);
+ assert(A1<int>::move_called == true);
+ assert(A2<int>::copy_called == false);
+ assert(A2<int>::move_called == true);
+ assert(A3<int>::copy_called == false);
+ assert(A3<int>::move_called == true);
+ assert(aN == a1);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp b/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp
deleted file mode 100644
index 3a9749e21c52..000000000000
--- a/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
-
-#include <ctime>
-
-int main() {
- // asctime is not thread-safe.
- std::time_t t = 0;
- std::asctime(&t);
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
index 6315598125c9..ad03e8fb6bb2 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
index 33bf01855908..4577d0bf4d54 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
index ab4dd59534d5..815096f6b157 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
index af5efe464d5d..f69afbf57667 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
index 4913a510c36e..a1137ee388c1 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
index b7874b77cf03..73f26e4b585a 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
index 12720f7b550a..f61d93aefd89 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<CopyConstructible Fn, CopyConstructible... Types>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
index 7f8dd4a98d2b..83fa452fecb3 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <functional>
// template<class T> struct is_bind_expression
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp
new file mode 100644
index 000000000000..12a78dbc7548
--- /dev/null
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+//-----------------------------------------------------------------------------
+// TESTING template<class T> struct is_bind_expression
+//
+// bind is not implemented in C++03 so nothing is a bind expression. However
+// for compatibility reasons the trait is_bind_expression should be available
+// in C++03 and it should always return false.
+
+#include <functional>
+
+template <class T>
+void test() {
+ static_assert(!std::is_bind_expression<T>::value, "");
+}
+
+struct C {};
+
+int main() {
+ test<int>();
+ test<void>();
+ test<C>();
+ test<C&>();
+ test<C const&>();
+ test<C*>();
+ test<void()>();
+ test<int(*)()>();
+ test<int (C::*)()>();
+ test<decltype(std::placeholders::_2)>();
+}
diff --git a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
index 4b9cc76f7e4f..97b0b4d158a0 100644
--- a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
+++ b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
@@ -40,6 +40,7 @@
#include <functional>
#include <type_traits>
+#include <utility> // for std::move
#include <cassert>
struct NonCopyable {
diff --git a/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp
index 4096bd814421..f371223ee84c 100644
--- a/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp
+++ b/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp
@@ -69,4 +69,7 @@ int main()
test0(std::mem_fn(&A::test0));
test1(std::mem_fn(&A::test1));
test2(std::mem_fn(&A::test2));
+#if __has_feature(cxx_noexcept)
+ static_assert((noexcept(std::mem_fn(&A::test0))), ""); // LWG#2489
+#endif
}
diff --git a/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp b/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp
new file mode 100644
index 000000000000..e579f207a33f
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp
@@ -0,0 +1,318 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+// - Bullet 1 -- (t1.*f)(t2, ..., tN)
+// - Bullet 2 -- ((*t1).*f)(t2, ..., tN)
+//
+// Overview:
+// Bullets 1 and 2 handle the case where 'f' is a pointer to member function.
+// Bullet 1 only handles the cases where t1 is an object of type T or a
+// type derived from 'T'. Bullet 2 handles all other cases.
+//
+// Concerns:
+// 1) cv-qualified member function signatures are accepted.
+// 2) reference qualified member function signatures are accepted.
+// 3) member functions with varargs at the end are accepted.
+// 4) The arguments are perfect forwarded to the member function call.
+// 5) Classes that are publicly derived from 'T' are accepted as the call object
+// 6) All types that dereference to T or a type derived from T can be used
+// as the call object.
+// 7) Pointers to T or a type derived from T can be used as the call object.
+// 8) Reference return types are properly deduced.
+//
+//
+// Plan:
+// 1) Create a class that contains a set, 'S', of non-static functions.
+// 'S' should include functions that cover every single combination
+// of qualifiers and varargs for arities of 0, 1 and 2 (C-1,2,3).
+// The argument types used in the functions should be non-copyable (C-4).
+// The functions should return 'MethodID::setUncheckedCall()'.
+//
+// 2) Create a set of supported call object, 'Objs', of different types
+// and behaviors. (C-5,6,7)
+//
+// 3) Attempt to call each function, 'f', in 'S' with each call object, 'c',
+// in 'Objs'. After every attempted call to 'f' check that 'f' was
+// actually called using 'MethodID::checkCalled(<return-value>)'
+//
+// 3b) If 'f' is reference qualified call 'f' with the properly qualified
+// call object. Otherwise call 'f' with lvalue call objects.
+//
+// 3a) If 'f' is const, volatile, or cv qualified then call it with call
+// objects that are equally or less cv-qualified.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+//==============================================================================
+// MemFun03 - C++03 compatible set of test member functions.
+struct MemFun03 {
+ typedef void*& R;
+#define F(...) \
+ R f(__VA_ARGS__) { return MethodID<R(MemFun03::*)(__VA_ARGS__)>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const { return MethodID<R(MemFun03::*)(__VA_ARGS__) const>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) volatile>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) const volatile>::setUncheckedCall(); }
+#
+ F()
+ F(...)
+ F(ArgType&)
+ F(ArgType&, ...)
+ F(ArgType&, ArgType&)
+ F(ArgType&, ArgType&, ...)
+ F(ArgType&, ArgType&, ArgType&)
+ F(ArgType&, ArgType&, ArgType&, ...)
+#undef F
+public:
+ MemFun03() {}
+private:
+ MemFun03(MemFun03 const&);
+ MemFun03& operator=(MemFun03 const&);
+};
+
+
+#if TEST_STD_VER >= 11
+
+//==============================================================================
+// MemFun11 - C++11 reference qualified test member functions.
+struct MemFun11 {
+ typedef void*& R;
+ typedef MemFun11 C;
+#define F(...) \
+ R f(__VA_ARGS__) & { return MethodID<R(C::*)(__VA_ARGS__) &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const & { return MethodID<R(C::*)(__VA_ARGS__) const &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile & { return MethodID<R(C::*)(__VA_ARGS__) volatile &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile & { return MethodID<R(C::*)(__VA_ARGS__) const volatile &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) && { return MethodID<R(C::*)(__VA_ARGS__) &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const && { return MethodID<R(C::*)(__VA_ARGS__) const &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile && { return MethodID<R(C::*)(__VA_ARGS__) volatile &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile && { return MethodID<R(C::*)(__VA_ARGS__) const volatile &&>::setUncheckedCall(); }
+#
+ F()
+ F(...)
+ F(ArgType&&)
+ F(ArgType&&, ...)
+ F(ArgType&&, ArgType&&)
+ F(ArgType&&, ArgType&&, ...)
+ F(ArgType&&, ArgType&&, ArgType&&)
+ F(ArgType&&, ArgType&&, ArgType&&, ...)
+#undef F
+public:
+ MemFun11() {}
+private:
+ MemFun11(MemFun11 const&);
+ MemFun11& operator=(MemFun11 const&);
+};
+
+#endif // TEST_STD_VER >= 11
+
+
+//==============================================================================
+// TestCase - A test case for a single member function.
+// ClassType - The type of the class being tested.
+// CallSig - The function signature of the method being tested.
+// Arity - the arity of 'CallSig'
+// CV - the cv qualifiers of 'CallSig' represented as a type tag.
+// RValue - The method is RValue qualified.
+// ArgRValue - Call the method with RValue arguments.
+template <class ClassType, class CallSig, int Arity, class CV,
+ bool RValue = false, bool ArgRValue = false>
+struct TestCaseImp {
+public:
+
+ static void run() { TestCaseImp().doTest(); }
+
+private:
+ //==========================================================================
+ // TEST DISPATCH
+ void doTest() {
+ // (Plan-2) Create test call objects.
+ typedef ClassType T;
+ typedef DerivedFromType<T> D;
+ T obj;
+ T* obj_ptr = &obj;
+ D der;
+ D* der_ptr = &der;
+ DerefToType<T> dref;
+ DerefPropType<T> dref2;
+
+ // (Plan-3) Dispatch based on the CV tags.
+ CV tag;
+ Bool<!RValue> NotRValue;
+ runTestDispatch(tag, obj);
+ runTestDispatch(tag, der);
+ runTestDispatch(tag, dref2);
+ runTestDispatchIf(NotRValue, tag, dref);
+ runTestDispatchIf(NotRValue, tag, obj_ptr);
+ runTestDispatchIf(NotRValue, tag, der_ptr);
+ }
+
+ template <class QT, class Tp>
+ void runTestDispatchIf(Bool<true>, QT q, Tp& v) {
+ runTestDispatch(q, v);
+ }
+
+ template <class QT, class Tp>
+ void runTestDispatchIf(Bool<false>, QT, Tp&) {
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_None, Tp& v) {
+ runTest(v);
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_Const, Tp& v) {
+ Tp const& cv = v;
+ runTest(v);
+ runTest(cv);
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_Volatile, Tp& v) {
+ Tp volatile& vv = v;
+ runTest(v);
+ runTest(vv);
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_CV, Tp& v) {
+ Tp const& cv = v;
+ Tp volatile& vv = v;
+ Tp const volatile& cvv = v;
+ runTest(v);
+ runTest(cv);
+ runTest(vv);
+ runTest(cvv);
+ }
+
+ template <class Obj>
+ void runTest(Obj& obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig (ClassType::*MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest( (MemPtr)&ClassType::f, obj);
+ }
+};
+
+template <class Sig, int Arity, class CV>
+struct TestCase : public TestCaseImp<MemFun03, Sig, Arity, CV> {};
+
+#if TEST_STD_VER >= 11
+template <class Sig, int Arity, class CV, bool RValue = false>
+struct TestCase11 : public TestCaseImp<MemFun11, Sig, Arity, CV, RValue, true> {};
+#endif
+
+int main() {
+ typedef void*& R;
+ typedef ArgType A;
+ TestCase<R(), 0, Q_None>::run();
+ TestCase<R() const, 0, Q_Const>::run();
+ TestCase<R() volatile, 0, Q_Volatile>::run();
+ TestCase<R() const volatile, 0, Q_CV>::run();
+ TestCase<R(...), 0, Q_None>::run();
+ TestCase<R(...) const, 0, Q_Const>::run();
+ TestCase<R(...) volatile, 0, Q_Volatile>::run();
+ TestCase<R(...) const volatile, 0, Q_CV>::run();
+ TestCase<R(A&), 1, Q_None>::run();
+ TestCase<R(A&) const, 1, Q_Const>::run();
+ TestCase<R(A&) volatile, 1, Q_Volatile>::run();
+ TestCase<R(A&) const volatile, 1, Q_CV>::run();
+ TestCase<R(A&, ...), 1, Q_None>::run();
+ TestCase<R(A&, ...) const, 1, Q_Const>::run();
+ TestCase<R(A&, ...) volatile, 1, Q_Volatile>::run();
+ TestCase<R(A&, ...) const volatile, 1, Q_CV>::run();
+ TestCase<R(A&, A&), 2, Q_None>::run();
+ TestCase<R(A&, A&) const, 2, Q_Const>::run();
+ TestCase<R(A&, A&) volatile, 2, Q_Volatile>::run();
+ TestCase<R(A&, A&) const volatile, 2, Q_CV>::run();
+ TestCase<R(A&, A&, ...), 2, Q_None>::run();
+ TestCase<R(A&, A&, ...) const, 2, Q_Const>::run();
+ TestCase<R(A&, A&, ...) volatile, 2, Q_Volatile>::run();
+ TestCase<R(A&, A&, ...) const volatile, 2, Q_CV>::run();
+ TestCase<R(A&, A&, A&), 3, Q_None>::run();
+ TestCase<R(A&, A&, A&) const, 3, Q_Const>::run();
+ TestCase<R(A&, A&, A&) volatile, 3, Q_Volatile>::run();
+ TestCase<R(A&, A&, A&) const volatile, 3, Q_CV>::run();
+ TestCase<R(A&, A&, A&, ...), 3, Q_None>::run();
+ TestCase<R(A&, A&, A&, ...) const, 3, Q_Const>::run();
+ TestCase<R(A&, A&, A&, ...) volatile, 3, Q_Volatile>::run();
+ TestCase<R(A&, A&, A&, ...) const volatile, 3, Q_CV>::run();
+
+#if TEST_STD_VER >= 11
+ TestCase11<R() &, 0, Q_None>::run();
+ TestCase11<R() const &, 0, Q_Const>::run();
+ TestCase11<R() volatile &, 0, Q_Volatile>::run();
+ TestCase11<R() const volatile &, 0, Q_CV>::run();
+ TestCase11<R(...) &, 0, Q_None>::run();
+ TestCase11<R(...) const &, 0, Q_Const>::run();
+ TestCase11<R(...) volatile &, 0, Q_Volatile>::run();
+ TestCase11<R(...) const volatile &, 0, Q_CV>::run();
+ TestCase11<R(A&&) &, 1, Q_None>::run();
+ TestCase11<R(A&&) const &, 1, Q_Const>::run();
+ TestCase11<R(A&&) volatile &, 1, Q_Volatile>::run();
+ TestCase11<R(A&&) const volatile &, 1, Q_CV>::run();
+ TestCase11<R(A&&, ...) &, 1, Q_None>::run();
+ TestCase11<R(A&&, ...) const &, 1, Q_Const>::run();
+ TestCase11<R(A&&, ...) volatile &, 1, Q_Volatile>::run();
+ TestCase11<R(A&&, ...) const volatile &, 1, Q_CV>::run();
+ TestCase11<R(A&&, A&&) &, 2, Q_None>::run();
+ TestCase11<R(A&&, A&&) const &, 2, Q_Const>::run();
+ TestCase11<R(A&&, A&&) volatile &, 2, Q_Volatile>::run();
+ TestCase11<R(A&&, A&&) const volatile &, 2, Q_CV>::run();
+ TestCase11<R(A&&, A&&, ...) &, 2, Q_None>::run();
+ TestCase11<R(A&&, A&&, ...) const &, 2, Q_Const>::run();
+ TestCase11<R(A&&, A&&, ...) volatile &, 2, Q_Volatile>::run();
+ TestCase11<R(A&&, A&&, ...) const volatile &, 2, Q_CV>::run();
+ TestCase11<R() &&, 0, Q_None, /* RValue */ true>::run();
+ TestCase11<R() const &&, 0, Q_Const, /* RValue */ true>::run();
+ TestCase11<R() volatile &&, 0, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R() const volatile &&, 0, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(...) &&, 0, Q_None, /* RValue */ true>::run();
+ TestCase11<R(...) const &&, 0, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(...) volatile &&, 0, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(...) const volatile &&, 0, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&) &&, 1, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&) const &&, 1, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&) volatile &&, 1, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&) const volatile &&, 1, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) &&, 1, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) const &&, 1, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) volatile &&, 1, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) const volatile &&, 1, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) &&, 2, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) const &&, 2, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) volatile &&, 2, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) const volatile &&, 2, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) &&, 2, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) const &&, 2, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) volatile &&, 2, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) const volatile &&, 2, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) &&, 3, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) const &&, 3, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) volatile &&, 3, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) const volatile &&, 3, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) &&, 3, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) const &&, 3, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) volatile &&, 3, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) const volatile &&, 3, Q_CV, /* RValue */ true>::run();
+#endif
+} \ No newline at end of file
diff --git a/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp b/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp
new file mode 100644
index 000000000000..b6fe190bd2a7
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+// - Bullet 3 -- t1.*f
+// - Bullet 4 -- (*t1).*f
+//
+// Overview:
+// Bullets 3 and 4 handle the case where 'f' is a pointer to member object.
+// Bullet 3 only handles the cases where t1 is an object of type T or a
+// type derived from 'T'. Bullet 4 handles all other cases.
+//
+// Concerns:
+// 1) The return type is always an lvalue reference.
+// 2) The return type is not less cv-qualified that the object that contains it.
+// 3) The return type is not less cv-qualified than object type.
+// 4) The call object is perfectly forwarded.
+// 5) Classes that are publicly derived from 'T' are accepted as the call object
+// 6) All types that dereference to T or a type derived from T can be used
+// as the call object.
+// 7) Pointers to T or a type derived from T can be used as the call object.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+template <class Tp>
+struct TestMemberObject {
+ TestMemberObject() : object() {}
+ Tp object;
+private:
+ TestMemberObject(TestMemberObject const&);
+ TestMemberObject& operator=(TestMemberObject const&);
+};
+
+template <class ObjectType>
+struct TestCase {
+ public:
+
+ static void run() { TestCase().doTest(); }
+
+private:
+ typedef TestMemberObject<ObjectType> TestType;
+
+ //==========================================================================
+ // TEST DISPATCH
+ void doTest() {
+ typedef DerivedFromType<TestType> Derived;
+ TestType obj;
+ TestType* obj_ptr = &obj;
+ Derived der;
+ Derived* der_ptr = &der;
+ DerefToType<TestType> dref;
+ DerefPropType<TestType> dref2;
+
+ {
+ typedef ObjectType (TestType::*MemPtr);
+ typedef ObjectType E;
+ MemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestPointerDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType const (TestType::*CMemPtr);
+ typedef ObjectType const E;
+ CMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestPointerDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType volatile (TestType::*VMemPtr);
+ typedef ObjectType volatile E;
+ VMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestPointerDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType const volatile (TestType::*CVMemPtr);
+ typedef ObjectType const volatile E;
+ CVMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestPointerDispatch<E>(M, dref, &dref.object.object);
+ }
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect &> (M, C_<T&>(obj), expect);
+ runTest<Expect const&> (M, C_<T const&>(obj), expect);
+ runTest<Expect volatile&> (M, C_<T volatile&>(obj), expect);
+ runTest<Expect const volatile&>(M, C_<T const volatile&>(obj), expect);
+#if TEST_STD_VER >= 11
+ runTest<Expect&&> (M, C_<T&&>(obj), expect);
+ runTest<Expect const&&> (M, C_<T const&&>(obj), expect);
+ runTest<Expect volatile&&> (M, C_<T volatile&&>(obj), expect);
+ runTest<Expect const volatile&&>(M, C_<T const volatile&&>(obj), expect);
+#endif
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestPointerDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect&>(M, C_<T &>(obj), expect);
+ runTest<Expect&>(M, C_<T const&>(obj), expect);
+ runTest<Expect&>(M, C_<T volatile&>(obj), expect);
+ runTest<Expect&>(M, C_<T const volatile&>(obj), expect);
+#if TEST_STD_VER >= 11
+ runTest<Expect&>(M, C_<T&&>(obj), expect);
+ runTest<Expect&>(M, C_<T const&&>(obj), expect);
+ runTest<Expect&>(M, C_<T volatile&&>(obj), expect);
+ runTest<Expect&>(M, C_<T const volatile&&>(obj), expect);
+#endif
+ }
+
+ template <class Expect, class Fn, class T>
+#if TEST_STD_VER >= 11
+ void runTest(Fn M, T&& obj, ObjectType* expect) {
+#else
+ void runTest(Fn M, T& obj, ObjectType* expect ) {
+#endif
+ static_assert((std::is_same<
+ decltype(std::__invoke(M, std::forward<T>(obj))), Expect
+ >::value), "");
+ Expect e = std::__invoke(M, std::forward<T>(obj));
+ assert(&e == expect);
+ }
+};
+
+int main() {
+ TestCase<ArgType>::run();
+ TestCase<ArgType const>::run();
+ TestCase<ArgType volatile>::run();
+ TestCase<ArgType const volatile>::run();
+ TestCase<ArgType*>::run();
+} \ No newline at end of file
diff --git a/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp b/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp
new file mode 100644
index 000000000000..3f3c96a9b9bd
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp
@@ -0,0 +1,327 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+// - Bullet 5 -- f(t2, ..., tN)
+//
+// Overview:
+// Bullet 5 handles the cases where the first argument is not a member
+// function.
+//
+// Concerns:
+// 1) Different types of callable objects are supported. Including
+// 1a) Free Function pointers and references.
+// 1b) Classes which provide a call operator
+// 1c) lambdas
+// 2) The callable objects are perfect forwarded.
+// 3) The arguments are perfect forwarded.
+// 4) Signatures which include varargs are supported.
+// 5) In C++03 3 extra arguments should be allowed.
+//
+// Plan:
+// 1) Define a set of free functions, 'SF', and class types with call
+// operators, 'SC', that address concerns 4 and 5. The free functions should
+// return 'FunctionID::setUncheckedCall()' and the call operators should
+// return 'MethodID::setUncheckedCall()'.
+//
+// 2) For each function 'f' in 'SF' and 'SC' attempt to call 'f'
+// using the correct number of arguments and cv-ref qualifiers. Check that
+// 'f' has been called using 'FunctionID::checkCall()' if 'f' is a free
+// function and 'MethodID::checkCall()' otherwise.
+
+
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+
+//==============================================================================
+// freeFunction03 - A C++03 free function.
+void*& freeFunction03() {
+ return FunctionPtrID<void*&(), freeFunction03>::setUncheckedCall();
+}
+
+void*& freeFunction03(...) {
+ return FunctionPtrID<void*&(...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0>
+void*& freeFunction03(A0&) {
+ return FunctionPtrID<void*&(A0&), freeFunction03>::setUncheckedCall();
+}
+
+
+template <class A0>
+void*& freeFunction03(A0&, ...) {
+ return FunctionPtrID<void*&(A0&, ...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1>
+void*& freeFunction03(A0&, A1&) {
+ return FunctionPtrID<void*&(A0&, A1&), freeFunction03>::setUncheckedCall();
+}
+
+
+template <class A0, class A1>
+void*& freeFunction03(A0&, A1&, ...) {
+ return FunctionPtrID<void*&(A0&, A1&, ...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1, class A2>
+void*& freeFunction03(A0&, A1&, A2&) {
+ return FunctionPtrID<void*&(A0&, A1&, A2&), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1, class A2>
+void*& freeFunction03(A0&, A1&, A2&, ...) {
+ return FunctionPtrID<void*&(A0&, A1&, A2&, ...), freeFunction03>::setUncheckedCall();
+}
+
+//==============================================================================
+// Functor03 - C++03 compatible functor object
+struct Functor03 {
+ typedef void*& R;
+ typedef Functor03 C;
+#define F(Args, ...) \
+ __VA_ARGS__ R operator() Args { return MethodID<R(C::*) Args>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args const { return MethodID<R(C::*) Args const>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args volatile { return MethodID<R(C::*) Args volatile>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args const volatile { return MethodID<R(C::*) Args const volatile>::setUncheckedCall(); }
+#
+ F(())
+ F((A0&), template <class A0>)
+ F((A0&, A1&), template <class A0, class A1>)
+ F((A0&, A1&, A2&), template <class A0, class A1, class A2>)
+#undef F
+public:
+ Functor03() {}
+private:
+ Functor03(Functor03 const&);
+ Functor03& operator=(Functor03 const&);
+};
+
+
+#if TEST_STD_VER >= 11
+
+//==============================================================================
+// freeFunction11 - A C++11 free function.
+template <class ...Args>
+void*& freeFunction11(Args&&...) {
+ return FunctionPtrID<void*&(Args&&...), freeFunction11>::setUncheckedCall();
+}
+
+template <class ...Args>
+void*& freeFunction11(Args&&...,...) {
+ return FunctionPtrID<void*&(Args&&...,...), freeFunction11>::setUncheckedCall();
+}
+
+//==============================================================================
+// Functor11 - C++11 reference qualified test member functions.
+struct Functor11 {
+ typedef void*& R;
+ typedef Functor11 C;
+
+#define F(CV) \
+ template <class ...Args> \
+ R operator()(Args&&...) CV { return MethodID<R(C::*)(Args&&...) CV>::setUncheckedCall(); }
+#
+ F(&)
+ F(const &)
+ F(volatile &)
+ F(const volatile &)
+ F(&&)
+ F(const &&)
+ F(volatile &&)
+ F(const volatile &&)
+#undef F
+public:
+ Functor11() {}
+private:
+ Functor11(Functor11 const&);
+ Functor11& operator=(Functor11 const&);
+};
+
+#endif // TEST_STD_VER >= 11
+
+
+//==============================================================================
+// TestCaseFunctorImp - A test case for an operator() class method.
+// ClassType - The type of the call object.
+// CallSig - The function signature of the call operator being tested.
+// Arity - the arity of 'CallSig'
+// ObjCaster - Transformation function applied to call object.
+// ArgCaster - Transformation function applied to the extra arguments.
+template <class ClassType, class CallSig, int Arity,
+ class ObjCaster, class ArgCaster = LValueCaster>
+struct TestCaseFunctorImp {
+public:
+ static void run() {
+ typedef MethodID<CallSig ClassType::*> MID;
+ BasicTest<MID, Arity, ObjCaster, ArgCaster> t;
+ typedef ClassType T;
+ typedef DerivedFromType<T> D;
+ T obj;
+ D der;
+ t.runTest(obj);
+ t.runTest(der);
+ }
+};
+
+//==============================================================================
+// TestCaseFreeFunction - A test case for a free function.
+// CallSig - The function signature of the free function being tested.
+// FnPtr - The function being tested.
+// Arity - the arity of 'CallSig'
+// ArgCaster - Transformation function to be applied to the extra arguments.
+template <class CallSig, CallSig* FnPtr, int Arity, class ArgCaster>
+struct TestCaseFreeFunction {
+public:
+ static void run() {
+ typedef FunctionPtrID<CallSig, FnPtr> FID;
+ BasicTest<FID, Arity, LValueCaster, ArgCaster> t;
+
+ DerefToType<CallSig*> deref_to(FnPtr);
+ DerefToType<CallSig&> deref_to_ref(*FnPtr);
+
+ t.runTest(FnPtr);
+ t.runTest(*FnPtr);
+ t.runTest(deref_to);
+ t.runTest(deref_to_ref);
+ }
+};
+
+//==============================================================================
+// runTest Helpers
+//==============================================================================
+#if TEST_STD_VER >= 11
+template <class Sig, int Arity, class ArgCaster>
+void runFunctionTestCase11() {
+ TestCaseFreeFunction<Sig, freeFunction11, Arity, ArgCaster>();
+}
+#endif
+
+template <class Sig, int Arity, class ArgCaster>
+void runFunctionTestCase() {
+ TestCaseFreeFunction<Sig, freeFunction03, Arity, ArgCaster>();
+#if TEST_STD_VER >= 11
+ runFunctionTestCase11<Sig, Arity, ArgCaster>();
+#endif
+}
+
+template <class Sig, int Arity, class ObjCaster, class ArgCaster>
+void runFunctorTestCase() {
+ TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster, ArgCaster>::run();
+}
+
+template <class Sig, int Arity, class ObjCaster>
+void runFunctorTestCase() {
+ TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster>::run();
+}
+
+#if TEST_STD_VER >= 11
+// runTestCase - Run a test case for C++11 class functor types
+template <class Sig, int Arity, class ObjCaster, class ArgCaster = LValueCaster>
+void runFunctorTestCase11() {
+ TestCaseFunctorImp<Functor11, Sig, Arity, ObjCaster, ArgCaster>::run();
+}
+#endif
+
+// runTestCase - Run a test case for both function and functor types.
+template <class Sig, int Arity, class ArgCaster>
+void runTestCase() {
+ runFunctionTestCase<Sig, Arity, ArgCaster>();
+ runFunctorTestCase <Sig, Arity, LValueCaster, ArgCaster>();
+};
+
+int main() {
+ typedef void*& R;
+ typedef ArgType A;
+ typedef A const CA;
+
+ runTestCase< R(), 0, LValueCaster >();
+ runTestCase< R(A&), 1, LValueCaster >();
+ runTestCase< R(A&, A&), 2, LValueCaster >();
+ runTestCase< R(A&, A&, A&), 3, LValueCaster >();
+ runTestCase< R(CA&), 1, ConstCaster >();
+ runTestCase< R(CA&, CA&), 2, ConstCaster >();
+ runTestCase< R(CA&, CA&, CA&), 3, ConstCaster >();
+
+ runFunctionTestCase<R(...), 0, LValueCaster >();
+ runFunctionTestCase<R(A&, ...), 1, LValueCaster >();
+ runFunctionTestCase<R(A&, A&, ...), 2, LValueCaster >();
+ runFunctionTestCase<R(A&, A&, A&, ...), 3, LValueCaster >();
+
+#if TEST_STD_VER >= 11
+ runFunctionTestCase11<R(A&&), 1, MoveCaster >();
+ runFunctionTestCase11<R(A&&, ...), 1, MoveCaster >();
+#endif
+
+ runFunctorTestCase<R(), 0, LValueCaster >();
+ runFunctorTestCase<R() const, 0, ConstCaster >();
+ runFunctorTestCase<R() volatile, 0, VolatileCaster >();
+ runFunctorTestCase<R() const volatile, 0, CVCaster >();
+ runFunctorTestCase<R(A&), 1, LValueCaster >();
+ runFunctorTestCase<R(A&) const, 1, ConstCaster >();
+ runFunctorTestCase<R(A&) volatile, 1, VolatileCaster >();
+ runFunctorTestCase<R(A&) const volatile, 1, CVCaster >();
+ runFunctorTestCase<R(A&, A&), 2, LValueCaster >();
+ runFunctorTestCase<R(A&, A&) const, 2, ConstCaster >();
+ runFunctorTestCase<R(A&, A&) volatile, 2, VolatileCaster >();
+ runFunctorTestCase<R(A&, A&) const volatile, 2, CVCaster >();
+ runFunctorTestCase<R(A&, A&, A&), 3, LValueCaster >();
+ runFunctorTestCase<R(A&, A&, A&) const, 3, ConstCaster >();
+ runFunctorTestCase<R(A&, A&, A&) volatile, 3, VolatileCaster >();
+ runFunctorTestCase<R(A&, A&, A&) const volatile, 3, CVCaster >();
+ {
+ typedef ConstCaster CC;
+ runFunctorTestCase<R(CA&), 1, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&) const, 1, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&) volatile, 1, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&) const volatile, 1, CVCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&), 2, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) const, 2, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) volatile, 2, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) const volatile, 2, CVCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&), 3, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) const, 3, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) volatile, 3, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) const volatile, 3, CVCaster, CC>();
+ }
+
+#if TEST_STD_VER >= 11
+ runFunctorTestCase11<R() &, 0, LValueCaster >();
+ runFunctorTestCase11<R() const &, 0, ConstCaster >();
+ runFunctorTestCase11<R() volatile &, 0, VolatileCaster >();
+ runFunctorTestCase11<R() const volatile &, 0, CVCaster >();
+ runFunctorTestCase11<R() &&, 0, MoveCaster >();
+ runFunctorTestCase11<R() const &&, 0, MoveConstCaster >();
+ runFunctorTestCase11<R() volatile &&, 0, MoveVolatileCaster >();
+ runFunctorTestCase11<R() const volatile &&, 0, MoveCVCaster >();
+ {
+ typedef MoveCaster MC;
+ runFunctorTestCase11<R(A&&) &, 1, LValueCaster, MC>();
+ runFunctorTestCase11<R(A&&) const &, 1, ConstCaster, MC>();
+ runFunctorTestCase11<R(A&&) volatile &, 1, VolatileCaster, MC>();
+ runFunctorTestCase11<R(A&&) const volatile &, 1, CVCaster, MC>();
+ runFunctorTestCase11<R(A&&) &&, 1, MoveCaster, MC>();
+ runFunctorTestCase11<R(A&&) const &&, 1, MoveConstCaster, MC>();
+ runFunctorTestCase11<R(A&&) volatile &&, 1, MoveVolatileCaster, MC>();
+ runFunctorTestCase11<R(A&&) const volatile &&, 1, MoveCVCaster, MC>();
+ }
+#endif
+}
diff --git a/test/std/utilities/function.objects/func.require/invoke_helpers.h b/test/std/utilities/function.objects/func.require/invoke_helpers.h
new file mode 100644
index 000000000000..0583b624da31
--- /dev/null
+++ b/test/std/utilities/function.objects/func.require/invoke_helpers.h
@@ -0,0 +1,317 @@
+#ifndef INVOKE_HELPERS_H
+#define INVOKE_HELPERS_H
+
+#include <type_traits>
+#include <cassert>
+#include <functional>
+
+#include "test_macros.h"
+
+template <int I>
+struct Int : public std::integral_constant<int, I> {};
+
+template <bool P>
+struct Bool : public std::integral_constant<bool, P> {};
+
+struct Q_None {
+ template <class T>
+ struct apply { typedef T type; };
+};
+
+struct Q_Const {
+ template <class T>
+ struct apply { typedef T const type; };
+};
+
+struct Q_Volatile {
+ template <class T>
+ struct apply { typedef T volatile type; };
+};
+
+struct Q_CV {
+ template <class T>
+ struct apply { typedef T const volatile type; };
+};
+
+// Caster - A functor object that performs cv-qualifier and value category
+// conversions.
+// QualTag - A metafunction type that applies cv-qualifiers to its argument.
+// RValue - True if the resulting object should be an RValue reference.
+// False otherwise.
+template <class QualTag, bool RValue = false>
+struct Caster {
+ template <class T>
+ struct apply {
+ typedef typename std::remove_reference<T>::type RawType;
+ typedef typename QualTag::template apply<RawType>::type CVType;
+#if TEST_STD_VER >= 11
+ typedef typename std::conditional<RValue,
+ CVType&&, CVType&
+ >::type type;
+#else
+ typedef CVType& type;
+#endif
+ };
+
+ template <class T>
+ typename apply<T>::type
+ operator()(T& obj) const {
+ typedef typename apply<T>::type OutType;
+ return static_cast<OutType>(obj);
+ }
+};
+
+typedef Caster<Q_None> LValueCaster;
+typedef Caster<Q_Const> ConstCaster;
+typedef Caster<Q_Volatile> VolatileCaster;
+typedef Caster<Q_CV> CVCaster;
+typedef Caster<Q_None, true> MoveCaster;
+typedef Caster<Q_Const, true> MoveConstCaster;
+typedef Caster<Q_Volatile, true> MoveVolatileCaster;
+typedef Caster<Q_CV, true> MoveCVCaster;
+
+// A shorter name for 'static_cast'
+template <class QualType, class Tp>
+QualType C_(Tp& v) { return static_cast<QualType>(v); };
+
+//==============================================================================
+// ArgType - A non-copyable type intended to be used as a dummy argument type
+// to test functions.
+struct ArgType {
+ int value;
+ explicit ArgType(int val = 0) : value(val) {}
+private:
+ ArgType(ArgType const&);
+ ArgType& operator=(ArgType const&);
+};
+
+//==============================================================================
+// DerivedFromBase - A type that derives from it's template argument 'Base'
+template <class Base>
+struct DerivedFromType : public Base {
+ DerivedFromType() : Base() {}
+ template <class Tp>
+ explicit DerivedFromType(Tp const& t) : Base(t) {}
+};
+
+//==============================================================================
+// DerefToType - A type that dereferences to it's template argument 'To'.
+// The cv-ref qualifiers of the 'DerefToType' object do not propagate
+// to the resulting 'To' object.
+template <class To>
+struct DerefToType {
+ To object;
+
+ DerefToType() {}
+
+ template <class Up>
+ explicit DerefToType(Up const& val) : object(val) {}
+
+ To& operator*() const volatile { return const_cast<To&>(object); }
+};
+
+//==============================================================================
+// DerefPropToType - A type that dereferences to it's template argument 'To'.
+// The cv-ref qualifiers of the 'DerefPropToType' object propagate
+// to the resulting 'To' object.
+template <class To>
+struct DerefPropType {
+ To object;
+
+ DerefPropType() {}
+
+ template <class Up>
+ explicit DerefPropType(Up const& val) : object(val) {}
+
+#if TEST_STD_VER < 11
+ To& operator*() { return object; }
+ To const& operator*() const { return object; }
+ To volatile& operator*() volatile { return object; }
+ To const volatile& operator*() const volatile { return object; }
+#else
+ To& operator*() & { return object; }
+ To const& operator*() const & { return object; }
+ To volatile& operator*() volatile & { return object; }
+ To const volatile& operator*() const volatile & { return object; }
+ To&& operator*() && { return static_cast<To &&>(object); }
+ To const&& operator*() const && { return static_cast<To const&&>(object); }
+ To volatile&& operator*() volatile && { return static_cast<To volatile&&>(object); }
+ To const volatile&& operator*() const volatile && { return static_cast<To const volatile&&>(object); }
+#endif
+};
+
+//==============================================================================
+// MethodID - A type that uniquely identifies a member function for a class.
+// This type is used to communicate between the member functions being tested
+// and the tests invoking them.
+// - Test methods should call 'setUncheckedCall()' whenever they are invoked.
+// - Tests consume the unchecked call using checkCall(<return-value>)` to assert
+// that the method has been called and that the return value of `__invoke`
+// matches what the method actually returned.
+template <class T>
+struct MethodID {
+ typedef void* IDType;
+
+ static int dummy; // A dummy memory location.
+ static void* id; // The "ID" is the value of this pointer.
+ static bool unchecked_call; // Has a call happened that has not been checked.
+
+ static void*& setUncheckedCall() {
+ assert(unchecked_call == false);
+ unchecked_call = true;
+ return id;
+ }
+
+ static bool checkCalled(void*& return_value) {
+ bool old = unchecked_call;
+ unchecked_call = false;
+ return old && id == return_value && &id == &return_value;
+ }
+};
+
+template <class T> int MethodID<T>::dummy = 0;
+template <class T> void* MethodID<T>::id = (void*)&MethodID<T>::dummy;
+template <class T> bool MethodID<T>::unchecked_call = false;
+
+
+//==============================================================================
+// FunctionPtrID - Like MethodID but for free function pointers.
+template <class T, T*>
+struct FunctionPtrID {
+ static int dummy; // A dummy memory location.
+ static void* id; // The "ID" is the value of this pointer.
+ static bool unchecked_call; // Has a call happened that has not been checked.
+
+ static void*& setUncheckedCall() {
+ assert(unchecked_call == false);
+ unchecked_call = true;
+ return id;
+ }
+
+ static bool checkCalled(void*& return_value) {
+ bool old = unchecked_call;
+ unchecked_call = false;
+ return old && id == return_value && &id == &return_value;
+ }
+};
+
+template <class T, T* Ptr> int FunctionPtrID<T, Ptr>::dummy = 0;
+template <class T, T* Ptr> void* FunctionPtrID<T, Ptr>::id = (void*)&FunctionPtrID<T, Ptr>::dummy;
+template <class T, T* Ptr> bool FunctionPtrID<T, Ptr>::unchecked_call = false;
+
+//==============================================================================
+// BasicTest - The basic test structure for everything except
+// member object pointers.
+// ID - The "Function Identifier" type used either MethodID or FunctionPtrID.
+// Arity - The Arity of the call signature.
+// ObjectCaster - The object transformation functor type.
+// ArgCaster - The extra argument transformation functor type.
+template <class ID, int Arity, class ObjectCaster = LValueCaster,
+ class ArgCaster = LValueCaster>
+struct BasicTest {
+ template <class ObjectT>
+ void runTest(ObjectT& object) {
+ Int<Arity> A;
+ runTestImp(A, object);
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTest(MethodPtr ptr, ObjectT& object) {
+ Int<Arity> A;
+ runTestImp(A, ptr, object);
+ }
+
+private:
+ typedef void*& CallRet;
+ ObjectCaster object_cast;
+ ArgCaster arg_cast;
+ ArgType a0, a1, a2;
+
+ //==========================================================================
+ // BULLET 1 AND 2 TEST METHODS
+ //==========================================================================
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<0>, MethodPtr ptr, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object));
+ assert(ID::checkCalled(ret));
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<1>, MethodPtr ptr, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<2>, MethodPtr ptr, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<3>, MethodPtr ptr, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
+ }
+
+ //==========================================================================
+ // BULLET 5 TEST METHODS
+ //==========================================================================
+ template <class ObjectT>
+ void runTestImp(Int<0>, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object));
+ assert(ID::checkCalled(ret));
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<1>, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object), arg_cast(a0)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<2>, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<3>, ObjectT& object) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
+ }
+};
+
+#endif // INVOKE_HELPERS_H
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
index cd86e4cbf8eb..82a6f6c5215e 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
@@ -11,7 +11,7 @@
// class function<R(ArgTypes...)>
-// function(nullptr_t);
+// function(F);
#include <functional>
#include <cassert>
@@ -87,4 +87,8 @@ int main()
assert(f.target<int(*)(int)>() != 0);
f(1);
}
+ {
+ std::function <void()> f(static_cast<void (*)()>(0));
+ assert(!f);
+ }
}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
new file mode 100644
index 000000000000..f89bde8e6544
--- /dev/null
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
@@ -0,0 +1,247 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// class function<R(ArgTypes...)>
+
+// function(Fp);
+
+// Ensure that __not_null works for all function types.
+// See https://llvm.org/bugs/show_bug.cgi?id=23589
+
+//------------------------------------------------------------------------------
+// TESTING std::function<...>::__not_null(Callable)
+//
+// Concerns:
+// 1) The call __not_null(Callable) is well formed and correct for each
+// possible 'Callable' type category. These categories include:
+// 1a) function pointers
+// 1b) member function pointer
+// 1c) member data pointer
+// 1d) callable class type
+// 1e) lambdas
+// Categories 1a, 1b, and 1c are 'Nullable' types. Only objects of these
+// types can be null. The other categories are not tested here.
+// 3) '__not_null(Callable)' is well formed when the call signature includes
+// varargs.
+// 4) '__not_null(Callable)' works for Callable types with all aritys less
+// than or equal to 3 in C++03.
+// 5) '__not_null(Callable)' works when 'Callable' is a member function
+// pointer to a cv or ref qualified function type.
+//
+// Plan:
+// 1 For categories 1a, 1b and 1c define a set of
+// 'Callable' objects for this category. This set should include examples
+// of arity 0, 1, 2 and possible 3 including versions with varargs as the
+// last parameter.
+//
+// 2 For each 'Callable' object in categories 1a, 1b and 1c do the following.
+//
+// 1 Define a type 'std::function<Sig>' as 'F' where 'Sig' is compatible with
+// the signature of the 'Callable' object.
+//
+// 2 Create an object of type 'F' using a null pointer of type 'Callable'.
+// Check that 'F.target<Callable>()' is null.
+//
+// 3 Create an object of type 'F' that is not null. Check that
+// 'F.target<Callable>()' is not null and is equal to the original
+// argument.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+///////////////////////////////////////////////////////////////////////////////
+int foo() { return 42; }
+int foo(int) { return 42; }
+int foo(int, int) { return 42; }
+int foo(int, int, int) { return 42; }
+
+int foo(...) { return 42; }
+int foo(int, ...) { return 42; }
+int foo(int, int, ...) { return 42; }
+int foo(int, int, int, ...) { return 42; }
+
+///////////////////////////////////////////////////////////////////////////////
+struct MemFun03 {
+ int foo() { return 42; }
+ int foo() const { return 42; }
+ int foo() volatile { return 42; }
+ int foo() const volatile { return 42; }
+
+ int foo(int) { return 42; }
+ int foo(int) const { return 42; }
+ int foo(int) volatile { return 42; }
+ int foo(int) const volatile { return 42; }
+
+ int foo(int, int) { return 42; }
+ int foo(int, int) const { return 42; }
+ int foo(int, int) volatile { return 42; }
+ int foo(int, int) const volatile { return 42; }
+
+ int foo(int, int, int) { return 42; }
+ int foo(int, int, int) const { return 42; }
+ int foo(int, int, int) volatile { return 42; }
+ int foo(int, int, int) const volatile { return 42; }
+
+ int foo(...) { return 42; }
+ int foo(...) const { return 42; }
+ int foo(...) volatile { return 42; }
+ int foo(...) const volatile { return 42; }
+
+ int foo(int, ...) { return 42; }
+ int foo(int, ...) const { return 42; }
+ int foo(int, ...) volatile { return 42; }
+ int foo(int, ...) const volatile { return 42; }
+
+ int foo(int, int, ...) { return 42; }
+ int foo(int, int, ...) const { return 42; }
+ int foo(int, int, ...) volatile { return 42; }
+ int foo(int, int, ...) const volatile { return 42; }
+
+ int foo(int, int, int, ...) { return 42; }
+ int foo(int, int, int, ...) const { return 42; }
+ int foo(int, int, int, ...) volatile { return 42; }
+ int foo(int, int, int, ...) const volatile { return 42; }
+};
+
+#if TEST_STD_VER >= 11
+struct MemFun11 {
+ int foo() & { return 42; }
+ int foo() const & { return 42; }
+ int foo() volatile & { return 42; }
+ int foo() const volatile & { return 42; }
+
+ int foo(...) & { return 42; }
+ int foo(...) const & { return 42; }
+ int foo(...) volatile & { return 42; }
+ int foo(...) const volatile & { return 42; }
+
+ int foo() && { return 42; }
+ int foo() const && { return 42; }
+ int foo() volatile && { return 42; }
+ int foo() const volatile && { return 42; }
+
+ int foo(...) && { return 42; }
+ int foo(...) const && { return 42; }
+ int foo(...) volatile && { return 42; }
+ int foo(...) const volatile && { return 42; }
+};
+#endif // TEST_STD_VER >= 11
+
+struct MemData {
+ int foo;
+};
+
+// Create a non-null free function by taking the address of
+// &static_cast<Tp&>(foo);
+template <class Tp>
+struct Creator {
+ static Tp create() {
+ return &foo;
+ }
+};
+
+// Create a non-null member pointer.
+template <class Ret, class Class>
+struct Creator<Ret Class::*> {
+ typedef Ret Class::*ReturnType;
+ static ReturnType create() {
+ return &Class::foo;
+ }
+};
+
+template <class TestFn, class Fn>
+void test_imp() {
+ { // Check that the null value is detected
+ TestFn tf = nullptr;
+ std::function<Fn> f = tf;
+ assert(f.template target<TestFn>() == nullptr);
+ }
+ { // Check that the non-null value is detected.
+ TestFn tf = Creator<TestFn>::create();
+ assert(tf != nullptr);
+ std::function<Fn> f = tf;
+ assert(f.template target<TestFn>() != nullptr);
+ assert(*f.template target<TestFn>() == tf);
+ }
+}
+
+void test_func() {
+ test_imp<int(*)(), int()>();
+ test_imp<int(*)(...), int()>();
+ test_imp<int(*)(int), int(int)>();
+ test_imp<int(*)(int, ...), int(int)>();
+ test_imp<int(*)(int, int), int(int, int)>();
+ test_imp<int(*)(int, int, ...), int(int, int)>();
+ test_imp<int(*)(int, int, int), int(int, int, int)>();
+ test_imp<int(*)(int, int, int, ...), int(int, int, int)>();
+}
+
+void test_mf() {
+ test_imp<int(MemFun03::*)(), int(MemFun03&)>();
+ test_imp<int(MemFun03::*)(...), int(MemFun03&)>();
+ test_imp<int(MemFun03::*)() const, int(MemFun03&)>();
+ test_imp<int(MemFun03::*)(...) const, int(MemFun03&)>();
+ test_imp<int(MemFun03::*)() volatile, int(MemFun03&)>();
+ test_imp<int(MemFun03::*)(...) volatile, int(MemFun03&)>();
+ test_imp<int(MemFun03::*)() const volatile, int(MemFun03&)>();
+ test_imp<int(MemFun03::*)(...) const volatile, int(MemFun03&)>();
+
+ test_imp<int(MemFun03::*)(int), int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int, ...), int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int) const, int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int, ...) const, int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int) volatile, int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int, ...) volatile, int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int) const volatile, int(MemFun03&, int)>();
+ test_imp<int(MemFun03::*)(int, ...) const volatile, int(MemFun03&, int)>();
+
+ test_imp<int(MemFun03::*)(int, int), int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int, ...), int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int) const, int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int, ...) const, int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int) volatile, int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int, ...) volatile, int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int) const volatile, int(MemFun03&, int, int)>();
+ test_imp<int(MemFun03::*)(int, int, ...) const volatile, int(MemFun03&, int, int)>();
+
+#if TEST_STD_VER >= 11
+ test_imp<int(MemFun11::*)() &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)(...) &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)() const &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)(...) const &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)() volatile &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)(...) volatile &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)() const volatile &, int(MemFun11&)>();
+ test_imp<int(MemFun11::*)(...) const volatile &, int(MemFun11&)>();
+
+ test_imp<int(MemFun11::*)() &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)(...) &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)() const &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)(...) const &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)() volatile &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)(...) volatile &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)() const volatile &&, int(MemFun11&&)>();
+ test_imp<int(MemFun11::*)(...) const volatile &&, int(MemFun11&&)>();
+#endif
+}
+
+void test_md() {
+ test_imp<int MemData::*, int(MemData&)>();
+}
+
+int main() {
+ test_func();
+ test_mf();
+ test_md();
+}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
index 6dcd2857452c..61eda7244d3b 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
@@ -30,13 +30,13 @@ test_int_1()
{
// member data pointer
{
- int A_int_1::*fp = &A_int_1::data_;
- A_int_1 a;
- std::function<int& (const A_int_1*)> r2(fp);
- const A_int_1* ap = &a;
- assert(r2(ap) == 6);
- r2(ap) = 7;
- assert(r2(ap) == 7);
+ int A_int_1::*fp = &A_int_1::data_;
+ A_int_1 a;
+ std::function<int& (const A_int_1*)> r2(fp);
+ const A_int_1* ap = &a;
+ assert(r2(ap) == 6);
+ r2(ap) = 7;
+ assert(r2(ap) == 7);
}
}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
index 31b80c3323c1..cc4315c14422 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
@@ -16,8 +16,85 @@
#include <functional>
#include <cassert>
+
int count = 0;
+
+// 0 args, return int
+
+int f_int_0()
+{
+ return 3;
+}
+
+struct A_int_0
+{
+ int operator()() {return 4;}
+};
+
+void test_int_0()
+{
+ // function
+ {
+ std::function<int ()> r1(f_int_0);
+ assert(r1() == 3);
+ }
+ // function pointer
+ {
+ int (*fp)() = f_int_0;
+ std::function<int ()> r1(fp);
+ assert(r1() == 3);
+ }
+ // functor
+ {
+ A_int_0 a0;
+ std::function<int ()> r1(a0);
+ assert(r1() == 4);
+ }
+}
+
+
+// 0 args, return void
+
+void f_void_0()
+{
+ ++count;
+}
+
+struct A_void_0
+{
+ void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+ int save_count = count;
+ // function
+ {
+ std::function<void ()> r1(f_void_0);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // function pointer
+ {
+ void (*fp)() = f_void_0;
+ std::function<void ()> r1(fp);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+ // functor
+ {
+ A_void_0 a0;
+ std::function<void ()> r1(a0);
+ r1();
+ assert(count == save_count+1);
+ save_count = count;
+ }
+}
+
// 1 arg, return void
void f_void_1(int i)
@@ -42,57 +119,57 @@ test_void_1()
int save_count = count;
// function
{
- std::function<void (int)> r1(f_void_1);
- int i = 2;
- r1(i);
- assert(count == save_count+2);
- save_count = count;
+ std::function<void (int)> r1(f_void_1);
+ int i = 2;
+ r1(i);
+ assert(count == save_count+2);
+ save_count = count;
}
// function pointer
{
- void (*fp)(int) = f_void_1;
- std::function<void (int)> r1(fp);
- int i = 3;
- r1(i);
- assert(count == save_count+3);
- save_count = count;
+ void (*fp)(int) = f_void_1;
+ std::function<void (int)> r1(fp);
+ int i = 3;
+ r1(i);
+ assert(count == save_count+3);
+ save_count = count;
}
// functor
{
- A_void_1 a0;
- std::function<void (int)> r1(a0);
- int i = 4;
- r1(i);
- assert(count == save_count+4);
- save_count = count;
+ A_void_1 a0;
+ std::function<void (int)> r1(a0);
+ int i = 4;
+ r1(i);
+ assert(count == save_count+4);
+ save_count = count;
}
// member function pointer
{
- void (A_void_1::*fp)() = &A_void_1::mem1;
- std::function<void (A_void_1)> r1(fp);
- A_void_1 a;
- r1(a);
- assert(count == save_count+1);
- save_count = count;
- A_void_1* ap = &a;
- std::function<void (A_void_1*)> r2 = fp;
- r2(ap);
- assert(count == save_count+1);
- save_count = count;
+ void (A_void_1::*fp)() = &A_void_1::mem1;
+ std::function<void (A_void_1)> r1(fp);
+ A_void_1 a;
+ r1(a);
+ assert(count == save_count+1);
+ save_count = count;
+ A_void_1* ap = &a;
+ std::function<void (A_void_1*)> r2 = fp;
+ r2(ap);
+ assert(count == save_count+1);
+ save_count = count;
}
// const member function pointer
{
- void (A_void_1::*fp)() const = &A_void_1::mem2;
- std::function<void (A_void_1)> r1(fp);
- A_void_1 a;
- r1(a);
- assert(count == save_count+1);
- save_count = count;
- std::function<void (A_void_1*)> r2(fp);
- A_void_1* ap = &a;
- r2(ap);
- assert(count == save_count+1);
- save_count = count;
+ void (A_void_1::*fp)() const = &A_void_1::mem2;
+ std::function<void (A_void_1)> r1(fp);
+ A_void_1 a;
+ r1(a);
+ assert(count == save_count+1);
+ save_count = count;
+ std::function<void (A_void_1*)> r2(fp);
+ A_void_1* ap = &a;
+ r2(ap);
+ assert(count == save_count+1);
+ save_count = count;
}
}
@@ -121,57 +198,57 @@ test_int_1()
{
// function
{
- std::function<int (int)> r1(f_int_1);
- int i = 2;
- assert(r1(i) == 3);
+ std::function<int (int)> r1(f_int_1);
+ int i = 2;
+ assert(r1(i) == 3);
}
// function pointer
{
- int (*fp)(int) = f_int_1;
- std::function<int (int)> r1(fp);
- int i = 3;
- assert(r1(i) == 4);
+ int (*fp)(int) = f_int_1;
+ std::function<int (int)> r1(fp);
+ int i = 3;
+ assert(r1(i) == 4);
}
// functor
{
- A_int_1 a0;
- std::function<int (int)> r1(a0);
- int i = 4;
- assert(r1(i) == 3);
+ A_int_1 a0;
+ std::function<int (int)> r1(a0);
+ int i = 4;
+ assert(r1(i) == 3);
}
// member function pointer
{
- int (A_int_1::*fp)() = &A_int_1::mem1;
- std::function<int (A_int_1)> r1(fp);
- A_int_1 a;
- assert(r1(a) == 3);
- std::function<int (A_int_1*)> r2(fp);
- A_int_1* ap = &a;
- assert(r2(ap) == 3);
+ int (A_int_1::*fp)() = &A_int_1::mem1;
+ std::function<int (A_int_1)> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 3);
+ std::function<int (A_int_1*)> r2(fp);
+ A_int_1* ap = &a;
+ assert(r2(ap) == 3);
}
// const member function pointer
{
- int (A_int_1::*fp)() const = &A_int_1::mem2;
- std::function<int (A_int_1)> r1(fp);
- A_int_1 a;
- assert(r1(a) == 4);
- std::function<int (A_int_1*)> r2(fp);
- A_int_1* ap = &a;
- assert(r2(ap) == 4);
+ int (A_int_1::*fp)() const = &A_int_1::mem2;
+ std::function<int (A_int_1)> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 4);
+ std::function<int (A_int_1*)> r2(fp);
+ A_int_1* ap = &a;
+ assert(r2(ap) == 4);
}
// member data pointer
{
- int A_int_1::*fp = &A_int_1::data_;
- std::function<int& (A_int_1&)> r1(fp);
- A_int_1 a;
- assert(r1(a) == 5);
- r1(a) = 6;
- assert(r1(a) == 6);
- std::function<int& (A_int_1*)> r2(fp);
- A_int_1* ap = &a;
- assert(r2(ap) == 6);
- r2(ap) = 7;
- assert(r2(ap) == 7);
+ int A_int_1::*fp = &A_int_1::data_;
+ std::function<int& (A_int_1&)> r1(fp);
+ A_int_1 a;
+ assert(r1(a) == 5);
+ r1(a) = 6;
+ assert(r1(a) == 6);
+ std::function<int& (A_int_1*)> r2(fp);
+ A_int_1* ap = &a;
+ assert(r2(ap) == 6);
+ r2(ap) = 7;
+ assert(r2(ap) == 7);
}
}
@@ -199,62 +276,62 @@ test_void_2()
int save_count = count;
// function
{
- std::function<void (int, int)> r1(f_void_2);
- int i = 2;
- int j = 3;
- r1(i, j);
- assert(count == save_count+5);
- save_count = count;
+ std::function<void (int, int)> r1(f_void_2);
+ int i = 2;
+ int j = 3;
+ r1(i, j);
+ assert(count == save_count+5);
+ save_count = count;
}
// function pointer
{
- void (*fp)(int, int) = f_void_2;
- std::function<void (int, int)> r1(fp);
- int i = 3;
- int j = 4;
- r1(i, j);
- assert(count == save_count+7);
- save_count = count;
+ void (*fp)(int, int) = f_void_2;
+ std::function<void (int, int)> r1(fp);
+ int i = 3;
+ int j = 4;
+ r1(i, j);
+ assert(count == save_count+7);
+ save_count = count;
}
// functor
{
- A_void_2 a0;
- std::function<void (int, int)> r1(a0);
- int i = 4;
- int j = 5;
- r1(i, j);
- assert(count == save_count+9);
- save_count = count;
+ A_void_2 a0;
+ std::function<void (int, int)> r1(a0);
+ int i = 4;
+ int j = 5;
+ r1(i, j);
+ assert(count == save_count+9);
+ save_count = count;
}
// member function pointer
{
- void (A_void_2::*fp)(int) = &A_void_2::mem1;
- std::function<void (A_void_2, int)> r1(fp);
- A_void_2 a;
- int i = 3;
- r1(a, i);
- assert(count == save_count+3);
- save_count = count;
- std::function<void (A_void_2*, int)> r2(fp);
- A_void_2* ap = &a;
- r2(ap, i);
- assert(count == save_count+3);
- save_count = count;
+ void (A_void_2::*fp)(int) = &A_void_2::mem1;
+ std::function<void (A_void_2, int)> r1(fp);
+ A_void_2 a;
+ int i = 3;
+ r1(a, i);
+ assert(count == save_count+3);
+ save_count = count;
+ std::function<void (A_void_2*, int)> r2(fp);
+ A_void_2* ap = &a;
+ r2(ap, i);
+ assert(count == save_count+3);
+ save_count = count;
}
// const member function pointer
{
- void (A_void_2::*fp)(int) const = &A_void_2::mem2;
- std::function<void (A_void_2, int)> r1(fp);
- A_void_2 a;
- int i = 4;
- r1(a, i);
- assert(count == save_count+4);
- save_count = count;
- std::function<void (A_void_2*, int)> r2(fp);
- A_void_2* ap = &a;
- r2(ap, i);
- assert(count == save_count+4);
- save_count = count;
+ void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+ std::function<void (A_void_2, int)> r1(fp);
+ A_void_2 a;
+ int i = 4;
+ r1(a, i);
+ assert(count == save_count+4);
+ save_count = count;
+ std::function<void (A_void_2*, int)> r2(fp);
+ A_void_2* ap = &a;
+ r2(ap, i);
+ assert(count == save_count+4);
+ save_count = count;
}
}
@@ -276,60 +353,61 @@ struct A_int_2
int mem2(int i) const {return i+2;}
};
-void
-testint_2()
+void test_int_2()
{
// function
{
- std::function<int (int, int)> r1(f_int_2);
- int i = 2;
- int j = 3;
- assert(r1(i, j) == i+j);
+ std::function<int (int, int)> r1(f_int_2);
+ int i = 2;
+ int j = 3;
+ assert(r1(i, j) == i+j);
}
// function pointer
{
- int (*fp)(int, int) = f_int_2;
- std::function<int (int, int)> r1(fp);
- int i = 3;
- int j = 4;
- assert(r1(i, j) == i+j);
+ int (*fp)(int, int) = f_int_2;
+ std::function<int (int, int)> r1(fp);
+ int i = 3;
+ int j = 4;
+ assert(r1(i, j) == i+j);
}
// functor
{
- A_int_2 a0;
- std::function<int (int, int)> r1(a0);
- int i = 4;
- int j = 5;
- assert(r1(i, j) == i+j);
+ A_int_2 a0;
+ std::function<int (int, int)> r1(a0);
+ int i = 4;
+ int j = 5;
+ assert(r1(i, j) == i+j);
}
// member function pointer
{
- int(A_int_2::*fp)(int) = &A_int_2::mem1;
- std::function<int (A_int_2, int)> r1(fp);
- A_int_2 a;
- int i = 3;
- assert(r1(a, i) == i+1);
- std::function<int (A_int_2*, int)> r2(fp);
- A_int_2* ap = &a;
- assert(r2(ap, i) == i+1);
+ int(A_int_2::*fp)(int) = &A_int_2::mem1;
+ std::function<int (A_int_2, int)> r1(fp);
+ A_int_2 a;
+ int i = 3;
+ assert(r1(a, i) == i+1);
+ std::function<int (A_int_2*, int)> r2(fp);
+ A_int_2* ap = &a;
+ assert(r2(ap, i) == i+1);
}
// const member function pointer
{
- int (A_int_2::*fp)(int) const = &A_int_2::mem2;
- std::function<int (A_int_2, int)> r1(fp);
- A_int_2 a;
- int i = 4;
- assert(r1(a, i) == i+2);
- std::function<int (A_int_2*, int)> r2(fp);
- A_int_2* ap = &a;
- assert(r2(ap, i) == i+2);
+ int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+ std::function<int (A_int_2, int)> r1(fp);
+ A_int_2 a;
+ int i = 4;
+ assert(r1(a, i) == i+2);
+ std::function<int (A_int_2*, int)> r2(fp);
+ A_int_2* ap = &a;
+ assert(r2(ap, i) == i+2);
}
}
int main()
{
+ test_void_0();
+ test_int_0();
test_void_1();
test_int_1();
test_void_2();
- testint_2();
+ test_int_2();
}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
deleted file mode 100644
index 67b4ec22da8c..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// class function<R(ArgTypes...)>
-
-// R operator()(ArgTypes... args) const
-
-#include <functional>
-#include <cassert>
-
-// 0 args, return int
-
-int count = 0;
-
-int f_int_0()
-{
- return 3;
-}
-
-struct A_int_0
-{
- int operator()() {return 4;}
-};
-
-void
-test_int_0()
-{
- // function
- {
- std::function<int ()> r1(f_int_0);
- assert(r1() == 3);
- }
- // function pointer
- {
- int (*fp)() = f_int_0;
- std::function<int ()> r1(fp);
- assert(r1() == 3);
- }
- // functor
- {
- A_int_0 a0;
- std::function<int ()> r1(a0);
- assert(r1() == 4);
- }
-}
-
-int main()
-{
- test_int_0();
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp
deleted file mode 100644
index c0a14fd96fcb..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// class function<R()>
-
-// Test that we properly return both values and void for all non-variadic
-// overloads of function::operator()(...)
-
-#define _LIBCPP_HAS_NO_VARIADICS
-#include <functional>
-#include <cassert>
-
-int foo0() { return 42; }
-int foo1(int) { return 42; }
-int foo2(int, int) { return 42; }
-int foo3(int, int, int) { return 42; }
-
-int main()
-{
- {
- std::function<int()> f(&foo0);
- assert(f() == 42);
- }
- {
- std::function<int(int)> f(&foo1);
- assert(f(1) == 42);
- }
- {
- std::function<int(int, int)> f(&foo2);
- assert(f(1, 1) == 42);
- }
- {
- std::function<int(int, int, int)> f(&foo3);
- assert(f(1, 1, 1) == 42);
- }
- {
- std::function<void()> f(&foo0);
- f();
- }
- {
- std::function<void(int)> f(&foo1);
- f(1);
- }
- {
- std::function<void(int, int)> f(&foo2);
- f(1, 1);
- }
- {
- std::function<void(int, int, int)> f(&foo3);
- f(1, 1, 1);
- }
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
deleted file mode 100644
index a820cb1b8f38..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// class function<R(ArgTypes...)>
-
-// R operator()(ArgTypes... args) const
-
-#include <functional>
-#include <new>
-#include <cstdlib>
-#include <cassert>
-
-// 0 args, return void
-
-int count = 0;
-
-void f_void_0()
-{
- ++count;
-}
-
-struct A_void_0
-{
- void operator()() {++count;}
-};
-
-void
-test_void_0()
-{
- int save_count = count;
- // function
- {
- std::function<void ()> r1(f_void_0);
- r1();
- assert(count == save_count+1);
- save_count = count;
- }
- // function pointer
- {
- void (*fp)() = f_void_0;
- std::function<void ()> r1(fp);
- r1();
- assert(count == save_count+1);
- save_count = count;
- }
- // functor
- {
- A_void_0 a0;
- std::function<void ()> r1(a0);
- r1();
- assert(count == save_count+1);
- save_count = count;
- }
-}
-
-int main()
-{
- test_void_0();
-}
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
index ba46946aae1b..a2316063cec6 100644
--- a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
+++ b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
@@ -13,6 +13,8 @@
// reference_wrapper(T&&) = delete;
+// XFAIL: c++98, c++03
+
#include <functional>
#include <cassert>
diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
index 86a5696f48ca..0aad4986a1f8 100644
--- a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
+++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
@@ -15,6 +15,8 @@
// Don't allow binding to a temp
+// XFAIL: c++98, c++03
+
#include <functional>
struct A {};
diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
index 7cd9f15e93d1..d3db45fad7c0 100644
--- a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -57,4 +57,44 @@ int main()
test<unsigned long>();
test<long long>();
test<unsigned long long>();
+
+// LWG #2119
+ test<ptrdiff_t>();
+ test<size_t>();
+
+ test<int8_t>();
+ test<int16_t>();
+ test<int32_t>();
+ test<int64_t>();
+
+ test<int_fast8_t>();
+ test<int_fast16_t>();
+ test<int_fast32_t>();
+ test<int_fast64_t>();
+
+ test<int_least8_t>();
+ test<int_least16_t>();
+ test<int_least32_t>();
+ test<int_least64_t>();
+
+ test<intmax_t>();
+ test<intptr_t>();
+
+ test<uint8_t>();
+ test<uint16_t>();
+ test<uint32_t>();
+ test<uint64_t>();
+
+ test<uint_fast8_t>();
+ test<uint_fast16_t>();
+ test<uint_fast32_t>();
+ test<uint_fast64_t>();
+
+ test<uint_least8_t>();
+ test<uint_least16_t>();
+ test<uint_least32_t>();
+ test<uint_least64_t>();
+
+ test<uintmax_t>();
+ test<uintptr_t>();
}
diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
index 2dd6c17b3dee..af4a3c4dfe7f 100644
--- a/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
+++ b/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
@@ -12,19 +12,23 @@
// template<class T, T N>
// using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+// UNSUPPORTED: c++98, c++03, c++11
+
#include <utility>
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
-#if _LIBCPP_STD_VER > 11
-
- std::make_integer_sequence<int, -3>::value_type i;
+ typedef std::make_integer_sequence<int, -3> MakeSeqT;
+ // std::make_integer_sequence is implemented using a compiler builtin if available.
+ // this builtin has different diagnostic messages than the fallback implementation.
+#if TEST_HAS_BUILTIN(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+ MakeSeqT i; // expected-error@utility:* {{integer sequences must have non-negative sequence length}}
#else
-
-X
-
-#endif // _LIBCPP_STD_VER > 11
+ MakeSeqT i; // expected-error@utility:* {{static_assert failed "std::make_integer_sequence must have a non-negative sequence length"}}
+#endif
}
diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
index 7e82b94a7da0..9bfc5f3d9d70 100644
--- a/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
+++ b/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
@@ -12,14 +12,14 @@
// template<class T, T N>
// using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+// UNSUPPORTED: c++98, c++03, c++11
+
#include <utility>
#include <type_traits>
#include <cassert>
int main()
{
-#if _LIBCPP_STD_VER > 11
-
static_assert(std::is_same<std::make_integer_sequence<int, 0>, std::integer_sequence<int>>::value, "");
static_assert(std::is_same<std::make_integer_sequence<int, 1>, std::integer_sequence<int, 0>>::value, "");
static_assert(std::is_same<std::make_integer_sequence<int, 2>, std::integer_sequence<int, 0, 1>>::value, "");
@@ -29,6 +29,4 @@ int main()
static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 1>, std::integer_sequence<unsigned long long, 0>>::value, "");
static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 2>, std::integer_sequence<unsigned long long, 0, 1>>::value, "");
static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 3>, std::integer_sequence<unsigned long long, 0, 1, 2>>::value, "");
-
-#endif // _LIBCPP_STD_VER > 11
}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp
index 7099c45fab81..b6431b56d5f0 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
+++ b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp
@@ -7,18 +7,12 @@
//
//===----------------------------------------------------------------------===//
-// <functional>
+// <utility>
-// class function<R()>
+// template<class T, T N>
+// using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
-// template<class F> function(F);
+// UNSUPPORTED: c++98, c++03, c++11
-#define _LIBCPP_HAS_NO_VARIADICS
-#include <functional>
-#include <cassert>
-
-int main()
-{
- std::function<void()> f(static_cast<void(*)()>(0));
- assert(!f);
-}
+#define _LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE
+#include "make_integer_seq.fail.cpp"
diff --git a/test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp
index cd246c631527..c75d20b11af3 100644
--- a/test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp
+++ b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+// <utility>
-#include <ctime>
+// template<class T, T N>
+// using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
-int main() {
- // ctime is not thread-safe.
- std::time_t t = 0;
- std::ctime(&t);
-}
+// UNSUPPORTED: c++98, c++03, c++11
+
+#define _LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE
+#include "make_integer_seq.pass.cpp"
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
index 1fa7291203ed..352c7c8d0caf 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
@@ -45,12 +45,12 @@ int main()
{
A<int> a;
assert(std::allocator_traits<A<int> >::max_size(a) ==
- std::numeric_limits<std::size_t>::max());
+ std::numeric_limits<std::size_t>::max() / sizeof(int));
}
{
const A<int> a = {};
assert(std::allocator_traits<A<int> >::max_size(a) ==
- std::numeric_limits<std::size_t>::max());
+ std::numeric_limits<std::size_t>::max() / sizeof(int));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
index d0a870e60690..28dadd831514 100644
--- a/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
+++ b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
@@ -15,6 +15,7 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
#include "count_new.hpp"
int A_constructed = 0;
@@ -34,30 +35,24 @@ struct A
int move_only_constructed = 0;
+#if TEST_STD_VER >= 11
class move_only
{
- int data;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(const move_only&);
- move_only& operator=(const move_only&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(move_only&);
- move_only& operator=(move_only&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&) = delete;
+ move_only& operator=(const move_only&)= delete;
public:
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
move_only(move_only&&) {++move_only_constructed;}
move_only& operator=(move_only&&) {return *this;}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
- move_only(std::__rv<move_only>) {++move_only_constructed;}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
move_only() {++move_only_constructed;}
~move_only() {--move_only_constructed;}
+
+public:
+ int data; // unused other than to make sizeof(move_only) == sizeof(int).
+ // but public to suppress "-Wunused-private-field"
};
+#endif // TEST_STD_VER >= 11
int main()
{
@@ -108,6 +103,7 @@ int main()
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
}
+#if TEST_STD_VER >= 11
{
std::allocator<move_only> a;
assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -139,4 +135,5 @@ int main()
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(move_only_constructed == 0);
}
+#endif
}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
index 6ec9339bc48f..10109383b0c7 100644
--- a/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
+++ b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
@@ -22,6 +22,6 @@ int new_called = 0;
int main()
{
const std::allocator<int> a;
- std::size_t M = a.max_size() * sizeof(int);
- assert(M > 0xFFFF && M <= std::numeric_limits<std::size_t>::max());
+ std::size_t M = a.max_size();
+ assert(M > 0xFFFF && M <= (std::numeric_limits<std::size_t>::max() / sizeof(int)));
}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
index f431335db732..8bb818319a37 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template <class InputIterator, class ForwardIterator>
@@ -20,13 +21,15 @@
struct B
{
static int count_;
+ static int population_;
int data_;
- explicit B() : data_(1) {}
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
- ~B() {data_ = 0;}
+ explicit B() : data_(1) { ++population_; }
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ ~B() {data_ = 0; --population_; }
};
int B::count_ = 0;
+int B::population_ = 0;
struct Nasty
{
@@ -45,6 +48,7 @@ int main()
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
B b[N];
+ assert(B::population_ == N);
try
{
std::uninitialized_copy(b, b+N, bp);
@@ -52,14 +56,15 @@ int main()
}
catch (...)
{
- for (int i = 0; i < N; ++i)
- assert(bp[i].data_ == 0);
+ assert(B::population_ == N);
}
B::count_ = 0;
std::uninitialized_copy(b, b+2, bp);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ assert(B::population_ == N + 2);
}
+
{
const int N = 5;
char pool[sizeof(Nasty)*N] = {0};
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
index 3b2007b969c3..ae438ef7d561 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template <class InputIterator, class Size, class ForwardIterator>
@@ -20,12 +21,14 @@
struct B
{
static int count_;
+ static int population_;
int data_;
- explicit B() : data_(1) {}
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
- ~B() {data_ = 0;}
+ explicit B() : data_(1) { ++population_; }
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ ~B() {data_ = 0; --population_; }
};
+int B::population_ = 0;
int B::count_ = 0;
struct Nasty
@@ -45,6 +48,7 @@ int main()
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
B b[N];
+ assert(B::population_ == N);
try
{
std::uninitialized_copy_n(b, 5, bp);
@@ -52,14 +56,15 @@ int main()
}
catch (...)
{
- for (int i = 0; i < N; ++i)
- assert(bp[i].data_ == 0);
+ assert(B::population_ == N);
}
B::count_ = 0;
std::uninitialized_copy_n(b, 2, bp);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ assert(B::population_ == N + 2);
}
+
{
const int N = 5;
char pool[sizeof(Nasty)*N] = {0};
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
index d2b1dfa28868..22aa8b98b8c9 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template <class ForwardIterator, class Size, class T>
@@ -19,13 +20,15 @@
struct B
{
static int count_;
+ static int population_;
int data_;
- explicit B() : data_(1) {}
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
- ~B() {data_ = 0;}
+ explicit B() : data_(1) { ++population_; }
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ ~B() {data_ = 0; --population_; }
};
int B::count_ = 0;
+int B::population_ = 0;
struct Nasty
{
@@ -43,6 +46,7 @@ int main()
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
+ assert(B::population_ == 0);
try
{
std::uninitialized_fill_n(bp, 5, B());
@@ -50,14 +54,14 @@ int main()
}
catch (...)
{
- for (int i = 0; i < N; ++i)
- assert(bp[i].data_ == 0);
+ assert(B::population_ == 0);
}
B::count_ = 0;
B* r = std::uninitialized_fill_n(bp, 2, B());
assert(r == bp + 2);
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ assert(B::population_ == 2);
}
{
{
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
index 47cabdfa478a..95c45dd50541 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template <class ForwardIterator, class T>
@@ -20,13 +21,15 @@
struct B
{
static int count_;
+ static int population_;
int data_;
- explicit B() : data_(1) {}
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
- ~B() {data_ = 0;}
+ explicit B() : data_(1) { ++population_; }
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ ~B() {data_ = 0; --population_; }
};
int B::count_ = 0;
+int B::population_ = 0;
struct Nasty
{
@@ -44,6 +47,7 @@ int main()
const int N = 5;
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
+ assert(B::population_ == 0);
try
{
std::uninitialized_fill(bp, bp+N, B());
@@ -51,13 +55,13 @@ int main()
}
catch (...)
{
- for (int i = 0; i < N; ++i)
- assert(bp[i].data_ == 0);
+ assert(B::population_ == 0);
}
B::count_ = 0;
std::uninitialized_fill(bp, bp+2, B());
for (int i = 0; i < 2; ++i)
assert(bp[i].data_ == 1);
+ assert(B::population_ == 2);
}
{
const int N = 5;
diff --git a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
index f77d6c75e17a..914802423ce7 100644
--- a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
+++ b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
@@ -13,6 +13,8 @@
#include <type_traits>
#include <cassert>
+#include <MoveOnly.h>
+
int A_constructed = 0;
struct A
@@ -29,16 +31,33 @@ public:
int main()
{
- typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+ {
+ typedef A S;
+ typedef std::aligned_storage<3*sizeof(S), std::alignment_of<S>::value>::type
Storage;
Storage buffer;
- std::raw_storage_iterator<A*, A> it((A*)&buffer);
+ std::raw_storage_iterator<S*, S> it((S*)&buffer);
assert(A_constructed == 0);
for (int i = 0; i < 3; ++i)
{
- *it++ = A(i+1);
- A* ap = (A*)&buffer + i;
+ *it++ = S(i+1);
+ S* ap = (S*)&buffer + i;
assert(*ap == i+1);
assert(A_constructed == i+1);
}
+ }
+#if _LIBCPP_STD_VER >= 14
+ {
+ typedef MoveOnly S;
+ typedef std::aligned_storage<3*sizeof(S), std::alignment_of<S>::value>::type
+ Storage;
+ Storage buffer;
+ std::raw_storage_iterator<S*, S> it((S*)&buffer);
+ S m{1};
+ *it++ = std::move(m);
+ assert(m.get() == 0); // moved from
+ S *ap = (S*) &buffer;
+ assert(ap->get() == 1); // original value
+ }
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/deleter.h b/test/std/utilities/memory/unique.ptr/deleter.h
index fb26044d98ff..1d8e19d5bc41 100644
--- a/test/std/utilities/memory/unique.ptr/deleter.h
+++ b/test/std/utilities/memory/unique.ptr/deleter.h
@@ -20,21 +20,19 @@
#include <utility>
#include <cassert>
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+
template <class T>
class Deleter
{
int state_;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(const Deleter&);
Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
Deleter& operator=(Deleter&& r)
{
@@ -42,22 +40,12 @@ public:
r.state_ = 0;
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
- return *this;
- }
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
Deleter() : state_(0) {}
explicit Deleter(int s) : state_(s) {}
~Deleter() {assert(state_ >= 0); state_ = -1;}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class U>
Deleter(Deleter<U>&& d,
typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
@@ -67,12 +55,6 @@ private:
template <class U>
Deleter(const Deleter<U>& d,
typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U> d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
public:
int state() const {return state_;}
void set_state(int i) {state_ = i;}
@@ -85,16 +67,11 @@ class Deleter<T[]>
{
int state_;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(const Deleter&);
Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
Deleter& operator=(Deleter&& r)
{
@@ -102,16 +79,66 @@ public:
r.state_ = 0;
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
+
+ Deleter() : state_(0) {}
+ explicit Deleter(int s) : state_(s) {}
+ ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+#else // TEST_STD_VER < 11
+
+template <class T>
+class Deleter
+{
+ mutable int state_;
+
+public:
+ Deleter() : state_(0) {}
+ explicit Deleter(int s) : state_(s) {}
+
+ Deleter(Deleter const & other) : state_(other.state_) {
+ other.state_ = 0;
+ }
+ Deleter& operator=(Deleter const& other) {
+ state_ = other.state_;
+ other.state_ = 0;
+ return *this;
+ }
+
+ ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class Deleter<T[]>
+{
+ mutable int state_;
+
+public:
+
+ Deleter(Deleter const& other) : state_(other.state_) {
+ other.state_ = 0;
+ }
+ Deleter& operator=(Deleter const& other) {
+ state_ = other.state_;
+ other.state_ = 0;
return *this;
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter() : state_(0) {}
explicit Deleter(int s) : state_(s) {}
@@ -123,6 +150,8 @@ public:
void operator()(T* p) {delete [] p;}
};
+#endif
+
template <class T>
void
swap(Deleter<T>& x, Deleter<T>& y)
@@ -132,6 +161,7 @@ swap(Deleter<T>& x, Deleter<T>& y)
y = std::move(t);
}
+
template <class T>
class CDeleter
{
@@ -179,4 +209,130 @@ swap(CDeleter<T>& x, CDeleter<T>& y)
y = std::move(t);
}
+// Non-copyable deleter
+template <class T>
+class NCDeleter
+{
+ int state_;
+ NCDeleter(NCDeleter const&);
+ NCDeleter& operator=(NCDeleter const&);
+public:
+
+ NCDeleter() : state_(0) {}
+ explicit NCDeleter(int s) : state_(s) {}
+ ~NCDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+
+template <class T>
+class NCDeleter<T[]>
+{
+ int state_;
+ NCDeleter(NCDeleter const&);
+ NCDeleter& operator=(NCDeleter const&);
+public:
+
+ NCDeleter() : state_(0) {}
+ explicit NCDeleter(int s) : state_(s) {}
+ ~NCDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+
+// Non-copyable deleter
+template <class T>
+class NCConstDeleter
+{
+ int state_;
+ NCConstDeleter(NCConstDeleter const&);
+ NCConstDeleter& operator=(NCConstDeleter const&);
+public:
+
+ NCConstDeleter() : state_(0) {}
+ explicit NCConstDeleter(int s) : state_(s) {}
+ ~NCConstDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) const {delete p;}
+};
+
+
+template <class T>
+class NCConstDeleter<T[]>
+{
+ int state_;
+ NCConstDeleter(NCConstDeleter const&);
+ NCConstDeleter& operator=(NCConstDeleter const&);
+public:
+
+ NCConstDeleter() : state_(0) {}
+ explicit NCConstDeleter(int s) : state_(s) {}
+ ~NCConstDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) const {delete [] p;}
+};
+
+
+// Non-copyable deleter
+template <class T>
+class CopyDeleter
+{
+ int state_;
+public:
+
+ CopyDeleter() : state_(0) {}
+ explicit CopyDeleter(int s) : state_(s) {}
+ ~CopyDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ CopyDeleter(CopyDeleter const& other) : state_(other.state_) {}
+ CopyDeleter& operator=(CopyDeleter const& other) {
+ state_ = other.state_;
+ return *this;
+ }
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+
+template <class T>
+class CopyDeleter<T[]>
+{
+ int state_;
+
+public:
+
+ CopyDeleter() : state_(0) {}
+ explicit CopyDeleter(int s) : state_(s) {}
+ ~CopyDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ CopyDeleter(CopyDeleter const& other) : state_(other.state_) {}
+ CopyDeleter& operator=(CopyDeleter const& other) {
+ state_ = other.state_;
+ return *this;
+ }
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+
#endif // DELETER_H
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
index 17375ede00f5..ed94c1a1e470 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
@@ -14,26 +14,15 @@
// Test unique_ptr move assignment
#include <memory>
-#include <utility>
-#include <cassert>
-// Can't copy from lvalue
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
+#include "test_macros.h"
int main()
{
- {
- std::unique_ptr<A> s(new A);
- std::unique_ptr<A> s2;
- s2 = s;
- }
+ std::unique_ptr<int> s, s2;
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
+ s2 = s; // expected-error {{'operator=' is a private member of 'std::__1::unique_ptr}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
index 03747b4f89cf..5088a4410e79 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
@@ -32,22 +32,6 @@ struct A
int A::count = 0;
-class NCDeleter
-{
- int state_;
-
- NCDeleter(NCDeleter&);
- NCDeleter& operator=(NCDeleter&);
-public:
-
- NCDeleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) {delete [] p;}
-};
-
int main()
{
{
@@ -71,10 +55,10 @@ int main()
}
assert(A::count == 0);
{
- NCDeleter d;
- std::unique_ptr<A[], NCDeleter&> s(new A[3], d);
+ NCDeleter<A[]> d;
+ std::unique_ptr<A[], NCDeleter<A[]>&> s(new A[3], d);
A* p = s.get();
- std::unique_ptr<A[], NCDeleter&> s2 = std::move(s);
+ std::unique_ptr<A[], NCDeleter<A[]>&> s2 = std::move(s);
assert(s2.get() == p);
assert(s.get() == 0);
assert(A::count == 3);
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
index ef821a915e44..5720d3bd288f 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
@@ -31,21 +31,6 @@ struct A
int A::count = 0;
-class NCDeleter
-{
- int state_;
-
- NCDeleter(NCDeleter&);
- NCDeleter& operator=(NCDeleter&);
-public:
-
- NCDeleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) {delete [] p;}
-};
std::unique_ptr<A[]>
source1()
@@ -67,14 +52,14 @@ void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
{
}
-std::unique_ptr<A[], NCDeleter&>
+std::unique_ptr<A[], NCDeleter<A[]>&>
source3()
{
- static NCDeleter d;
- return std::unique_ptr<A[], NCDeleter&>(new A[3], d);
+ static NCDeleter<A[]> d;
+ return std::unique_ptr<A[], NCDeleter<A[]>&>(new A[3], d);
}
-void sink3(std::unique_ptr<A[], NCDeleter&> p)
+void sink3(std::unique_ptr<A[], NCDeleter<A[]>&> p)
{
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
index b635d507b2ec..9d3f94098a08 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: c++98, c++03
+
// <memory>
// unique_ptr
@@ -16,40 +18,16 @@
// unique_ptr<T, const D&>(pointer, D()) should not compile
#include <memory>
-#include <cassert>
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
class Deleter
{
- int state_;
-
public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) const {delete [] p;}
+ Deleter() {}
+ void operator()(int* p) const {delete [] p;}
};
int main()
{
- {
- A* p = new A[3];
- assert(A::count == 3);
- std::unique_ptr<A[], const Deleter&> s(p, Deleter());
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
+ int* p = nullptr;
+ std::unique_ptr<int[], const Deleter&> s(p, Deleter()); // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}}
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
index 57724ae10a70..87cfb72ad6e0 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
@@ -14,25 +14,16 @@
// Test unique_ptr move assignment
#include <memory>
-#include <cassert>
-// Can't copy from lvalue
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
+#include "test_macros.h"
+// Can't copy from lvalue
int main()
{
- {
- std::unique_ptr<A> s(new A);
- std::unique_ptr<A> s2;
- s2 = s;
- }
+ std::unique_ptr<int> s, s2;
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
+ s2 = s; // expected-error {{'operator=' is a private member}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
index 5046fd8aae6b..9cea12b1249f 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
@@ -14,25 +14,20 @@
// Test unique_ptr move assignment
#include <memory>
-#include <cassert>
-// Can't copy from const lvalue
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
+#include "test_macros.h"
-int A::count = 0;
+// Can't copy from const lvalue
int main()
{
- {
- const std::unique_ptr<A> s(new A);
- std::unique_ptr<A> s2;
- s2 = s;
- }
+ const std::unique_ptr<int> s(new int);
+ std::unique_ptr<int> s2;
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
+ // NOTE: The error says "constructor" because the assignment operator takes
+ // 's' by value and attempts to copy construct it.
+ s2 = s; // expected-error {{no matching constructor for initialization}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
index aa4fdb8a96b1..05a057f9bb32 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
@@ -14,43 +14,20 @@
// Test unique_ptr move assignment
#include <memory>
-#include <cassert>
-// Can't copy from lvalue
+#include "test_macros.h"
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
-public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p) {delete p;}
+struct Deleter {
+ void operator()(int* p) {delete p;}
};
+// Can't copy from lvalue
int main()
{
- {
- std::unique_ptr<A, Deleter> s(new A);
- A* p = s.get();
- std::unique_ptr<A, Deleter> s2;
- s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- }
- assert(A::count == 0);
+ std::unique_ptr<int, Deleter> s, s2;
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
+ s2 = s; // expected-error {{'operator=' is a private member}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
index e0d7c891c80f..24703ec98238 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
@@ -11,46 +11,26 @@
// unique_ptr
-// Test unique_ptr move ctor
+// Test unique_ptr move assignment
#include <memory>
-#include <cassert>
-// test move ctor. Can't copy from const lvalue
+#include "test_macros.h"
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
-public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p) {delete p;}
+struct Deleter {
+ void operator()(int* p) {delete p;}
};
+// Can't copy from a const lvalue
int main()
{
- {
- const std::unique_ptr<A, Deleter> s(new A);
- A* p = s.get();
- std::unique_ptr<A, Deleter> s2;
- s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- }
- assert(A::count == 0);
+ const std::unique_ptr<int, Deleter> s(new int);
+ std::unique_ptr<int, Deleter> s2;
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}}
+#else
+ // NOTE: The error says "constructor" because the assignment operator takes
+ // 's' by value and attempts to copy construct it.
+ s2 = s; // expected-error {{no matching constructor for initialization}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp
new file mode 100644
index 000000000000..4c4a32035641
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+
+template <class APtr, class BPtr>
+void testAssign(APtr& aptr, BPtr& bptr) {
+ A* p = bptr.get();
+ assert(A::count == 2);
+ aptr = std::move(bptr);
+ assert(aptr.get() == p);
+ assert(bptr.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+}
+
+template <class LHS, class RHS>
+void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) {
+ assert(lhs.get_deleter().state() == LHSState);
+ assert(rhs.get_deleter().state() == RHSState);
+}
+
+int main()
+{
+ {
+ std::unique_ptr<B> bptr(new B);
+ std::unique_ptr<A> aptr(new A);
+ testAssign(aptr, bptr);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ Deleter<B> del(42);
+ std::unique_ptr<B, Deleter<B> > bptr(new B, std::move(del));
+ std::unique_ptr<A, Deleter<A> > aptr(new A);
+ testAssign(aptr, bptr);
+ checkDeleter(aptr, bptr, 42, 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ CDeleter<A> adel(6);
+ CDeleter<B> bdel(42);
+ std::unique_ptr<B, CDeleter<B>&> bptr(new B, bdel);
+ std::unique_ptr<A, CDeleter<A>&> aptr(new A, adel);
+ testAssign(aptr, bptr);
+ checkDeleter(aptr, bptr, 42, 42);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
index 3fd2cbc42bd6..816a598d9a23 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
@@ -14,44 +14,29 @@
// Test unique_ptr converting move assignment
#include <memory>
-#include <utility>
-#include <cassert>
-// Can't assign from lvalue
+#include "test_macros.h"
struct A
{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
+ A() {}
+ virtual ~A() {}
};
-int A::count = 0;
-
-struct B
- : public A
+struct B : public A
{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
};
-int B::count = 0;
-
+// Can't assign from lvalue
int main()
{
- {
- std::unique_ptr<B> s(new B);
- A* p = s.get();
+ std::unique_ptr<B> s;
std::unique_ptr<A> s2;
- s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- }
- assert(A::count == 0);
- assert(B::count == 0);
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{no viable overloaded '='}}
+#else
+ // NOTE: The move-semantic emulation creates an ambiguous overload set
+ // so that assignment from an lvalue does not compile
+ s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
deleted file mode 100644
index 989f594e38b8..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move assignment
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- std::unique_ptr<B> s(new B);
- A* p = s.get();
- std::unique_ptr<A> s2(new A);
- assert(A::count == 2);
- s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
index 0f900603e239..1ddf1d811651 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
@@ -14,48 +14,30 @@
// Test unique_ptr converting move assignment
#include <memory>
-#include <utility>
-#include <cassert>
+#include "test_macros.h"
#include "../../deleter.h"
-// Can't assign from lvalue
-
struct A
{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
+ A() {}
+ virtual ~A() {}
};
-int A::count = 0;
-
-struct B
- : public A
+struct B : public A
{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
};
-int B::count = 0;
-
+// Can't assign from lvalue
int main()
{
- {
- std::unique_ptr<B, Deleter<B> > s(new B);
- A* p = s.get();
+ std::unique_ptr<B, Deleter<B> > s;
std::unique_ptr<A, Deleter<A> > s2;
- s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- assert(B::count == 0);
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{no viable overloaded '='}}
+#else
+ // NOTE: The move-semantic emulation creates an ambiguous overload set
+ // so that assignment from an lvalue does not compile
+ s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
deleted file mode 100644
index a448c77a66a7..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move assignment
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-#include "../../deleter.h"
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
- A* p = s.get();
- std::unique_ptr<A, Deleter<A> > s2(new A);
- assert(A::count == 2);
- s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
index f35af9f453ff..570c1c42f4fe 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
@@ -16,47 +16,32 @@
// Can't assign from lvalue
#include <memory>
-#include <utility>
-#include <cassert>
+#include "test_macros.h"
#include "../../deleter.h"
struct A
{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
+ A() {}
+ virtual ~A() {}
};
-int A::count = 0;
-
-struct B
- : public A
+struct B : public A
{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
};
-int B::count = 0;
-
+// Can't assign from lvalue
int main()
{
- {
- Deleter<B> db(5);
- std::unique_ptr<B, Deleter<B>&> s(new B, db);
- A* p = s.get();
- Deleter<A> da(6);
- std::unique_ptr<A, Deleter<A>&> s2(new A, da);
- s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- }
- assert(A::count == 0);
- assert(B::count == 0);
+ Deleter<B> db;
+ std::unique_ptr<B, Deleter<B>& > s(new B, db);
+ Deleter<A> da;
+ std::unique_ptr<A, Deleter<A> &> s2(new A, da);
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{no viable overloaded '='}}
+#else
+ // NOTE: The move-semantic emulation creates an ambiguous overload set
+ // so that assignment from an lvalue does not compile
+ s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
deleted file mode 100644
index 9aea81a8b144..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move assignment
-
-// test converting move assignment with reference deleters
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-#include "../../deleter.h"
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- CDeleter<B> db(5);
- std::unique_ptr<B, CDeleter<B>&> s(new B, db);
- A* p = s.get();
- CDeleter<A> da(6);
- std::unique_ptr<A, CDeleter<A>&> s2(new A, da);
- s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s.get_deleter().state() == 5);
- assert(s2.get_deleter().state() == 5);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
index dba901b2ce17..2ebc33d21d81 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
@@ -14,44 +14,30 @@
// Test unique_ptr converting move assignment
#include <memory>
-#include <utility>
-#include <cassert>
-// Can't assign from const lvalue
+#include "test_macros.h"
+#include "../../deleter.h"
struct A
{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
+ A() {}
+ virtual ~A() {}
};
-int A::count = 0;
-
-struct B
- : public A
+struct B : public A
{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
};
-int B::count = 0;
-
+// Can't assign from lvalue
int main()
{
- {
const std::unique_ptr<B> s(new B);
- A* p = s.get();
std::unique_ptr<A> s2;
- s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- }
- assert(A::count == 0);
- assert(B::count == 0);
+#if TEST_STD_VER >= 11
+ s2 = s; // expected-error {{no viable overloaded '='}}
+#else
+ // NOTE: The error says "constructor" because the assignment operator takes
+ // 's' by value and attempts to copy construct it.
+ s2 = s; // expected-error {{no matching constructor for initialization}}
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
index 56ab43c7de24..412648420d46 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
@@ -32,5 +32,5 @@ int main()
{
std::unique_ptr<A[], Deleter> s;
std::unique_ptr<A, Deleter> s2;
- s2 = std::move(s);
+ s2 = std::move(s); // expected-error {{no viable overloaded '='}}
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
index 1ce1838afbb7..7c3ac462c287 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
@@ -7,17 +7,21 @@
//
//===----------------------------------------------------------------------===//
+// libc++ cannot safely provide the auto_ptr constructor without rvalue
+// references.
+// XFAIL: c++98, c++03
+
// <memory>
// unique_ptr
-// Test unique_ptr(pointer) ctor
+// template <class U> unique_ptr(auto_ptr<U>&&) noexcept
#include <memory>
#include <utility>
#include <cassert>
-// template <class U> explicit unique_ptr(auto_ptr<U>&);
+#include "test_macros.h"
struct A
{
@@ -65,4 +69,12 @@ int main()
}
assert(A::count == 0);
assert(B::count == 0);
+#if TEST_STD_VER >= 11
+ {
+ static_assert(std::is_nothrow_constructible<
+ std::unique_ptr<A>,
+ std::auto_ptr<B>&&
+ >::value, "");
+ }
+#endif
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp
new file mode 100644
index 000000000000..2694538145b9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+//=============================================================================
+// TESTING std::unique_ptr::unique_ptr()
+//
+// Concerns:
+// 1 The default constructor works for any default constructible deleter types.
+// 2 The stored type 'T' is allowed to be incomplete.
+//
+// Plan
+// 1 Default construct unique_ptr's with various deleter types (C-1)
+// 2 Default construct a unique_ptr with a incomplete element_type and
+// various deleter types (C-1,2)
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct IncompleteT;
+
+void checkNumIncompleteTypeAlive(int i);
+
+template <class Del = std::default_delete<IncompleteT> >
+struct StoresIncomplete {
+ std::unique_ptr<IncompleteT, Del> m_ptr;
+ StoresIncomplete() {}
+ ~StoresIncomplete();
+
+ IncompleteT* get() const { return m_ptr.get(); }
+ Del& get_deleter() { return m_ptr.get_deleter(); }
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int> p;
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int, NCDeleter<int> > p;
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 0);
+ p.get_deleter().set_state(5);
+ assert(p.get_deleter().state() == 5);
+ }
+ {
+ StoresIncomplete<> s;
+ assert(s.get() == 0);
+ checkNumIncompleteTypeAlive(0);
+ }
+ checkNumIncompleteTypeAlive(0);
+ {
+ StoresIncomplete< Deleter<IncompleteT> > s;
+ assert(s.get() == 0);
+ assert(s.get_deleter().state() == 0);
+ checkNumIncompleteTypeAlive(0);
+ }
+ checkNumIncompleteTypeAlive(0);
+}
+
+struct IncompleteT {
+ static int count;
+ IncompleteT() { ++count; }
+ ~IncompleteT() {--count; }
+};
+
+int IncompleteT::count = 0;
+
+void checkNumIncompleteTypeAlive(int i) {
+ assert(IncompleteT::count == i);
+}
+
+template <class Del>
+StoresIncomplete<Del>::~StoresIncomplete() { } \ No newline at end of file
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
deleted file mode 100644
index e63db5cb7185..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr default ctor
-
-#include <memory>
-#include <cassert>
-
-// default unique_ptr ctor should only require default Deleter ctor
-class Deleter
-{
- int state_;
-
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-
-public:
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(void*) {}
-};
-
-int main()
-{
- {
- std::unique_ptr<int> p;
- assert(p.get() == 0);
- }
- {
- std::unique_ptr<int, Deleter> p;
- assert(p.get() == 0);
- assert(p.get_deleter().state() == 5);
- }
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
deleted file mode 100644
index e9af7e285255..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test default unique_ptr ctor
-
-#include <memory>
-#include <cassert>
-
-// default unique_ptr ctor shouldn't require complete type
-
-struct A;
-
-class Deleter
-{
- int state_;
-
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-
-public:
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p);
-};
-
-void check(int i);
-
-template <class D = std::default_delete<A> >
-struct B
-{
- std::unique_ptr<A, D> a_;
- B() {}
- ~B();
-
- A* get() const {return a_.get();}
- D& get_deleter() {return a_.get_deleter();}
-};
-
-int main()
-{
- {
- B<> s;
- assert(s.get() == 0);
- }
- check(0);
- {
- B<Deleter> s;
- assert(s.get() == 0);
- assert(s.get_deleter().state() == 5);
- }
- check(0);
-}
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-void Deleter::operator()(A* p) {delete p;}
-
-void check(int i)
-{
- assert(A::count == i);
-}
-
-template <class D>
-B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp
new file mode 100644
index 000000000000..4c5cc843a138
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+//=============================================================================
+// TESTING unique_ptr(unique_ptr&&)
+//
+// Concerns
+// 1 The moved from pointer is empty and the new pointer stores the old value.
+// 2 The only requirement on the deleter is that it is MoveConstructible
+// or a reference.
+// 3 The constructor works for explicitly moved values (ie std::move(x))
+// 4 The constructor works for true temporaries (ie a return value)
+//
+// Plan
+// 1 Explicitly construct unique_ptr<T, D> for various deleter types 'D'.
+// check that the value and deleter have been properly moved. (C-1,2,3)
+//
+// 2 Use the expression 'sink(source())' to move construct a unique_ptr<T, D>
+// from a temporary. 'source' should return the unique_ptr by value and
+// 'sink' should accept the unique_ptr by value. (C-1,2,4)
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class Expect>
+void sinkFunction(Expect)
+{
+}
+
+typedef std::unique_ptr<A> APtrSource1;
+typedef std::unique_ptr<A, Deleter<A> > APtrSource2;
+typedef std::unique_ptr<A, NCDeleter<A>& > APtrSource3;
+
+APtrSource1 source1() {
+ return APtrSource1 (new A);
+}
+
+void sink1(APtrSource1 p) {
+ assert(p.get() != nullptr);
+}
+
+APtrSource2 source2() {
+ return APtrSource2(new A, Deleter<A>(5));
+}
+
+void sink2(APtrSource2 p) {
+ assert(p.get() != nullptr);
+ assert(p.get_deleter().state() == 5);
+}
+
+APtrSource3 source3() {
+ static NCDeleter<A> d(5);
+ return APtrSource3(new A, d);
+}
+
+void sink3(APtrSource3 p) {
+ assert(p.get() != nullptr);
+ assert(p.get_deleter().state() == 5);
+ assert(&p.get_deleter() == &source3().get_deleter());
+}
+
+int main()
+{
+ {
+ typedef std::unique_ptr<A> APtr;
+ APtr s(new A);
+ A* p = s.get();
+ APtr s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ typedef Deleter<A> MoveDel;
+ typedef std::unique_ptr<A, MoveDel> APtr;
+ MoveDel d(5);
+ APtr s(new A, std::move(d));
+ assert(d.state() == 0);
+ assert(s.get_deleter().state() == 5);
+ A* p = s.get();
+ APtr s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ typedef NCDeleter<A> NonCopyDel;
+ typedef std::unique_ptr<A, NonCopyDel&> APtr;
+
+ NonCopyDel d;
+ APtr s(new A, d);
+ A* p = s.get();
+ APtr s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ {
+ sink1(source1());
+ assert(A::count == 0);
+ sink2(source2());
+ assert(A::count == 0);
+ sink3(source3());
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
deleted file mode 100644
index dc16c3115376..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-// test move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-template <class T>
-class Deleter
-{
- int state_;
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(const Deleter&);
- Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
- Deleter& operator=(Deleter&& r)
- {
- state_ = r.state_;
- r.state_ = 0;
- return *this;
- }
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
- return *this;
- }
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
- Deleter() : state_(5) {}
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U>&& d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {d.set_state(0);}
-
-private:
- template <class U>
- Deleter(const Deleter<U>& d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U> d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-public:
- int state() const {return state_;}
- void set_state(int i) {state_ = i;}
-
- void operator()(T* p) {delete p;}
-};
-
-class CDeleter
-{
- int state_;
-
- CDeleter(CDeleter&);
- CDeleter& operator=(CDeleter&);
-public:
-
- CDeleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) {delete p;}
-};
-
-int main()
-{
- {
- std::unique_ptr<A> s(new A);
- A* p = s.get();
- std::unique_ptr<A> s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- }
- assert(A::count == 0);
- {
- std::unique_ptr<A, Deleter<A> > s(new A);
- A* p = s.get();
- std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- {
- CDeleter d;
- std::unique_ptr<A, CDeleter&> s(new A, d);
- A* p = s.get();
- std::unique_ptr<A, CDeleter&> s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- d.set_state(6);
- assert(s2.get_deleter().state() == d.state());
- assert(s.get_deleter().state() == d.state());
- }
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
deleted file mode 100644
index 4b997df95a0b..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr move ctor
-
-#include <memory>
-#include <cassert>
-
-// test move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-template <class T>
-class Deleter
-{
- int state_;
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(const Deleter&);
- Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
- Deleter& operator=(Deleter&& r)
- {
- state_ = r.state_;
- r.state_ = 0;
- return *this;
- }
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
- return *this;
- }
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
- Deleter() : state_(5) {}
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U>&& d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {d.set_state(0);}
-
-private:
- template <class U>
- Deleter(const Deleter<U>& d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U> d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-public:
- int state() const {return state_;}
- void set_state(int i) {state_ = i;}
-
- void operator()(T* p) {delete p;}
-};
-
-class CDeleter
-{
- int state_;
-
- CDeleter(CDeleter&);
- CDeleter& operator=(CDeleter&);
-public:
-
- CDeleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) {delete p;}
-};
-
-std::unique_ptr<A>
-source1()
-{
- return std::unique_ptr<A>(new A);
-}
-
-void sink1(std::unique_ptr<A> p)
-{
-}
-
-std::unique_ptr<A, Deleter<A> >
-source2()
-{
- return std::unique_ptr<A, Deleter<A> >(new A);
-}
-
-void sink2(std::unique_ptr<A, Deleter<A> > p)
-{
-}
-
-std::unique_ptr<A, CDeleter&>
-source3()
-{
- static CDeleter d;
- return std::unique_ptr<A, CDeleter&>(new A, d);
-}
-
-void sink3(std::unique_ptr<A, CDeleter&> p)
-{
-}
-
-int main()
-{
- sink1(source1());
- sink2(source2());
- sink3(source3());
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp
new file mode 100644
index 000000000000..f00fcfe15b80
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// NOTE: unique_ptr does not provide converting constructors in c++03
+// XFAIL: c++98, c++03
+
+
+
+#include <memory>
+#include <type_traits>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+
+template <class LHS, class RHS>
+void checkReferenceDeleter(LHS& lhs, RHS& rhs) {
+ typedef typename LHS::deleter_type NewDel;
+ static_assert(std::is_reference<NewDel>::value, "");
+ rhs.get_deleter().set_state(42);
+ assert(rhs.get_deleter().state() == 42);
+ assert(lhs.get_deleter().state() == 42);
+ lhs.get_deleter().set_state(99);
+ assert(lhs.get_deleter().state() == 99);
+ assert(rhs.get_deleter().state() == 99);
+}
+
+template <class LHS, class RHS>
+void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) {
+ assert(lhs.get_deleter().state() == LHSVal);
+ assert(rhs.get_deleter().state() == RHSVal);
+}
+
+template <class LHS, class RHS>
+void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) {
+ assert(lhs.get() == RHSVal);
+ assert(rhs.get() == nullptr);
+ assert(A::count == 1);
+ assert(B::count == 1);
+}
+
+void checkNoneAlive() {
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+int main()
+{
+ {
+ typedef std::unique_ptr<A> APtr;
+ typedef std::unique_ptr<B> BPtr;
+ { // explicit
+ BPtr b(new B);
+ A* p = b.get();
+ APtr a(std::move(b));
+ checkCtor(a, b, p);
+ }
+ checkNoneAlive();
+ { // implicit
+ BPtr b(new B);
+ A* p = b.get();
+ APtr a = std::move(b);
+ checkCtor(a, b, p);
+ }
+ checkNoneAlive();
+ }
+ { // test with moveable deleters
+ typedef std::unique_ptr<A, Deleter<A> > APtr;
+ typedef std::unique_ptr<B, Deleter<B> > BPtr;
+ {
+ Deleter<B> del(5);
+ BPtr b(new B, std::move(del));
+ A* p = b.get();
+ APtr a(std::move(b));
+ checkCtor(a, b, p);
+ checkDeleter(a, b, 5, 0);
+ }
+ checkNoneAlive();
+ {
+ Deleter<B> del(5);
+ BPtr b(new B, std::move(del));
+ A* p = b.get();
+ APtr a = std::move(b);
+ checkCtor(a, b, p);
+ checkDeleter(a, b, 5, 0);
+ }
+ checkNoneAlive();
+
+ }
+ { // test with reference deleters
+ typedef std::unique_ptr<A, NCDeleter<A>& > APtr;
+ typedef std::unique_ptr<B, NCDeleter<A>& > BPtr;
+ NCDeleter<A> del(5);
+ {
+ BPtr b(new B, del);
+ A* p = b.get();
+ APtr a(std::move(b));
+ checkCtor(a, b, p);
+ checkReferenceDeleter(a, b);
+ }
+ checkNoneAlive();
+ {
+ BPtr b(new B, del);
+ A* p = b.get();
+ APtr a = std::move(b);
+ checkCtor(a, b, p);
+ checkReferenceDeleter(a, b);
+ }
+ checkNoneAlive();
+ }
+ {
+ typedef std::unique_ptr<A, CDeleter<A> > APtr;
+ typedef std::unique_ptr<B, CDeleter<B>& > BPtr;
+ CDeleter<B> del(5);
+ {
+ BPtr b(new B, del);
+ A* p = b.get();
+ APtr a(std::move(b));
+ checkCtor(a, b, p);
+ checkDeleter(a, b, 5, 5);
+ }
+ checkNoneAlive();
+ {
+ BPtr b(new B, del);
+ A* p = b.get();
+ APtr a = std::move(b);
+ checkCtor(a, b, p);
+ checkDeleter(a, b, 5, 5);
+ }
+ checkNoneAlive();
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
deleted file mode 100644
index b65cf564a925..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// Explicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- std::unique_ptr<B> s(new B);
- A* p = s.get();
- std::unique_ptr<A> s2(std::move(s));
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
deleted file mode 100644
index 829e7553acd9..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-#include "../../deleter.h"
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// Explicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
- A* p = s.get();
- std::unique_ptr<A, Deleter<A> > s2(std::move(s));
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
deleted file mode 100644
index 792076a95245..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// Explicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-template <class T>
-class CDeleter
-{
- int state_;
-
- CDeleter(CDeleter&);
- CDeleter& operator=(CDeleter&);
-public:
-
- CDeleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(T* p) {delete p;}
-};
-
-int main()
-{
- {
- CDeleter<A> d;
- std::unique_ptr<B, CDeleter<A>&> s(new B, d);
- A* p = s.get();
- std::unique_ptr<A, CDeleter<A>&> s2(std::move(s));
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- d.set_state(6);
- assert(s2.get_deleter().state() == d.state());
- assert(s.get_deleter().state() == d.state());
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
deleted file mode 100644
index 12ab17fadcd3..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// implicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- std::unique_ptr<B> s(new B);
- A* p = s.get();
- std::unique_ptr<A> s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
deleted file mode 100644
index 8077b0dacb23..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-#include "../../deleter.h"
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// Implicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
- A* p = s.get();
- std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
deleted file mode 100644
index 4115107b85f9..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// Explicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-template <class T>
-class CDeleter
-{
- int state_;
-
- CDeleter(CDeleter&);
- CDeleter& operator=(CDeleter&);
-public:
-
- CDeleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(T* p) {delete p;}
-};
-
-int main()
-{
- {
- CDeleter<A> d;
- std::unique_ptr<B, CDeleter<A>&> s(new B, d);
- A* p = s.get();
- std::unique_ptr<A, CDeleter<A>&> s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- d.set_state(6);
- assert(s2.get_deleter().state() == d.state());
- assert(s.get_deleter().state() == d.state());
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
deleted file mode 100644
index 978cb0e9024b..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr converting move ctor
-
-#include <memory>
-#include <utility>
-#include <cassert>
-
-#include "../../deleter.h"
-
-// test converting move ctor. Should only require a MoveConstructible deleter, or if
-// deleter is a reference, not even that.
-// Implicit version
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-int main()
-{
- {
- CDeleter<B> b(5);
- std::unique_ptr<B, CDeleter<B>&> s(new B, b);
- A* p = s.get();
- std::unique_ptr<A, CDeleter<A> > s2 = std::move(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp
new file mode 100644
index 000000000000..faa554d8b320
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+//=============================================================================
+// TESTING std::unique_ptr::unique_ptr()
+//
+// Concerns:
+// 1 The pointer constructor works for any default constructible deleter types.
+// 2 The pointer constructor accepts pointers to derived types.
+// 2 The stored type 'T' is allowed to be incomplete.
+//
+// Plan
+// 1 Construct unique_ptr<T, D>'s with a pointer to 'T' and various deleter
+// types (C-1)
+// 2 Construct unique_ptr<T, D>'s with a pointer to 'D' and various deleter
+// types where 'D' is derived from 'T'. (C-1,2)
+// 3 Construct a unique_ptr<T, D> with a pointer to 'T' and various deleter
+// types where 'T' is an incomplete type (C-1,3)
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// unique_ptr(pointer) ctor should only require default Deleter ctor
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+
+struct IncompleteT;
+
+IncompleteT* getIncomplete();
+void checkNumIncompleteTypeAlive(int i);
+
+template <class Del = std::default_delete<IncompleteT> >
+struct StoresIncomplete {
+ std::unique_ptr<IncompleteT, Del> m_ptr;
+ StoresIncomplete() {}
+ explicit StoresIncomplete(IncompleteT* ptr) : m_ptr(ptr) {}
+ ~StoresIncomplete();
+
+ IncompleteT* get() const { return m_ptr.get(); }
+ Del& get_deleter() { return m_ptr.get_deleter(); }
+};
+
+void test_pointer()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, NCDeleter<A> > s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+}
+
+void test_derived()
+{
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A, NCDeleter<A> > s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
+
+void test_incomplete()
+{
+ {
+ IncompleteT* p = getIncomplete();
+ checkNumIncompleteTypeAlive(1);
+ StoresIncomplete<> s(p);
+ assert(s.get() == p);
+ }
+ checkNumIncompleteTypeAlive(0);
+ {
+ IncompleteT* p = getIncomplete();
+ checkNumIncompleteTypeAlive(1);
+ StoresIncomplete< NCDeleter<IncompleteT> > s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 0);
+ }
+ checkNumIncompleteTypeAlive(0);
+}
+
+struct IncompleteT {
+ static int count;
+ IncompleteT() { ++count; }
+ ~IncompleteT() {--count; }
+};
+
+int IncompleteT::count = 0;
+
+IncompleteT* getIncomplete() {
+ return new IncompleteT;
+}
+
+void checkNumIncompleteTypeAlive(int i) {
+ assert(IncompleteT::count == i);
+}
+
+template <class Del>
+StoresIncomplete<Del>::~StoresIncomplete() { }
+
+int main()
+{
+ test_pointer();
+ test_derived();
+ test_incomplete();
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
deleted file mode 100644
index e5fff774b790..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer) ctor should only require default Deleter ctor
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-
-public:
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p) {delete p;}
-};
-
-int main()
-{
- {
- A* p = new A;
- assert(A::count == 1);
- std::unique_ptr<A> s(p);
- assert(s.get() == p);
- }
- assert(A::count == 0);
- {
- A* p = new A;
- assert(A::count == 1);
- std::unique_ptr<A, Deleter> s(p);
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
deleted file mode 100644
index a226e87d64a4..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer) ctor shouldn't require complete type
-
-struct A;
-
-class Deleter
-{
- int state_;
-
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-
-public:
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p);
-};
-
-void check(int i);
-
-template <class D = std::default_delete<A> >
-struct B
-{
- std::unique_ptr<A, D> a_;
- explicit B(A*);
- ~B();
-
- A* get() const {return a_.get();}
- D& get_deleter() {return a_.get_deleter();}
-};
-
-A* get();
-
-int main()
-{
- {
- A* p = get();
- check(1);
- B<> s(p);
- assert(s.get() == p);
- }
- check(0);
- {
- A* p = get();
- check(1);
- B<Deleter> s(p);
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- check(0);
-}
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-A* get() {return new A;}
-
-void Deleter::operator()(A* p) {delete p;}
-
-void check(int i)
-{
- assert(A::count == i);
-}
-
-template <class D>
-B<D>::B(A* a) : a_(a) {}
-
-template <class D>
-B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
deleted file mode 100644
index 42fc09453914..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer) ctor should work with derived pointers
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-class Deleter
-{
- int state_;
-
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-
-public:
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p) {delete p;}
-};
-
-int main()
-{
- {
- B* p = new B;
- assert(A::count == 1);
- assert(B::count == 1);
- std::unique_ptr<A> s(p);
- assert(s.get() == p);
- }
- assert(A::count == 0);
- assert(B::count == 0);
- {
- B* p = new B;
- assert(A::count == 1);
- assert(B::count == 1);
- std::unique_ptr<A, Deleter> s(p);
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp
new file mode 100644
index 000000000000..7ddd16265107
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+//=============================================================================
+// TESTING unique_ptr(pointer, deleter)
+//
+// Concerns:
+// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter.
+// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter.
+// 3 unique_ptr<T, D&>(pointer, deleter) does not require a CopyConstructible deleter.
+// 4 unique_ptr<T, D const&>(pointer, deleter) does not require a CopyConstructible deleter.
+// 5 unique_ptr(pointer, deleter) should work for derived pointers.
+// 6 unique_ptr(pointer, deleter) should work with function pointers.
+// 7 unique_ptr<void> should work.
+
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+bool my_free_called = false;
+
+void my_free(void*) {
+ my_free_called = true;
+}
+
+int main()
+{
+ { // MoveConstructible deleter (C-1)
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5));
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ { // CopyConstructible deleter (C-2)
+ A* p = new A;
+ assert(A::count == 1);
+ CopyDeleter<A> d(5);
+ std::unique_ptr<A, CopyDeleter<A> > s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ { // Reference deleter (C-3)
+ A* p = new A;
+ assert(A::count == 1);
+ NCDeleter<A> d(5);
+ std::unique_ptr<A, NCDeleter<A>&> s(p, d);
+ assert(s.get() == p);
+ assert(&s.get_deleter() == &d);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 6);
+ }
+ assert(A::count == 0);
+ { // Const Reference deleter (C-4)
+ A* p = new A;
+ assert(A::count == 1);
+ NCConstDeleter<A> d(5);
+ std::unique_ptr<A, NCConstDeleter<A> const&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ assert(&s.get_deleter() == &d);
+ }
+ assert(A::count == 0);
+ { // Derived pointers (C-5)
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5));
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ { // Void and function pointers (C-6,7)
+ {
+ int i = 0;
+ std::unique_ptr<void, void(*)(void*)> s(&i, my_free);
+ assert(s.get() == &i);
+ assert(s.get_deleter() == my_free);
+ assert(!my_free_called);
+ }
+ assert(my_free_called);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
deleted file mode 100644
index 130f91d6216f..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-template <class T>
-class Deleter
-{
- int state_;
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(const Deleter&);
- Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
- Deleter& operator=(Deleter&& r)
- {
- state_ = r.state_;
- r.state_ = 0;
- return *this;
- }
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
- return *this;
- }
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
- Deleter() : state_(5) {}
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U>&& d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {d.set_state(0);}
-
-private:
- template <class U>
- Deleter(const Deleter<U>& d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U> d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-public:
- int state() const {return state_;}
- void set_state(int i) {state_ = i;}
-
- void operator()(T* p) {delete p;}
-};
-
-int main()
-{
- {
- A* p = new A;
- assert(A::count == 1);
- std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>());
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
deleted file mode 100644
index 421bec55f99c..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer, d) requires CopyConstructible deleter
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
-public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) {delete p;}
-};
-
-int main()
-{
- {
- A* p = new A;
- assert(A::count == 1);
- Deleter d;
- std::unique_ptr<A, Deleter> s(p, d);
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- d.set_state(6);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
deleted file mode 100644
index bce79dbb1a97..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
- Deleter(const Deleter&);
- Deleter& operator=(const Deleter&);
-public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) {delete p;}
-};
-
-int main()
-{
- {
- A* p = new A;
- assert(A::count == 1);
- Deleter d;
- std::unique_ptr<A, Deleter&> s(p, d);
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- d.set_state(6);
- assert(s.get_deleter().state() == 6);
- }
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
index 7cacd1fda9f3..ad64b5e4ea39 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
@@ -7,49 +7,24 @@
//
//===----------------------------------------------------------------------===//
+// Without rvalue references it is impossible to detect when a rvalue deleter
+// is given.
+// XFAIL: c++98, c++03
+
// <memory>
// unique_ptr
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
// unique_ptr<T, const D&>(pointer, D()) should not compile
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
-public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
+#include <memory>
- void operator()(A* p) const {delete p;}
+struct Deleter {
+ void operator()(int* p) const {delete p;}
};
int main()
{
- {
- A* p = new A;
- assert(A::count == 1);
- std::unique_ptr<A, const Deleter&> s(p, Deleter());
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
+ // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}}
+ std::unique_ptr<int, const Deleter&> s((int*)nullptr, Deleter()); // expected-note {{requested here}}
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
deleted file mode 100644
index a7750fcb9f0f..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- ~A() {--count;}
-};
-
-int A::count = 0;
-
-class Deleter
-{
- int state_;
-
- Deleter(const Deleter&);
- Deleter& operator=(const Deleter&);
-public:
-
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
- void set_state(int s) {state_ = s;}
-
- void operator()(A* p) const {delete p;}
-};
-
-int main()
-{
- {
- A* p = new A;
- assert(A::count == 1);
- Deleter d;
- std::unique_ptr<A, const Deleter&> s(p, d);
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
deleted file mode 100644
index 1a83258e1e41..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer, deleter) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer, deleter) should work with derived pointers
-
-struct A
-{
- static int count;
- A() {++count;}
- A(const A&) {++count;}
- virtual ~A() {--count;}
-};
-
-int A::count = 0;
-
-struct B
- : public A
-{
- static int count;
- B() {++count;}
- B(const B&) {++count;}
- virtual ~B() {--count;}
-};
-
-int B::count = 0;
-
-class Deleter
-{
- int state_;
-
-public:
- Deleter() : state_(5) {}
-
- int state() const {return state_;}
-
- void operator()(A* p) {delete p;}
-};
-
-int main()
-{
- {
- B* p = new B;
- assert(A::count == 1);
- assert(B::count == 1);
- std::unique_ptr<A, Deleter> s(p, Deleter());
- assert(s.get() == p);
- assert(s.get_deleter().state() == 5);
- }
- assert(A::count == 0);
- assert(B::count == 0);
-}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
deleted file mode 100644
index ed68052cd3bb..000000000000
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// unique_ptr
-
-// Test unique_ptr(pointer, deleter) ctor
-
-#include <memory>
-#include <cassert>
-
-// unique_ptr(pointer, deleter) should work with function pointers
-// unique_ptr<void> should work
-
-bool my_free_called = false;
-
-void my_free(void*)
-{
- my_free_called = true;
-}
-
-int main()
-{
- {
- int i = 0;
- std::unique_ptr<void, void (*)(void*)> s(&i, my_free);
- assert(s.get() == &i);
- assert(s.get_deleter() == my_free);
- assert(!my_free_called);
- }
- assert(my_free_called);
-}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
index b2e61faff5ed..f17485108b92 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template<class Y> explicit shared_ptr(auto_ptr<Y>&& r);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
index ab2c73e0c5f1..41aeb04a5feb 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
index 97d3f69fb5c4..6a79a8ef60db 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// shared_ptr
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
index 4220993a5fd1..c72847791778 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
index ead081645671..982313b07499 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// shared_ptr
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
index 041fe9a7853d..2e761d70bba0 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template<class Y> explicit shared_ptr(Y* p);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
index 5e09d9a7934c..c62fcd689320 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// template <class Y, class D> explicit shared_ptr(unique_ptr<Y, D>&&r);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
index a9d8aff145a7..35a7d077b424 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <memory>
// shared_ptr
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
index d091ae99fc27..bf1719c66ffa 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
@@ -30,9 +30,28 @@
// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
// };
+//
+// Added in C++17
+// template<> struct owner_less<void>
+// {
+// template<class T, class U>
+// bool operator()(shared_ptr<T> const&, shared_ptr<U> const&) const;
+// template<class T, class U>
+// bool operator()(shared_ptr<T> const&, weak_ptr<U> const&) const;
+// template<class T, class U>
+// bool operator()(weak_ptr<T> const&, shared_ptr<U> const&) const;
+// template<class T, class U>
+// bool operator()(weak_ptr<T> const&, weak_ptr<U> const&) const;
+//
+// typedef unspecified is_transparent;
+// };
#include <memory>
#include <cassert>
+#include <set>
+#include "test_macros.h"
+
+struct X {};
int main()
{
@@ -79,4 +98,25 @@ int main()
assert(cs(w1, p3) || cs(w3, p1));
assert(cs(w3, p1) == cs(w3, p2));
}
+#if TEST_STD_VER > 14
+ {
+ std::shared_ptr<int> sp1;
+ std::shared_ptr<void> sp2;
+ std::shared_ptr<long> sp3;
+ std::weak_ptr<int> wp1;
+
+ std::owner_less<> cmp;
+ cmp(sp1, sp2);
+ cmp(sp1, wp1);
+ cmp(sp1, sp3);
+ cmp(wp1, sp1);
+ cmp(wp1, wp1);
+ }
+ {
+ // test heterogeneous lookups
+ std::set<std::shared_ptr<X>, std::owner_less<>> s;
+ std::shared_ptr<void> vp;
+ s.find(vp);
+ }
+#endif
}
diff --git a/test/std/utilities/meta/meta.logical/conjunction.pass.cpp b/test/std/utilities/meta/meta.logical/conjunction.pass.cpp
new file mode 100644
index 000000000000..dce58ec23725
--- /dev/null
+++ b/test/std/utilities/meta/meta.logical/conjunction.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// type_traits
+
+// template<class... B> struct conjunction; // C++17
+// template<class... B>
+// constexpr bool conjunction_v = conjunction<B...>::value; // C++17
+
+#include <type_traits>
+#include <cassert>
+
+struct True { static constexpr bool value = true; };
+struct False { static constexpr bool value = false; };
+
+int main()
+{
+ static_assert ( std::conjunction<>::value, "" );
+ static_assert ( std::conjunction<std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::false_type>::value, "" );
+
+ static_assert ( std::conjunction_v<>, "" );
+ static_assert ( std::conjunction_v<std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::false_type>, "" );
+
+ static_assert ( std::conjunction<std::true_type, std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::true_type, std::false_type>::value, "" );
+ static_assert (!std::conjunction<std::false_type, std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::false_type, std::false_type>::value, "" );
+
+ static_assert ( std::conjunction_v<std::true_type, std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::true_type, std::false_type>, "" );
+ static_assert (!std::conjunction_v<std::false_type, std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::false_type, std::false_type>, "" );
+
+ static_assert ( std::conjunction<std::true_type, std::true_type, std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::true_type, std::false_type, std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::false_type, std::true_type, std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::false_type, std::false_type, std::true_type >::value, "" );
+ static_assert (!std::conjunction<std::true_type, std::true_type, std::false_type>::value, "" );
+ static_assert (!std::conjunction<std::true_type, std::false_type, std::false_type>::value, "" );
+ static_assert (!std::conjunction<std::false_type, std::true_type, std::false_type>::value, "" );
+ static_assert (!std::conjunction<std::false_type, std::false_type, std::false_type>::value, "" );
+
+ static_assert ( std::conjunction_v<std::true_type, std::true_type, std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::true_type, std::false_type, std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::false_type, std::true_type, std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::false_type, std::false_type, std::true_type >, "" );
+ static_assert (!std::conjunction_v<std::true_type, std::true_type, std::false_type>, "" );
+ static_assert (!std::conjunction_v<std::true_type, std::false_type, std::false_type>, "" );
+ static_assert (!std::conjunction_v<std::false_type, std::true_type, std::false_type>, "" );
+ static_assert (!std::conjunction_v<std::false_type, std::false_type, std::false_type>, "" );
+
+ static_assert ( std::conjunction<True >::value, "" );
+ static_assert (!std::conjunction<False>::value, "" );
+
+ static_assert ( std::conjunction_v<True >, "" );
+ static_assert (!std::conjunction_v<False>, "" );
+}
diff --git a/test/std/utilities/meta/meta.logical/disjunction.pass.cpp b/test/std/utilities/meta/meta.logical/disjunction.pass.cpp
new file mode 100644
index 000000000000..13cd9341b99f
--- /dev/null
+++ b/test/std/utilities/meta/meta.logical/disjunction.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// type_traits
+
+// template<class... B> struct disjunction; // C++17
+// template<class... B>
+// constexpr bool disjunction_v = disjunction<B...>::value; // C++17
+
+#include <type_traits>
+#include <cassert>
+
+struct True { static constexpr bool value = true; };
+struct False { static constexpr bool value = false; };
+
+int main()
+{
+ static_assert (!std::disjunction<>::value, "" );
+ static_assert ( std::disjunction<std::true_type >::value, "" );
+ static_assert (!std::disjunction<std::false_type>::value, "" );
+
+ static_assert (!std::disjunction_v<>, "" );
+ static_assert ( std::disjunction_v<std::true_type >, "" );
+ static_assert (!std::disjunction_v<std::false_type>, "" );
+
+ static_assert ( std::disjunction<std::true_type, std::true_type >::value, "" );
+ static_assert ( std::disjunction<std::true_type, std::false_type>::value, "" );
+ static_assert ( std::disjunction<std::false_type, std::true_type >::value, "" );
+ static_assert (!std::disjunction<std::false_type, std::false_type>::value, "" );
+
+ static_assert ( std::disjunction_v<std::true_type, std::true_type >, "" );
+ static_assert ( std::disjunction_v<std::true_type, std::false_type>, "" );
+ static_assert ( std::disjunction_v<std::false_type, std::true_type >, "" );
+ static_assert (!std::disjunction_v<std::false_type, std::false_type>, "" );
+
+ static_assert ( std::disjunction<std::true_type, std::true_type, std::true_type >::value, "" );
+ static_assert ( std::disjunction<std::true_type, std::false_type, std::true_type >::value, "" );
+ static_assert ( std::disjunction<std::false_type, std::true_type, std::true_type >::value, "" );
+ static_assert ( std::disjunction<std::false_type, std::false_type, std::true_type >::value, "" );
+ static_assert ( std::disjunction<std::true_type, std::true_type, std::false_type>::value, "" );
+ static_assert ( std::disjunction<std::true_type, std::false_type, std::false_type>::value, "" );
+ static_assert ( std::disjunction<std::false_type, std::true_type, std::false_type>::value, "" );
+ static_assert (!std::disjunction<std::false_type, std::false_type, std::false_type>::value, "" );
+
+ static_assert ( std::disjunction_v<std::true_type, std::true_type, std::true_type >, "" );
+ static_assert ( std::disjunction_v<std::true_type, std::false_type, std::true_type >, "" );
+ static_assert ( std::disjunction_v<std::false_type, std::true_type, std::true_type >, "" );
+ static_assert ( std::disjunction_v<std::false_type, std::false_type, std::true_type >, "" );
+ static_assert ( std::disjunction_v<std::true_type, std::true_type, std::false_type>, "" );
+ static_assert ( std::disjunction_v<std::true_type, std::false_type, std::false_type>, "" );
+ static_assert ( std::disjunction_v<std::false_type, std::true_type, std::false_type>, "" );
+ static_assert (!std::disjunction_v<std::false_type, std::false_type, std::false_type>, "" );
+
+ static_assert ( std::disjunction<True >::value, "" );
+ static_assert (!std::disjunction<False>::value, "" );
+
+ static_assert ( std::disjunction_v<True >, "" );
+ static_assert (!std::disjunction_v<False>, "" );
+}
diff --git a/test/std/utilities/meta/meta.logical/negation.pass.cpp b/test/std/utilities/meta/meta.logical/negation.pass.cpp
new file mode 100644
index 000000000000..76ff6c5b24db
--- /dev/null
+++ b/test/std/utilities/meta/meta.logical/negation.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// type_traits
+
+// template<class B> struct negation; // C++17
+// template<class B>
+// constexpr bool negation_v = negation<B>::value; // C++17
+
+#include <type_traits>
+#include <cassert>
+
+struct True { static constexpr bool value = true; };
+struct False { static constexpr bool value = false; };
+
+int main()
+{
+ static_assert (!std::negation<std::true_type >::value, "" );
+ static_assert ( std::negation<std::false_type>::value, "" );
+
+ static_assert (!std::negation_v<std::true_type >, "" );
+ static_assert ( std::negation_v<std::false_type>, "" );
+
+ static_assert (!std::negation<True >::value, "" );
+ static_assert ( std::negation<False>::value, "" );
+
+ static_assert (!std::negation_v<True >, "" );
+ static_assert ( std::negation_v<False>, "" );
+
+ static_assert ( std::negation<std::negation<std::true_type >>::value, "" );
+ static_assert (!std::negation<std::negation<std::false_type>>::value, "" );
+}
diff --git a/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp b/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
index 0f90ae5c1cab..4b17a9f96505 100644
--- a/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
+++ b/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, class U>
void test_is_base_of()
{
@@ -20,6 +22,12 @@ void test_is_base_of()
static_assert((std::is_base_of<const T, U>::value), "");
static_assert((std::is_base_of<T, const U>::value), "");
static_assert((std::is_base_of<const T, const U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((std::is_base_of_v<T, U>), "");
+ static_assert((std::is_base_of_v<const T, U>), "");
+ static_assert((std::is_base_of_v<T, const U>), "");
+ static_assert((std::is_base_of_v<const T, const U>), "");
+#endif
}
template <class T, class U>
diff --git a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
index 429fb33037ff..1681c39972d2 100644
--- a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
+++ b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, class U>
void test_is_convertible()
{
@@ -20,6 +22,12 @@ void test_is_convertible()
static_assert((std::is_convertible<const T, U>::value), "");
static_assert((std::is_convertible<T, const U>::value), "");
static_assert((std::is_convertible<const T, const U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((std::is_convertible_v<T, U>), "");
+ static_assert((std::is_convertible_v<const T, U>), "");
+ static_assert((std::is_convertible_v<T, const U>), "");
+ static_assert((std::is_convertible_v<const T, const U>), "");
+#endif
}
template <class T, class U>
@@ -29,6 +37,12 @@ void test_is_not_convertible()
static_assert((!std::is_convertible<const T, U>::value), "");
static_assert((!std::is_convertible<T, const U>::value), "");
static_assert((!std::is_convertible<const T, const U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_convertible_v<T, U>), "");
+ static_assert((!std::is_convertible_v<const T, U>), "");
+ static_assert((!std::is_convertible_v<T, const U>), "");
+ static_assert((!std::is_convertible_v<const T, const U>), "");
+#endif
}
typedef void Function();
diff --git a/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp
index bd35ef63d08b..5a607f3b12ad 100644
--- a/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp
+++ b/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp
@@ -13,6 +13,14 @@
// Test the fallback implementation.
+// libc++ provides a fallback implementation of the compiler trait
+// `__is_convertible` with the same name when clang doesn't.
+// Because this test forces the use of the fallback even when clang provides
+// it causing a keyword incompatibility.
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wkeyword-compat"
+#endif
+
#define _LIBCPP_USE_IS_CONVERTIBLE_FALLBACK
#include "is_convertible.pass.cpp"
diff --git a/test/std/utilities/meta/meta.rel/is_same.pass.cpp b/test/std/utilities/meta/meta.rel/is_same.pass.cpp
index 7250d6ca7730..9db367391f69 100644
--- a/test/std/utilities/meta/meta.rel/is_same.pass.cpp
+++ b/test/std/utilities/meta/meta.rel/is_same.pass.cpp
@@ -13,13 +13,21 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, class U>
void test_is_same()
{
- static_assert((std::is_same<T, U>::value), "");
+ static_assert(( std::is_same<T, U>::value), "");
static_assert((!std::is_same<const T, U>::value), "");
static_assert((!std::is_same<T, const U>::value), "");
- static_assert((std::is_same<const T, const U>::value), "");
+ static_assert(( std::is_same<const T, const U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_same_v<T, U>), "");
+ static_assert((!std::is_same_v<const T, U>), "");
+ static_assert((!std::is_same_v<T, const U>), "");
+ static_assert(( std::is_same_v<const T, const U>), "");
+#endif
}
template <class T, class U>
@@ -29,6 +37,12 @@ void test_is_same_ref()
static_assert((std::is_same<const T, U>::value), "");
static_assert((std::is_same<T, const U>::value), "");
static_assert((std::is_same<const T, const U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((std::is_same_v<T, U>), "");
+ static_assert((std::is_same_v<const T, U>), "");
+ static_assert((std::is_same_v<T, const U>), "");
+ static_assert((std::is_same_v<const T, const U>), "");
+#endif
}
template <class T, class U>
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
index c87e99c46e80..a53bed984c5e 100644
--- a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
@@ -12,12 +12,14 @@
// aligned_storage
#include <type_traits>
+#include <cstddef> // for std::max_align_t
+#include "test_macros.h"
int main()
{
{
typedef std::aligned_storage<10, 1 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10, 1>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 1, "");
@@ -25,7 +27,7 @@ int main()
}
{
typedef std::aligned_storage<10, 2 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10, 2>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 2, "");
@@ -33,7 +35,7 @@ int main()
}
{
typedef std::aligned_storage<10, 4 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10, 4>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 4, "");
@@ -41,7 +43,7 @@ int main()
}
{
typedef std::aligned_storage<10, 8 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10, 8>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 8, "");
@@ -49,7 +51,7 @@ int main()
}
{
typedef std::aligned_storage<10, 16 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10, 16>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 16, "");
@@ -57,7 +59,7 @@ int main()
}
{
typedef std::aligned_storage<10, 32 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10, 32>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 32, "");
@@ -65,7 +67,7 @@ int main()
}
{
typedef std::aligned_storage<20, 32 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<20, 32>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 32, "");
@@ -73,7 +75,7 @@ int main()
}
{
typedef std::aligned_storage<40, 32 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<40, 32>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 32, "");
@@ -81,7 +83,7 @@ int main()
}
{
typedef std::aligned_storage<12, 16 >::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<12, 16>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 16, "");
@@ -89,7 +91,7 @@ int main()
}
{
typedef std::aligned_storage<1>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<1>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 1, "");
@@ -97,7 +99,7 @@ int main()
}
{
typedef std::aligned_storage<2>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<2>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 2, "");
@@ -105,7 +107,7 @@ int main()
}
{
typedef std::aligned_storage<3>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<3>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 2, "");
@@ -113,7 +115,7 @@ int main()
}
{
typedef std::aligned_storage<4>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<4>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 4, "");
@@ -121,7 +123,7 @@ int main()
}
{
typedef std::aligned_storage<5>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<5>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 4, "");
@@ -129,7 +131,7 @@ int main()
}
{
typedef std::aligned_storage<7>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<7>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 4, "");
@@ -137,7 +139,7 @@ int main()
}
{
typedef std::aligned_storage<8>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<8>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 8, "");
@@ -145,7 +147,7 @@ int main()
}
{
typedef std::aligned_storage<9>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<9>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 8, "");
@@ -153,7 +155,7 @@ int main()
}
{
typedef std::aligned_storage<15>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<15>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 8, "");
@@ -167,7 +169,7 @@ int main()
#endif
{
typedef std::aligned_storage<16>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
@@ -176,7 +178,7 @@ int main()
}
{
typedef std::aligned_storage<17>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
@@ -185,7 +187,7 @@ int main()
}
{
typedef std::aligned_storage<10>::type T1;
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert(std::is_same<std::aligned_storage_t<10>, T1>::value, "" );
#endif
static_assert(std::alignment_of<T1>::value == 8, "");
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
index 91bf7e7654e0..e8611253c5d4 100644
--- a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
+++ b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
@@ -13,11 +13,39 @@
#include <type_traits>
+#include "test_macros.h"
+
+struct E {};
+
+template <class T>
+struct X { explicit X(T const&){} };
+
+template <class T>
+struct S { explicit S(T const&){} };
+
+namespace std
+{
+ template <typename T>
+ struct common_type<T, ::S<T> >
+ {
+ typedef S<T> type;
+ };
+}
+
+#if TEST_STD_VER >= 11
+template <class T, class U, class = void>
+struct no_common_type : std::true_type {};
+
+template <class T, class U>
+struct no_common_type<T, U, typename std::conditional<false,
+ typename std::common_type<T, U>::type, void>::type> : std::false_type {};
+#endif // TEST_STD_VER >= 11
+
int main()
{
static_assert((std::is_same<std::common_type<int>::type, int>::value), "");
static_assert((std::is_same<std::common_type<char>::type, char>::value), "");
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert((std::is_same<std::common_type_t<int>, int>::value), "");
static_assert((std::is_same<std::common_type_t<char>, char>::value), "");
#endif
@@ -29,7 +57,7 @@ int main()
static_assert((std::is_same<std::common_type<int, int>::type, int>::value), "");
static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), "");
-
+
static_assert((std::is_same<std::common_type<long, const int>::type, long>::value), "");
static_assert((std::is_same<std::common_type<const long, int>::type, long>::value), "");
static_assert((std::is_same<std::common_type<long, volatile int>::type, long>::value), "");
@@ -38,15 +66,37 @@ int main()
static_assert((std::is_same<std::common_type<double, char>::type, double>::value), "");
static_assert((std::is_same<std::common_type<short, char>::type, int>::value), "");
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert((std::is_same<std::common_type_t<double, char>, double>::value), "");
static_assert((std::is_same<std::common_type_t<short, char>, int>::value), "");
#endif
static_assert((std::is_same<std::common_type<double, char, long long>::type, double>::value), "");
static_assert((std::is_same<std::common_type<unsigned, char, long long>::type, long long>::value), "");
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
static_assert((std::is_same<std::common_type_t<double, char, long long>, double>::value), "");
static_assert((std::is_same<std::common_type_t<unsigned, char, long long>, long long>::value), "");
#endif
+
+ static_assert((std::is_same<std::common_type< void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type<const void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type< volatile void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type<const volatile void>::type, void>::value), "");
+
+ static_assert((std::is_same<std::common_type<void, const void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type<const void, void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type<void, volatile void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type<volatile void, void>::type, void>::value), "");
+ static_assert((std::is_same<std::common_type<const void, const void>::type, void>::value), "");
+
+#if TEST_STD_VER >= 11
+ static_assert((no_common_type<void, int>::value), "");
+ static_assert((no_common_type<int, void>::value), "");
+ static_assert((no_common_type<int, E>::value), "");
+ static_assert((no_common_type<int, X<int> >::value), "");
+#endif // TEST_STD_VER >= 11
+
+ static_assert((std::is_same<std::common_type<int, S<int> >::type, S<int> >::value), "");
+ static_assert((std::is_same<std::common_type<int, S<int>, S<int> >::type, S<int> >::value), "");
+ static_assert((std::is_same<std::common_type<int, int, S<int> >::type, S<int> >::value), "");
}
diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
index 8150ce04e37f..fb53312cbe67 100644
--- a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
+++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
@@ -22,6 +22,26 @@ void test_add_lvalue_reference()
#endif
}
+template <class F>
+void test_function0()
+{
+ static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F&>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_lvalue_reference_t<F>, F&>::value), "");
+#endif
+}
+
+template <class F>
+void test_function1()
+{
+ static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_lvalue_reference_t<F>, F>::value), "");
+#endif
+}
+
+struct Foo {};
+
int main()
{
test_add_lvalue_reference<void, void>();
@@ -31,4 +51,20 @@ int main()
test_add_lvalue_reference<const int&, const int&>();
test_add_lvalue_reference<int*, int*&>();
test_add_lvalue_reference<const int*, const int*&>();
+
+// LWG 2101 specifically talks about add_lvalue_reference and functions.
+// The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
+ test_function0<void()>();
+// test_function1<void() const>();
+// test_function1<void() &>();
+// test_function1<void() &&>();
+// test_function1<void() const &>();
+// test_function1<void() const &&>();
+
+ test_function0<void (Foo::*)()>();
+ test_function0<void (Foo::*)() const>();
+ test_function0<void (Foo::*)() &>();
+ test_function0<void (Foo::*)() &&>();
+ test_function0<void (Foo::*)() const &>();
+ test_function0<void (Foo::*)() const &&>();
}
diff --git a/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
index 6ea1cac789ef..0f55db64719b 100644
--- a/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
+++ b/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
@@ -14,6 +14,8 @@
#include <type_traits>
#include <cstdint>
+#include "test_macros.h"
+
template <class T, unsigned A>
void test_alignment_of()
{
@@ -21,6 +23,12 @@ void test_alignment_of()
static_assert( std::alignment_of<const T>::value == A, "");
static_assert( std::alignment_of<volatile T>::value == A, "");
static_assert( std::alignment_of<const volatile T>::value == A, "");
+#if TEST_STD_VER > 14
+ static_assert( std::alignment_of_v<T> == A, "");
+ static_assert( std::alignment_of_v<const T> == A, "");
+ static_assert( std::alignment_of_v<volatile T> == A, "");
+ static_assert( std::alignment_of_v<const volatile T> == A, "");
+#endif
}
class Class
diff --git a/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
index a99dc6948529..39a7c2b593bb 100644
--- a/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
+++ b/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, unsigned A>
void test_extent()
{
@@ -20,6 +22,12 @@ void test_extent()
static_assert((std::extent<const T>::value == A), "");
static_assert((std::extent<volatile T>::value == A), "");
static_assert((std::extent<const volatile T>::value == A), "");
+#if TEST_STD_VER > 14
+ static_assert((std::extent_v<T> == A), "");
+ static_assert((std::extent_v<const T> == A), "");
+ static_assert((std::extent_v<volatile T> == A), "");
+ static_assert((std::extent_v<const volatile T> == A), "");
+#endif
}
template <class T, unsigned A>
@@ -29,6 +37,12 @@ void test_extent1()
static_assert((std::extent<const T, 1>::value == A), "");
static_assert((std::extent<volatile T, 1>::value == A), "");
static_assert((std::extent<const volatile T, 1>::value == A), "");
+#if TEST_STD_VER > 14
+ static_assert((std::extent_v<T, 1> == A), "");
+ static_assert((std::extent_v<const T, 1> == A), "");
+ static_assert((std::extent_v<volatile T, 1> == A), "");
+ static_assert((std::extent_v<const volatile T, 1> == A), "");
+#endif
}
class Class
diff --git a/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
index 06f66a92c7c3..755269d1d403 100644
--- a/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
+++ b/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp
@@ -13,6 +13,8 @@
#include <type_traits>
+#include "test_macros.h"
+
template <class T, unsigned A>
void test_rank()
{
@@ -20,6 +22,12 @@ void test_rank()
static_assert( std::rank<const T>::value == A, "");
static_assert( std::rank<volatile T>::value == A, "");
static_assert( std::rank<const volatile T>::value == A, "");
+#if TEST_STD_VER > 14
+ static_assert( std::rank_v<T> == A, "");
+ static_assert( std::rank_v<const T> == A, "");
+ static_assert( std::rank_v<volatile T> == A, "");
+ static_assert( std::rank_v<const volatile T> == A, "");
+#endif
}
class Class
diff --git a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
index 5deeeff110d4..ccec65fec399 100644
--- a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
+++ b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
@@ -11,11 +11,11 @@
// void_t
-#include <type_traits>
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// XFAIL: gcc-5.1 gcc-5.2
-#if _LIBCPP_STD_VER <= 14
-int main () {}
-#else
+#include <type_traits>
template <class T>
void test1()
@@ -66,4 +66,3 @@ int main()
static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, "");
}
-#endif
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp
new file mode 100644
index 000000000000..72955defa399
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_array
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_array()
+{
+ static_assert( std::is_array<T>::value, "");
+ static_assert( std::is_array<const T>::value, "");
+ static_assert( std::is_array<volatile T>::value, "");
+ static_assert( std::is_array<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_array_v<T>, "");
+ static_assert( std::is_array_v<const T>, "");
+ static_assert( std::is_array_v<volatile T>, "");
+ static_assert( std::is_array_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_array()
+{
+ static_assert(!std::is_array<T>::value, "");
+ static_assert(!std::is_array<const T>::value, "");
+ static_assert(!std::is_array<volatile T>::value, "");
+ static_assert(!std::is_array<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_array_v<T>, "");
+ static_assert(!std::is_array_v<const T>, "");
+ static_assert(!std::is_array_v<volatile T>, "");
+ static_assert(!std::is_array_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_array<char[3]>();
+ test_is_array<char[]>();
+ test_is_array<Union[]>();
+
+ test_is_not_array<std::nullptr_t>();
+ test_is_not_array<void>();
+ test_is_not_array<int&>();
+ test_is_not_array<int&&>();
+ test_is_not_array<int*>();
+ test_is_not_array<double>();
+ test_is_not_array<const int*>();
+ test_is_not_array<Enum>();
+ test_is_not_array<Union>();
+ test_is_not_array<FunctionPtr>();
+ test_is_not_array<Empty>();
+ test_is_not_array<bit_zero>();
+ test_is_not_array<NotEmpty>();
+ test_is_not_array<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp
new file mode 100644
index 000000000000..97671e7b62e0
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_class
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_class()
+{
+ static_assert( std::is_class<T>::value, "");
+ static_assert( std::is_class<const T>::value, "");
+ static_assert( std::is_class<volatile T>::value, "");
+ static_assert( std::is_class<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_class_v<T>, "");
+ static_assert( std::is_class_v<const T>, "");
+ static_assert( std::is_class_v<volatile T>, "");
+ static_assert( std::is_class_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_class()
+{
+ static_assert(!std::is_class<T>::value, "");
+ static_assert(!std::is_class<const T>::value, "");
+ static_assert(!std::is_class<volatile T>::value, "");
+ static_assert(!std::is_class<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_class_v<T>, "");
+ static_assert(!std::is_class_v<const T>, "");
+ static_assert(!std::is_class_v<volatile T>, "");
+ static_assert(!std::is_class_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_class<Empty>();
+ test_is_class<bit_zero>();
+ test_is_class<NotEmpty>();
+ test_is_class<Abstract>();
+
+#if TEST_STD_VER >= 11
+// In C++03 we have an emulation of std::nullptr_t
+ test_is_not_class<std::nullptr_t>();
+#endif
+ test_is_not_class<void>();
+ test_is_not_class<int>();
+ test_is_not_class<int&>();
+#if TEST_STD_VER >= 11
+ test_is_not_class<int&&>();
+#endif
+ test_is_not_class<int*>();
+ test_is_not_class<double>();
+ test_is_not_class<const int*>();
+ test_is_not_class<char[3]>();
+ test_is_not_class<char[]>();
+ test_is_not_class<Enum>();
+ test_is_not_class<Union>();
+ test_is_not_class<FunctionPtr>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp
new file mode 100644
index 000000000000..481260ea6e52
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_enum
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_enum()
+{
+ static_assert( std::is_enum<T>::value, "");
+ static_assert( std::is_enum<const T>::value, "");
+ static_assert( std::is_enum<volatile T>::value, "");
+ static_assert( std::is_enum<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_enum_v<T>, "");
+ static_assert( std::is_enum_v<const T>, "");
+ static_assert( std::is_enum_v<volatile T>, "");
+ static_assert( std::is_enum_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_enum()
+{
+ static_assert(!std::is_enum<T>::value, "");
+ static_assert(!std::is_enum<const T>::value, "");
+ static_assert(!std::is_enum<volatile T>::value, "");
+ static_assert(!std::is_enum<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_enum_v<T>, "");
+ static_assert(!std::is_enum_v<const T>, "");
+ static_assert(!std::is_enum_v<volatile T>, "");
+ static_assert(!std::is_enum_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_enum<Enum>();
+
+ test_is_not_enum<std::nullptr_t>();
+ test_is_not_enum<void>();
+ test_is_not_enum<int>();
+ test_is_not_enum<int&>();
+ test_is_not_enum<int&&>();
+ test_is_not_enum<int*>();
+ test_is_not_enum<double>();
+ test_is_not_enum<const int*>();
+ test_is_not_enum<char[3]>();
+ test_is_not_enum<char[]>();
+ test_is_not_enum<Union>();
+ test_is_not_enum<Empty>();
+ test_is_not_enum<bit_zero>();
+ test_is_not_enum<NotEmpty>();
+ test_is_not_enum<Abstract>();
+ test_is_not_enum<FunctionPtr>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp
new file mode 100644
index 000000000000..de9c146bcb4e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_floating_point
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_floating_point()
+{
+ static_assert( std::is_floating_point<T>::value, "");
+ static_assert( std::is_floating_point<const T>::value, "");
+ static_assert( std::is_floating_point<volatile T>::value, "");
+ static_assert( std::is_floating_point<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_floating_point_v<T>, "");
+ static_assert( std::is_floating_point_v<const T>, "");
+ static_assert( std::is_floating_point_v<volatile T>, "");
+ static_assert( std::is_floating_point_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_floating_point()
+{
+ static_assert(!std::is_floating_point<T>::value, "");
+ static_assert(!std::is_floating_point<const T>::value, "");
+ static_assert(!std::is_floating_point<volatile T>::value, "");
+ static_assert(!std::is_floating_point<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_floating_point_v<T>, "");
+ static_assert(!std::is_floating_point_v<const T>, "");
+ static_assert(!std::is_floating_point_v<volatile T>, "");
+ static_assert(!std::is_floating_point_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_floating_point<float>();
+ test_is_floating_point<double>();
+ test_is_floating_point<long double>();
+
+ test_is_not_floating_point<short>();
+ test_is_not_floating_point<unsigned short>();
+ test_is_not_floating_point<int>();
+ test_is_not_floating_point<unsigned int>();
+ test_is_not_floating_point<long>();
+ test_is_not_floating_point<unsigned long>();
+
+ test_is_not_floating_point<std::nullptr_t>();
+ test_is_not_floating_point<void>();
+ test_is_not_floating_point<int&>();
+ test_is_not_floating_point<int&&>();
+ test_is_not_floating_point<int*>();
+ test_is_not_floating_point<const int*>();
+ test_is_not_floating_point<char[3]>();
+ test_is_not_floating_point<char[]>();
+ test_is_not_floating_point<Union>();
+ test_is_not_floating_point<Empty>();
+ test_is_not_floating_point<bit_zero>();
+ test_is_not_floating_point<NotEmpty>();
+ test_is_not_floating_point<Abstract>();
+ test_is_not_floating_point<Enum>();
+ test_is_not_floating_point<FunctionPtr>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp
new file mode 100644
index 000000000000..9a1d821b0746
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_function
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_function()
+{
+ static_assert( std::is_function<T>::value, "");
+ static_assert( std::is_function<const T>::value, "");
+ static_assert( std::is_function<volatile T>::value, "");
+ static_assert( std::is_function<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_function_v<T>, "");
+ static_assert( std::is_function_v<const T>, "");
+ static_assert( std::is_function_v<volatile T>, "");
+ static_assert( std::is_function_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_function()
+{
+ static_assert(!std::is_function<T>::value, "");
+ static_assert(!std::is_function<const T>::value, "");
+ static_assert(!std::is_function<volatile T>::value, "");
+ static_assert(!std::is_function<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_function_v<T>, "");
+ static_assert(!std::is_function_v<const T>, "");
+ static_assert(!std::is_function_v<volatile T>, "");
+ static_assert(!std::is_function_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_function<void(void)>();
+ test_is_function<int(int)>();
+ test_is_function<int(int, double)>();
+ test_is_function<int(Abstract *)>();
+ test_is_function<void(...)>();
+
+ test_is_not_function<std::nullptr_t>();
+ test_is_not_function<void>();
+ test_is_not_function<int>();
+ test_is_not_function<int&>();
+ test_is_not_function<int&&>();
+ test_is_not_function<int*>();
+ test_is_not_function<double>();
+ test_is_not_function<char[3]>();
+ test_is_not_function<char[]>();
+ test_is_not_function<Union>();
+ test_is_not_function<Enum>();
+ test_is_not_function<FunctionPtr>(); // function pointer is not a function
+ test_is_not_function<Empty>();
+ test_is_not_function<bit_zero>();
+ test_is_not_function<NotEmpty>();
+ test_is_not_function<Abstract>();
+ test_is_not_function<Abstract*>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp
new file mode 100644
index 000000000000..86b63c53da54
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_integral
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_integral()
+{
+ static_assert( std::is_integral<T>::value, "");
+ static_assert( std::is_integral<const T>::value, "");
+ static_assert( std::is_integral<volatile T>::value, "");
+ static_assert( std::is_integral<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_integral_v<T>, "");
+ static_assert( std::is_integral_v<const T>, "");
+ static_assert( std::is_integral_v<volatile T>, "");
+ static_assert( std::is_integral_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_integral()
+{
+ static_assert(!std::is_integral<T>::value, "");
+ static_assert(!std::is_integral<const T>::value, "");
+ static_assert(!std::is_integral<volatile T>::value, "");
+ static_assert(!std::is_integral<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_integral_v<T>, "");
+ static_assert(!std::is_integral_v<const T>, "");
+ static_assert(!std::is_integral_v<volatile T>, "");
+ static_assert(!std::is_integral_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_integral<short>();
+ test_is_integral<unsigned short>();
+ test_is_integral<int>();
+ test_is_integral<unsigned int>();
+ test_is_integral<long>();
+ test_is_integral<unsigned long>();
+ test_is_integral<bool>();
+ test_is_integral<char>();
+ test_is_integral<signed char>();
+ test_is_integral<unsigned char>();
+ test_is_integral<wchar_t>();
+
+ test_is_not_integral<std::nullptr_t>();
+ test_is_not_integral<void>();
+ test_is_not_integral<int&>();
+ test_is_not_integral<int&&>();
+ test_is_not_integral<int*>();
+ test_is_not_integral<double>();
+ test_is_not_integral<const int*>();
+ test_is_not_integral<char[3]>();
+ test_is_not_integral<char[]>();
+ test_is_not_integral<Union>();
+ test_is_not_integral<Enum>();
+ test_is_not_integral<FunctionPtr>();
+ test_is_not_integral<Empty>();
+ test_is_not_integral<bit_zero>();
+ test_is_not_integral<NotEmpty>();
+ test_is_not_integral<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp
new file mode 100644
index 000000000000..0e59f7153f50
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_lvalue_reference
+
+// UNSUPPORTED: c++98, c++03
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_lvalue_reference()
+{
+ static_assert( std::is_lvalue_reference<T>::value, "");
+ static_assert( std::is_lvalue_reference<const T>::value, "");
+ static_assert( std::is_lvalue_reference<volatile T>::value, "");
+ static_assert( std::is_lvalue_reference<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_lvalue_reference_v<T>, "");
+ static_assert( std::is_lvalue_reference_v<const T>, "");
+ static_assert( std::is_lvalue_reference_v<volatile T>, "");
+ static_assert( std::is_lvalue_reference_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_lvalue_reference()
+{
+ static_assert(!std::is_lvalue_reference<T>::value, "");
+ static_assert(!std::is_lvalue_reference<const T>::value, "");
+ static_assert(!std::is_lvalue_reference<volatile T>::value, "");
+ static_assert(!std::is_lvalue_reference<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_lvalue_reference_v<T>, "");
+ static_assert(!std::is_lvalue_reference_v<const T>, "");
+ static_assert(!std::is_lvalue_reference_v<volatile T>, "");
+ static_assert(!std::is_lvalue_reference_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_lvalue_reference<int&>();
+
+ test_is_not_lvalue_reference<std::nullptr_t>();
+ test_is_not_lvalue_reference<void>();
+ test_is_not_lvalue_reference<int>();
+ test_is_not_lvalue_reference<int*>();
+ test_is_not_lvalue_reference<int&&>();
+ test_is_not_lvalue_reference<double>();
+ test_is_not_lvalue_reference<const int*>();
+ test_is_not_lvalue_reference<char[3]>();
+ test_is_not_lvalue_reference<char[]>();
+ test_is_not_lvalue_reference<Union>();
+ test_is_not_lvalue_reference<Enum>();
+ test_is_not_lvalue_reference<FunctionPtr>();
+ test_is_not_lvalue_reference<Empty>();
+ test_is_not_lvalue_reference<bit_zero>();
+ test_is_not_lvalue_reference<NotEmpty>();
+ test_is_not_lvalue_reference<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp
new file mode 100644
index 000000000000..8da411d2eeed
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_member_object_pointer
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_member_object_pointer()
+{
+ static_assert( std::is_member_object_pointer<T>::value, "");
+ static_assert( std::is_member_object_pointer<const T>::value, "");
+ static_assert( std::is_member_object_pointer<volatile T>::value, "");
+ static_assert( std::is_member_object_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_member_object_pointer_v<T>, "");
+ static_assert( std::is_member_object_pointer_v<const T>, "");
+ static_assert( std::is_member_object_pointer_v<volatile T>, "");
+ static_assert( std::is_member_object_pointer_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_member_object_pointer()
+{
+ static_assert(!std::is_member_object_pointer<T>::value, "");
+ static_assert(!std::is_member_object_pointer<const T>::value, "");
+ static_assert(!std::is_member_object_pointer<volatile T>::value, "");
+ static_assert(!std::is_member_object_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_member_object_pointer_v<T>, "");
+ static_assert(!std::is_member_object_pointer_v<const T>, "");
+ static_assert(!std::is_member_object_pointer_v<volatile T>, "");
+ static_assert(!std::is_member_object_pointer_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_member_object_pointer<int Abstract::*>();
+ test_is_member_object_pointer<double NotEmpty::*>();
+ test_is_member_object_pointer<FunctionPtr Empty::*>();
+
+ test_is_not_member_object_pointer<std::nullptr_t>();
+ test_is_not_member_object_pointer<void>();
+ test_is_not_member_object_pointer<int>();
+ test_is_not_member_object_pointer<int&>();
+ test_is_not_member_object_pointer<int&&>();
+ test_is_not_member_object_pointer<int*>();
+ test_is_not_member_object_pointer<double>();
+ test_is_not_member_object_pointer<const int*>();
+ test_is_not_member_object_pointer<char[3]>();
+ test_is_not_member_object_pointer<char[]>();
+ test_is_not_member_object_pointer<Union>();
+ test_is_not_member_object_pointer<Enum>();
+ test_is_not_member_object_pointer<FunctionPtr>();
+ test_is_not_member_object_pointer<Empty>();
+ test_is_not_member_object_pointer<bit_zero>();
+ test_is_not_member_object_pointer<NotEmpty>();
+ test_is_not_member_object_pointer<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp
new file mode 100644
index 000000000000..19a74b01d0fd
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_member_pointer
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_member_pointer()
+{
+ static_assert( std::is_member_pointer<T>::value, "");
+ static_assert( std::is_member_pointer<const T>::value, "");
+ static_assert( std::is_member_pointer<volatile T>::value, "");
+ static_assert( std::is_member_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_member_pointer_v<T>, "");
+ static_assert( std::is_member_pointer_v<const T>, "");
+ static_assert( std::is_member_pointer_v<volatile T>, "");
+ static_assert( std::is_member_pointer_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_member_pointer()
+{
+ static_assert(!std::is_member_pointer<T>::value, "");
+ static_assert(!std::is_member_pointer<const T>::value, "");
+ static_assert(!std::is_member_pointer<volatile T>::value, "");
+ static_assert(!std::is_member_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_member_pointer_v<T>, "");
+ static_assert(!std::is_member_pointer_v<const T>, "");
+ static_assert(!std::is_member_pointer_v<volatile T>, "");
+ static_assert(!std::is_member_pointer_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_member_pointer<int Abstract::*>();
+ test_is_member_pointer<double NotEmpty::*>();
+ test_is_member_pointer<FunctionPtr Empty::*>();
+ test_is_member_pointer<void (Empty::*)()>();
+
+ test_is_not_member_pointer<std::nullptr_t>();
+ test_is_not_member_pointer<void>();
+ test_is_not_member_pointer<int>();
+ test_is_not_member_pointer<int&>();
+ test_is_not_member_pointer<int&&>();
+ test_is_not_member_pointer<int*>();
+ test_is_not_member_pointer<double>();
+ test_is_not_member_pointer<const int*>();
+ test_is_not_member_pointer<char[3]>();
+ test_is_not_member_pointer<char[]>();
+ test_is_not_member_pointer<Union>();
+ test_is_not_member_pointer<Enum>();
+ test_is_not_member_pointer<FunctionPtr>();
+ test_is_not_member_pointer<Empty>();
+ test_is_not_member_pointer<bit_zero>();
+ test_is_not_member_pointer<NotEmpty>();
+ test_is_not_member_pointer<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp
new file mode 100644
index 000000000000..80f563e8969e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_null_pointer
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_null_pointer()
+{
+ static_assert( std::is_null_pointer<T>::value, "");
+ static_assert( std::is_null_pointer<const T>::value, "");
+ static_assert( std::is_null_pointer<volatile T>::value, "");
+ static_assert( std::is_null_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_null_pointer_v<T>, "");
+ static_assert( std::is_null_pointer_v<const T>, "");
+ static_assert( std::is_null_pointer_v<volatile T>, "");
+ static_assert( std::is_null_pointer_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_null_pointer()
+{
+ static_assert(!std::is_null_pointer<T>::value, "");
+ static_assert(!std::is_null_pointer<const T>::value, "");
+ static_assert(!std::is_null_pointer<volatile T>::value, "");
+ static_assert(!std::is_null_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_null_pointer_v<T>, "");
+ static_assert(!std::is_null_pointer_v<const T>, "");
+ static_assert(!std::is_null_pointer_v<volatile T>, "");
+ static_assert(!std::is_null_pointer_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_null_pointer<std::nullptr_t>();
+
+ test_is_not_null_pointer<void>();
+ test_is_not_null_pointer<int>();
+ test_is_not_null_pointer<int&>();
+ test_is_not_null_pointer<int&&>();
+ test_is_not_null_pointer<int*>();
+ test_is_not_null_pointer<double>();
+ test_is_not_null_pointer<const int*>();
+ test_is_not_null_pointer<char[3]>();
+ test_is_not_null_pointer<char[]>();
+ test_is_not_null_pointer<Union>();
+ test_is_not_null_pointer<Enum>();
+ test_is_not_null_pointer<FunctionPtr>();
+ test_is_not_null_pointer<Empty>();
+ test_is_not_null_pointer<bit_zero>();
+ test_is_not_null_pointer<NotEmpty>();
+ test_is_not_null_pointer<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp
new file mode 100644
index 000000000000..a901aed1143e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_pointer
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_pointer()
+{
+ static_assert( std::is_pointer<T>::value, "");
+ static_assert( std::is_pointer<const T>::value, "");
+ static_assert( std::is_pointer<volatile T>::value, "");
+ static_assert( std::is_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_pointer_v<T>, "");
+ static_assert( std::is_pointer_v<const T>, "");
+ static_assert( std::is_pointer_v<volatile T>, "");
+ static_assert( std::is_pointer_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_pointer()
+{
+ static_assert(!std::is_pointer<T>::value, "");
+ static_assert(!std::is_pointer<const T>::value, "");
+ static_assert(!std::is_pointer<volatile T>::value, "");
+ static_assert(!std::is_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_pointer_v<T>, "");
+ static_assert(!std::is_pointer_v<const T>, "");
+ static_assert(!std::is_pointer_v<volatile T>, "");
+ static_assert(!std::is_pointer_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_pointer<void*>();
+ test_is_pointer<int*>();
+ test_is_pointer<const int*>();
+ test_is_pointer<Abstract*>();
+ test_is_pointer<FunctionPtr>();
+
+ test_is_not_pointer<std::nullptr_t>();
+ test_is_not_pointer<void>();
+ test_is_not_pointer<int&>();
+ test_is_not_pointer<int&&>();
+ test_is_not_pointer<double>();
+ test_is_not_pointer<char[3]>();
+ test_is_not_pointer<char[]>();
+ test_is_not_pointer<Union>();
+ test_is_not_pointer<Enum>();
+ test_is_not_pointer<Empty>();
+ test_is_not_pointer<bit_zero>();
+ test_is_not_pointer<NotEmpty>();
+ test_is_not_pointer<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp
new file mode 100644
index 000000000000..b7b52687018a
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_rvalue_reference
+
+// UNSUPPORTED: c++98, c++03
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_rvalue_reference()
+{
+ static_assert( std::is_rvalue_reference<T>::value, "");
+ static_assert( std::is_rvalue_reference<const T>::value, "");
+ static_assert( std::is_rvalue_reference<volatile T>::value, "");
+ static_assert( std::is_rvalue_reference<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_rvalue_reference_v<T>, "");
+ static_assert( std::is_rvalue_reference_v<const T>, "");
+ static_assert( std::is_rvalue_reference_v<volatile T>, "");
+ static_assert( std::is_rvalue_reference_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_rvalue_reference()
+{
+ static_assert(!std::is_rvalue_reference<T>::value, "");
+ static_assert(!std::is_rvalue_reference<const T>::value, "");
+ static_assert(!std::is_rvalue_reference<volatile T>::value, "");
+ static_assert(!std::is_rvalue_reference<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_rvalue_reference_v<T>, "");
+ static_assert(!std::is_rvalue_reference_v<const T>, "");
+ static_assert(!std::is_rvalue_reference_v<volatile T>, "");
+ static_assert(!std::is_rvalue_reference_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_rvalue_reference<int&&>();
+
+ test_is_not_rvalue_reference<std::nullptr_t>();
+ test_is_not_rvalue_reference<void>();
+ test_is_not_rvalue_reference<int>();
+ test_is_not_rvalue_reference<int*>();
+ test_is_not_rvalue_reference<int&>();
+ test_is_not_rvalue_reference<double>();
+ test_is_not_rvalue_reference<const int*>();
+ test_is_not_rvalue_reference<char[3]>();
+ test_is_not_rvalue_reference<char[]>();
+ test_is_not_rvalue_reference<Union>();
+ test_is_not_rvalue_reference<Enum>();
+ test_is_not_rvalue_reference<FunctionPtr>();
+ test_is_not_rvalue_reference<Empty>();
+ test_is_not_rvalue_reference<bit_zero>();
+ test_is_not_rvalue_reference<NotEmpty>();
+ test_is_not_rvalue_reference<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp
new file mode 100644
index 000000000000..307fedb32b26
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_union
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_union()
+{
+ static_assert( std::is_union<T>::value, "");
+ static_assert( std::is_union<const T>::value, "");
+ static_assert( std::is_union<volatile T>::value, "");
+ static_assert( std::is_union<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_union_v<T>, "");
+ static_assert( std::is_union_v<const T>, "");
+ static_assert( std::is_union_v<volatile T>, "");
+ static_assert( std::is_union_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_union()
+{
+ static_assert(!std::is_union<T>::value, "");
+ static_assert(!std::is_union<const T>::value, "");
+ static_assert(!std::is_union<volatile T>::value, "");
+ static_assert(!std::is_union<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_union_v<T>, "");
+ static_assert(!std::is_union_v<const T>, "");
+ static_assert(!std::is_union_v<volatile T>, "");
+ static_assert(!std::is_union_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_union<Union>();
+
+ test_is_not_union<std::nullptr_t>();
+ test_is_not_union<void>();
+ test_is_not_union<int>();
+ test_is_not_union<int&>();
+ test_is_not_union<int&&>();
+ test_is_not_union<int*>();
+ test_is_not_union<double>();
+ test_is_not_union<const int*>();
+ test_is_not_union<char[3]>();
+ test_is_not_union<char[]>();
+ test_is_not_union<Enum>();
+ test_is_not_union<FunctionPtr>();
+ test_is_not_union<Empty>();
+ test_is_not_union<bit_zero>();
+ test_is_not_union<NotEmpty>();
+ test_is_not_union<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp
new file mode 100644
index 000000000000..1647666adf2e
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_void
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_void()
+{
+ static_assert( std::is_void<T>::value, "");
+ static_assert( std::is_void<const T>::value, "");
+ static_assert( std::is_void<volatile T>::value, "");
+ static_assert( std::is_void<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_void_v<T>, "");
+ static_assert( std::is_void_v<const T>, "");
+ static_assert( std::is_void_v<volatile T>, "");
+ static_assert( std::is_void_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_void()
+{
+ static_assert(!std::is_void<T>::value, "");
+ static_assert(!std::is_void<const T>::value, "");
+ static_assert(!std::is_void<volatile T>::value, "");
+ static_assert(!std::is_void<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_void_v<T>, "");
+ static_assert(!std::is_void_v<const T>, "");
+ static_assert(!std::is_void_v<volatile T>, "");
+ static_assert(!std::is_void_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+int main()
+{
+ test_is_void<void>();
+
+ test_is_not_void<int>();
+ test_is_not_void<int*>();
+ test_is_not_void<int&>();
+ test_is_not_void<int&&>();
+ test_is_not_void<double>();
+ test_is_not_void<const int*>();
+ test_is_not_void<char[3]>();
+ test_is_not_void<char[]>();
+ test_is_not_void<Union>();
+ test_is_not_void<Empty>();
+ test_is_not_void<bit_zero>();
+ test_is_not_void<NotEmpty>();
+ test_is_not_void<Abstract>();
+ test_is_not_void<Enum>();
+ test_is_not_void<FunctionPtr>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
index 691e3536167d..1c7a32fc9dc9 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
@@ -13,6 +13,7 @@
// is_null_pointer
#include <type_traits>
+#include <cstddef> // for std::nullptr_t
#if _LIBCPP_STD_VER > 11
template <class T>
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp
new file mode 100644
index 000000000000..a3f18d52a706
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_arithmetic
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_arithmetic()
+{
+ static_assert( std::is_arithmetic<T>::value, "");
+ static_assert( std::is_arithmetic<const T>::value, "");
+ static_assert( std::is_arithmetic<volatile T>::value, "");
+ static_assert( std::is_arithmetic<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_arithmetic_v<T>, "");
+ static_assert( std::is_arithmetic_v<const T>, "");
+ static_assert( std::is_arithmetic_v<volatile T>, "");
+ static_assert( std::is_arithmetic_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_arithmetic()
+{
+ static_assert(!std::is_arithmetic<T>::value, "");
+ static_assert(!std::is_arithmetic<const T>::value, "");
+ static_assert(!std::is_arithmetic<volatile T>::value, "");
+ static_assert(!std::is_arithmetic<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_arithmetic_v<T>, "");
+ static_assert(!std::is_arithmetic_v<const T>, "");
+ static_assert(!std::is_arithmetic_v<volatile T>, "");
+ static_assert(!std::is_arithmetic_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_arithmetic<short>();
+ test_is_arithmetic<unsigned short>();
+ test_is_arithmetic<int>();
+ test_is_arithmetic<unsigned int>();
+ test_is_arithmetic<long>();
+ test_is_arithmetic<unsigned long>();
+ test_is_arithmetic<bool>();
+ test_is_arithmetic<char>();
+ test_is_arithmetic<signed char>();
+ test_is_arithmetic<unsigned char>();
+ test_is_arithmetic<wchar_t>();
+ test_is_arithmetic<double>();
+
+ test_is_not_arithmetic<std::nullptr_t>();
+ test_is_not_arithmetic<void>();
+ test_is_not_arithmetic<int&>();
+ test_is_not_arithmetic<int&&>();
+ test_is_not_arithmetic<int*>();
+ test_is_not_arithmetic<const int*>();
+ test_is_not_arithmetic<char[3]>();
+ test_is_not_arithmetic<char[]>();
+ test_is_not_arithmetic<Union>();
+ test_is_not_arithmetic<Enum>();
+ test_is_not_arithmetic<FunctionPtr>();
+ test_is_not_arithmetic<Empty>();
+ test_is_not_arithmetic<bit_zero>();
+ test_is_not_arithmetic<NotEmpty>();
+ test_is_not_arithmetic<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp
new file mode 100644
index 000000000000..6a1798ab5adc
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_compound
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_compound()
+{
+ static_assert( std::is_compound<T>::value, "");
+ static_assert( std::is_compound<const T>::value, "");
+ static_assert( std::is_compound<volatile T>::value, "");
+ static_assert( std::is_compound<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_compound_v<T>, "");
+ static_assert( std::is_compound_v<const T>, "");
+ static_assert( std::is_compound_v<volatile T>, "");
+ static_assert( std::is_compound_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_compound()
+{
+ static_assert(!std::is_compound<T>::value, "");
+ static_assert(!std::is_compound<const T>::value, "");
+ static_assert(!std::is_compound<volatile T>::value, "");
+ static_assert(!std::is_compound<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_compound_v<T>, "");
+ static_assert(!std::is_compound_v<const T>, "");
+ static_assert(!std::is_compound_v<volatile T>, "");
+ static_assert(!std::is_compound_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_compound<char[3]>();
+ test_is_compound<char[]>();
+ test_is_compound<void *>();
+ test_is_compound<FunctionPtr>();
+ test_is_compound<int&>();
+ test_is_compound<int&&>();
+ test_is_compound<Union>();
+ test_is_compound<Empty>();
+ test_is_compound<bit_zero>();
+ test_is_compound<int*>();
+ test_is_compound<const int*>();
+ test_is_compound<Enum>();
+ test_is_compound<NotEmpty>();
+ test_is_compound<Abstract>();
+
+ test_is_not_compound<std::nullptr_t>();
+ test_is_not_compound<void>();
+ test_is_not_compound<int>();
+ test_is_not_compound<double>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp
new file mode 100644
index 000000000000..e16337e05f1c
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_fundamental
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_fundamental()
+{
+ static_assert( std::is_fundamental<T>::value, "");
+ static_assert( std::is_fundamental<const T>::value, "");
+ static_assert( std::is_fundamental<volatile T>::value, "");
+ static_assert( std::is_fundamental<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_fundamental_v<T>, "");
+ static_assert( std::is_fundamental_v<const T>, "");
+ static_assert( std::is_fundamental_v<volatile T>, "");
+ static_assert( std::is_fundamental_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_fundamental()
+{
+ static_assert(!std::is_fundamental<T>::value, "");
+ static_assert(!std::is_fundamental<const T>::value, "");
+ static_assert(!std::is_fundamental<volatile T>::value, "");
+ static_assert(!std::is_fundamental<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_fundamental_v<T>, "");
+ static_assert(!std::is_fundamental_v<const T>, "");
+ static_assert(!std::is_fundamental_v<volatile T>, "");
+ static_assert(!std::is_fundamental_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_fundamental<std::nullptr_t>();
+ test_is_fundamental<void>();
+ test_is_fundamental<short>();
+ test_is_fundamental<unsigned short>();
+ test_is_fundamental<int>();
+ test_is_fundamental<unsigned int>();
+ test_is_fundamental<long>();
+ test_is_fundamental<unsigned long>();
+ test_is_fundamental<long long>();
+ test_is_fundamental<unsigned long long>();
+ test_is_fundamental<bool>();
+ test_is_fundamental<char>();
+ test_is_fundamental<signed char>();
+ test_is_fundamental<unsigned char>();
+ test_is_fundamental<wchar_t>();
+ test_is_fundamental<double>();
+ test_is_fundamental<float>();
+ test_is_fundamental<double>();
+ test_is_fundamental<long double>();
+ test_is_fundamental<char16_t>();
+ test_is_fundamental<char32_t>();
+
+ test_is_not_fundamental<char[3]>();
+ test_is_not_fundamental<char[]>();
+ test_is_not_fundamental<void *>();
+ test_is_not_fundamental<FunctionPtr>();
+ test_is_not_fundamental<int&>();
+ test_is_not_fundamental<int&&>();
+ test_is_not_fundamental<Union>();
+ test_is_not_fundamental<Empty>();
+ test_is_not_fundamental<bit_zero>();
+ test_is_not_fundamental<int*>();
+ test_is_not_fundamental<const int*>();
+ test_is_not_fundamental<Enum>();
+ test_is_not_fundamental<NotEmpty>();
+ test_is_not_fundamental<Abstract>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp
new file mode 100644
index 000000000000..890da659e218
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_member_pointer
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_member_pointer()
+{
+ static_assert( std::is_member_pointer<T>::value, "");
+ static_assert( std::is_member_pointer<const T>::value, "");
+ static_assert( std::is_member_pointer<volatile T>::value, "");
+ static_assert( std::is_member_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_member_pointer_v<T>, "");
+ static_assert( std::is_member_pointer_v<const T>, "");
+ static_assert( std::is_member_pointer_v<volatile T>, "");
+ static_assert( std::is_member_pointer_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_member_pointer()
+{
+ static_assert(!std::is_member_pointer<T>::value, "");
+ static_assert(!std::is_member_pointer<const T>::value, "");
+ static_assert(!std::is_member_pointer<volatile T>::value, "");
+ static_assert(!std::is_member_pointer<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_member_pointer_v<T>, "");
+ static_assert(!std::is_member_pointer_v<const T>, "");
+ static_assert(!std::is_member_pointer_v<volatile T>, "");
+ static_assert(!std::is_member_pointer_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2),
+// std::nullptr_t, and cv-qualified versions of these types (3.9.3)
+// are collectively called scalar types.
+
+ test_is_member_pointer<int Empty::*>();
+ test_is_member_pointer<void (Empty::*)(int)>();
+
+ test_is_not_member_pointer<std::nullptr_t>();
+ test_is_not_member_pointer<void>();
+ test_is_not_member_pointer<void *>();
+ test_is_not_member_pointer<int>();
+ test_is_not_member_pointer<int*>();
+ test_is_not_member_pointer<const int*>();
+ test_is_not_member_pointer<int&>();
+ test_is_not_member_pointer<int&&>();
+ test_is_not_member_pointer<double>();
+ test_is_not_member_pointer<char[3]>();
+ test_is_not_member_pointer<char[]>();
+ test_is_not_member_pointer<Union>();
+ test_is_not_member_pointer<Empty>();
+ test_is_not_member_pointer<bit_zero>();
+ test_is_not_member_pointer<NotEmpty>();
+ test_is_not_member_pointer<Abstract>();
+ test_is_not_member_pointer<int(int)>();
+ test_is_not_member_pointer<Enum>();
+ test_is_not_member_pointer<FunctionPtr>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp
new file mode 100644
index 000000000000..ff7dda30d111
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_object
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_object()
+{
+ static_assert( std::is_object<T>::value, "");
+ static_assert( std::is_object<const T>::value, "");
+ static_assert( std::is_object<volatile T>::value, "");
+ static_assert( std::is_object<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_object_v<T>, "");
+ static_assert( std::is_object_v<const T>, "");
+ static_assert( std::is_object_v<volatile T>, "");
+ static_assert( std::is_object_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_object()
+{
+ static_assert(!std::is_object<T>::value, "");
+ static_assert(!std::is_object<const T>::value, "");
+ static_assert(!std::is_object<volatile T>::value, "");
+ static_assert(!std::is_object<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_object_v<T>, "");
+ static_assert(!std::is_object_v<const T>, "");
+ static_assert(!std::is_object_v<volatile T>, "");
+ static_assert(!std::is_object_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+// An object type is a (possibly cv-qualified) type that is not a function type,
+// not a reference type, and not a void type.
+
+ test_is_object<std::nullptr_t>();
+ test_is_object<void *>();
+ test_is_object<char[3]>();
+ test_is_object<char[]>();
+ test_is_object<int>();
+ test_is_object<int*>();
+ test_is_object<Union>();
+ test_is_object<int*>();
+ test_is_object<const int*>();
+ test_is_object<Enum>();
+ test_is_object<Empty>();
+ test_is_object<bit_zero>();
+ test_is_object<NotEmpty>();
+ test_is_object<Abstract>();
+ test_is_object<FunctionPtr>();
+ test_is_object<int Empty::*>();
+ test_is_object<void (Empty::*)(int)>();
+
+ test_is_not_object<void>();
+ test_is_not_object<int&>();
+ test_is_not_object<int&&>();
+ test_is_not_object<int(int)>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp
new file mode 100644
index 000000000000..e56c8f761814
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_reference
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_reference()
+{
+ static_assert( std::is_reference<T>::value, "");
+ static_assert( std::is_reference<const T>::value, "");
+ static_assert( std::is_reference<volatile T>::value, "");
+ static_assert( std::is_reference<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_reference_v<T>, "");
+ static_assert( std::is_reference_v<const T>, "");
+ static_assert( std::is_reference_v<volatile T>, "");
+ static_assert( std::is_reference_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_reference()
+{
+ static_assert(!std::is_reference<T>::value, "");
+ static_assert(!std::is_reference<const T>::value, "");
+ static_assert(!std::is_reference<volatile T>::value, "");
+ static_assert(!std::is_reference<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_reference_v<T>, "");
+ static_assert(!std::is_reference_v<const T>, "");
+ static_assert(!std::is_reference_v<volatile T>, "");
+ static_assert(!std::is_reference_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+ test_is_reference<int&>();
+#if TEST_STD_VER >= 11
+ test_is_reference<int&&>();
+#endif
+
+ test_is_not_reference<std::nullptr_t>();
+ test_is_not_reference<void>();
+ test_is_not_reference<int>();
+ test_is_not_reference<double>();
+ test_is_not_reference<char[3]>();
+ test_is_not_reference<char[]>();
+ test_is_not_reference<void *>();
+ test_is_not_reference<FunctionPtr>();
+ test_is_not_reference<Union>();
+ test_is_not_reference<Empty>();
+ test_is_not_reference<bit_zero>();
+ test_is_not_reference<int*>();
+ test_is_not_reference<const int*>();
+ test_is_not_reference<Enum>();
+ test_is_not_reference<NotEmpty>();
+ test_is_not_reference<Abstract>();
+ test_is_not_reference<int(int)>();
+ test_is_not_reference<int Empty::*>();
+ test_is_not_reference<void (Empty::*)(int)>();
+
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp
new file mode 100644
index 000000000000..2b412a68833b
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_scalar
+
+#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
+
+template <class T>
+void test_is_scalar()
+{
+ static_assert( std::is_scalar<T>::value, "");
+ static_assert( std::is_scalar<const T>::value, "");
+ static_assert( std::is_scalar<volatile T>::value, "");
+ static_assert( std::is_scalar<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_scalar_v<T>, "");
+ static_assert( std::is_scalar_v<const T>, "");
+ static_assert( std::is_scalar_v<volatile T>, "");
+ static_assert( std::is_scalar_v<const volatile T>, "");
+#endif
+}
+
+template <class T>
+void test_is_not_scalar()
+{
+ static_assert(!std::is_scalar<T>::value, "");
+ static_assert(!std::is_scalar<const T>::value, "");
+ static_assert(!std::is_scalar<volatile T>::value, "");
+ static_assert(!std::is_scalar<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_scalar_v<T>, "");
+ static_assert(!std::is_scalar_v<const T>, "");
+ static_assert(!std::is_scalar_v<volatile T>, "");
+ static_assert(!std::is_scalar_v<const volatile T>, "");
+#endif
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
+
+int main()
+{
+// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2),
+// std::nullptr_t, and cv-qualified versions of these types (3.9.3)
+// are collectively called scalar types.
+
+ test_is_scalar<std::nullptr_t>();
+ test_is_scalar<short>();
+ test_is_scalar<unsigned short>();
+ test_is_scalar<int>();
+ test_is_scalar<unsigned int>();
+ test_is_scalar<long>();
+ test_is_scalar<unsigned long>();
+ test_is_scalar<bool>();
+ test_is_scalar<char>();
+ test_is_scalar<signed char>();
+ test_is_scalar<unsigned char>();
+ test_is_scalar<wchar_t>();
+ test_is_scalar<double>();
+ test_is_scalar<int*>();
+ test_is_scalar<const int*>();
+ test_is_scalar<int Empty::*>();
+ test_is_scalar<void (Empty::*)(int)>();
+ test_is_scalar<Enum>();
+ test_is_scalar<FunctionPtr>();
+
+ test_is_not_scalar<void>();
+ test_is_not_scalar<int&>();
+ test_is_not_scalar<int&&>();
+ test_is_not_scalar<char[3]>();
+ test_is_not_scalar<char[]>();
+ test_is_not_scalar<Union>();
+ test_is_not_scalar<Empty>();
+ test_is_not_scalar<bit_zero>();
+ test_is_not_scalar<NotEmpty>();
+ test_is_not_scalar<Abstract>();
+ test_is_not_scalar<int(int)>();
+}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
index 685d30de692f..36020139ec58 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
@@ -20,6 +20,12 @@ void test_has_virtual_destructor()
static_assert( std::has_virtual_destructor<const T>::value, "");
static_assert( std::has_virtual_destructor<volatile T>::value, "");
static_assert( std::has_virtual_destructor<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::has_virtual_destructor_v<T>, "");
+ static_assert( std::has_virtual_destructor_v<const T>, "");
+ static_assert( std::has_virtual_destructor_v<volatile T>, "");
+ static_assert( std::has_virtual_destructor_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +35,12 @@ void test_has_not_virtual_destructor()
static_assert(!std::has_virtual_destructor<const T>::value, "");
static_assert(!std::has_virtual_destructor<volatile T>::value, "");
static_assert(!std::has_virtual_destructor<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::has_virtual_destructor_v<T>, "");
+ static_assert(!std::has_virtual_destructor_v<const T>, "");
+ static_assert(!std::has_virtual_destructor_v<volatile T>, "");
+ static_assert(!std::has_virtual_destructor_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
index f2a8c23246b1..a54adf10258f 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
@@ -12,6 +12,7 @@
// is_abstract
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_abstract()
@@ -20,6 +21,12 @@ void test_is_abstract()
static_assert( std::is_abstract<const T>::value, "");
static_assert( std::is_abstract<volatile T>::value, "");
static_assert( std::is_abstract<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_abstract_v<T>, "");
+ static_assert( std::is_abstract_v<const T>, "");
+ static_assert( std::is_abstract_v<volatile T>, "");
+ static_assert( std::is_abstract_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_abstract()
static_assert(!std::is_abstract<const T>::value, "");
static_assert(!std::is_abstract<volatile T>::value, "");
static_assert(!std::is_abstract<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_abstract_v<T>, "");
+ static_assert(!std::is_abstract_v<const T>, "");
+ static_assert(!std::is_abstract_v<volatile T>, "");
+ static_assert(!std::is_abstract_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
index d33019bcba9e..c0f6bb9bdfaf 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
@@ -12,6 +12,7 @@
// is_assignable
#include <type_traits>
+#include "test_macros.h"
struct A
{
@@ -26,12 +27,18 @@ template <class T, class U>
void test_is_assignable()
{
static_assert(( std::is_assignable<T, U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_assignable_v<T, U>, "");
+#endif
}
template <class T, class U>
void test_is_not_assignable()
{
static_assert((!std::is_assignable<T, U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert( !std::is_assignable_v<T, U>, "");
+#endif
}
struct D;
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
index 72f2ff458921..7f63ae40aca7 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
@@ -12,6 +12,7 @@
// is_const
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_const()
@@ -20,6 +21,12 @@ void test_is_const()
static_assert( std::is_const<const T>::value, "");
static_assert(!std::is_const<volatile T>::value, "");
static_assert( std::is_const<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_const_v<T>, "");
+ static_assert( std::is_const_v<const T>, "");
+ static_assert(!std::is_const_v<volatile T>, "");
+ static_assert( std::is_const_v<const volatile T>, "");
+#endif
}
int main()
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
index 2b8f7efec602..5401d95532b1 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -13,6 +13,7 @@
// struct is_constructible;
#include <type_traits>
+#include "test_macros.h"
struct A
{
@@ -38,30 +39,45 @@ template <class T>
void test_is_constructible()
{
static_assert( (std::is_constructible<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_constructible_v<T>, "");
+#endif
}
template <class T, class A0>
void test_is_constructible()
{
- static_assert( (std::is_constructible<T, A0>::value), "");
+ static_assert(( std::is_constructible<T, A0>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_constructible_v<T, A0>), "");
+#endif
}
template <class T, class A0, class A1>
void test_is_constructible()
{
- static_assert( (std::is_constructible<T, A0, A1>::value), "");
+ static_assert(( std::is_constructible<T, A0, A1>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_constructible_v<T, A0, A1>), "");
+#endif
}
template <class T>
void test_is_not_constructible()
{
static_assert((!std::is_constructible<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_constructible_v<T>), "");
+#endif
}
template <class T, class A0>
void test_is_not_constructible()
{
static_assert((!std::is_constructible<T, A0>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_constructible_v<T, A0>), "");
+#endif
}
int main()
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
index c43d59479fb2..421f865a623c 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_copy_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_copy_assignable()
{
static_assert(( std::is_copy_assignable<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_copy_assignable_v<T>), "");
+#endif
}
template <class T>
void test_is_not_copy_assignable()
{
static_assert((!std::is_copy_assignable<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_copy_assignable_v<T>), "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
index f878a50c3af5..fe2e01429b22 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
@@ -12,17 +12,24 @@
// is_copy_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_copy_constructible()
{
static_assert( std::is_copy_constructible<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_copy_constructible_v<T>, "");
+#endif
}
template <class T>
void test_is_not_copy_constructible()
{
static_assert(!std::is_copy_constructible<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_copy_constructible_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
index c8d5c42fbf89..7b46eeaab66b 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
@@ -12,6 +12,7 @@
// is_default_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_default_constructible()
@@ -20,6 +21,12 @@ void test_is_default_constructible()
static_assert( std::is_default_constructible<const T>::value, "");
static_assert( std::is_default_constructible<volatile T>::value, "");
static_assert( std::is_default_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_default_constructible_v<T>, "");
+ static_assert( std::is_default_constructible_v<const T>, "");
+ static_assert( std::is_default_constructible_v<volatile T>, "");
+ static_assert( std::is_default_constructible_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_default_constructible()
static_assert(!std::is_default_constructible<const T>::value, "");
static_assert(!std::is_default_constructible<volatile T>::value, "");
static_assert(!std::is_default_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_default_constructible_v<T>, "");
+ static_assert(!std::is_default_constructible_v<const T>, "");
+ static_assert(!std::is_default_constructible_v<volatile T>, "");
+ static_assert(!std::is_default_constructible_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
index 807745ef66c1..60d607aba61c 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
@@ -12,6 +12,7 @@
// is_destructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_destructible()
@@ -20,6 +21,12 @@ void test_is_destructible()
static_assert( std::is_destructible<const T>::value, "");
static_assert( std::is_destructible<volatile T>::value, "");
static_assert( std::is_destructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_destructible_v<T>, "");
+ static_assert( std::is_destructible_v<const T>, "");
+ static_assert( std::is_destructible_v<volatile T>, "");
+ static_assert( std::is_destructible_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_destructible()
static_assert(!std::is_destructible<const T>::value, "");
static_assert(!std::is_destructible<volatile T>::value, "");
static_assert(!std::is_destructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_destructible_v<T>, "");
+ static_assert(!std::is_destructible_v<const T>, "");
+ static_assert(!std::is_destructible_v<volatile T>, "");
+ static_assert(!std::is_destructible_v<const volatile T>, "");
+#endif
}
class Empty {};
@@ -68,6 +81,7 @@ struct PurePublicDestructor { public: virtual ~PurePublicDestruc
struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
+#if TEST_STD_VER >= 11
struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; };
struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; };
struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; };
@@ -75,6 +89,7 @@ struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor(
struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; };
struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; };
struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; };
+#endif
int main()
@@ -99,23 +114,27 @@ int main()
test_is_not_destructible<int[]>();
test_is_not_destructible<void>();
+ test_is_not_destructible<Function>();
+#if TEST_STD_VER >= 11
+ // Test access controlled destructors
test_is_not_destructible<ProtectedDestructor>();
test_is_not_destructible<PrivateDestructor>();
test_is_not_destructible<VirtualProtectedDestructor>();
test_is_not_destructible<VirtualPrivateDestructor>();
test_is_not_destructible<PureProtectedDestructor>();
test_is_not_destructible<PurePrivateDestructor>();
+
+ // Test deleted constructors
test_is_not_destructible<DeletedPublicDestructor>();
test_is_not_destructible<DeletedProtectedDestructor>();
test_is_not_destructible<DeletedPrivateDestructor>();
-
-// test_is_not_destructible<DeletedVirtualPublicDestructor>(); // currently fails due to clang bug #20268
+ //test_is_not_destructible<DeletedVirtualPublicDestructor>(); // previously failed due to clang bug #20268
test_is_not_destructible<DeletedVirtualProtectedDestructor>();
test_is_not_destructible<DeletedVirtualPrivateDestructor>();
-#if __has_feature(cxx_access_control_sfinae)
+ // Test private destructors
test_is_not_destructible<NotEmpty>();
#endif
- test_is_not_destructible<Function>();
+
}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
index 47af3c45cdea..410c1db7244d 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
@@ -12,6 +12,7 @@
// is_empty
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_empty()
@@ -20,6 +21,12 @@ void test_is_empty()
static_assert( std::is_empty<const T>::value, "");
static_assert( std::is_empty<volatile T>::value, "");
static_assert( std::is_empty<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_empty_v<T>, "");
+ static_assert( std::is_empty_v<const T>, "");
+ static_assert( std::is_empty_v<volatile T>, "");
+ static_assert( std::is_empty_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_empty()
static_assert(!std::is_empty<const T>::value, "");
static_assert(!std::is_empty<volatile T>::value, "");
static_assert(!std::is_empty<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_empty_v<T>, "");
+ static_assert(!std::is_empty_v<const T>, "");
+ static_assert(!std::is_empty_v<volatile T>, "");
+ static_assert(!std::is_empty_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
index cf32196213e1..baf85e3e8139 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
@@ -12,6 +12,7 @@
// is_final
#include <type_traits>
+#include "test_macros.h"
#if _LIBCPP_STD_VER > 11
@@ -26,6 +27,12 @@ void test_is_final()
static_assert( std::is_final<const T>::value, "");
static_assert( std::is_final<volatile T>::value, "");
static_assert( std::is_final<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_final_v<T>, "");
+ static_assert( std::is_final_v<const T>, "");
+ static_assert( std::is_final_v<volatile T>, "");
+ static_assert( std::is_final_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -35,6 +42,12 @@ void test_is_not_final()
static_assert(!std::is_final<const T>::value, "");
static_assert(!std::is_final<volatile T>::value, "");
static_assert(!std::is_final<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_final_v<T>, "");
+ static_assert(!std::is_final_v<const T>, "");
+ static_assert(!std::is_final_v<volatile T>, "");
+ static_assert(!std::is_final_v<const volatile T>, "");
+#endif
}
int main ()
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
index ce781cd936b0..59aa5e26a292 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
@@ -12,35 +12,94 @@
// is_literal_type
#include <type_traits>
+#include <cstddef> // for std::nullptr_t
+#include "test_macros.h"
template <class T>
void test_is_literal_type()
{
static_assert( std::is_literal_type<T>::value, "");
+ static_assert( std::is_literal_type<const T>::value, "");
+ static_assert( std::is_literal_type<volatile T>::value, "");
+ static_assert( std::is_literal_type<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_literal_type_v<T>, "");
+ static_assert( std::is_literal_type_v<const T>, "");
+ static_assert( std::is_literal_type_v<volatile T>, "");
+ static_assert( std::is_literal_type_v<const volatile T>, "");
+#endif
}
template <class T>
void test_is_not_literal_type()
{
static_assert(!std::is_literal_type<T>::value, "");
+ static_assert(!std::is_literal_type<const T>::value, "");
+ static_assert(!std::is_literal_type<volatile T>::value, "");
+ static_assert(!std::is_literal_type<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_literal_type_v<T>, "");
+ static_assert(!std::is_literal_type_v<const T>, "");
+ static_assert(!std::is_literal_type_v<volatile T>, "");
+ static_assert(!std::is_literal_type_v<const volatile T>, "");
+#endif
}
-struct A
+class Empty
{
};
-struct B
+class NotEmpty
{
- B();
+ virtual ~NotEmpty();
};
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+enum Enum {zero, one};
+
+typedef void (*FunctionPtr)();
+
int main()
{
- test_is_literal_type<int> ();
- test_is_literal_type<const int> ();
- test_is_literal_type<int&> ();
- test_is_literal_type<volatile int&> ();
- test_is_literal_type<A> ();
+#if TEST_STD_VER >= 11
+ test_is_literal_type<std::nullptr_t>();
+#endif
+
+// Before C++14, void was not a literal type
+// In C++14, cv-void is is a literal type
+#if TEST_STD_VER < 14
+ test_is_not_literal_type<void>();
+#else
+ test_is_literal_type<void>();
+#endif
+
+ test_is_literal_type<int>();
+ test_is_literal_type<int*>();
+ test_is_literal_type<const int*>();
+ test_is_literal_type<int&>();
+#if TEST_STD_VER >= 11
+ test_is_literal_type<int&&>();
+#endif
+ test_is_literal_type<double>();
+ test_is_literal_type<char[3]>();
+ test_is_literal_type<char[]>();
+ test_is_literal_type<Empty>();
+ test_is_literal_type<bit_zero>();
+ test_is_literal_type<Union>();
+ test_is_literal_type<Enum>();
+ test_is_literal_type<FunctionPtr>();
- test_is_not_literal_type<B> ();
+ test_is_not_literal_type<NotEmpty>();
+ test_is_not_literal_type<Abstract>();
}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
index a89ee7d4e490..613c1123e3fa 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_move_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_move_assignable()
{
- static_assert( std::is_move_assignable<T>::value, "");
+ static_assert(( std::is_move_assignable<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_move_assignable_v<T>), "");
+#endif
}
template <class T>
void test_is_not_move_assignable()
{
- static_assert(!std::is_move_assignable<T>::value, "");
+ static_assert((!std::is_move_assignable<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_move_assignable_v<T>), "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
index 7409ebaa56c8..07c283bf8890 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
@@ -12,17 +12,24 @@
// is_move_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_move_constructible()
{
static_assert( std::is_move_constructible<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_move_constructible_v<T>, "");
+#endif
}
template <class T>
void test_is_not_move_constructible()
{
static_assert(!std::is_move_constructible<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_move_constructible_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
index 8fff5f8b3de3..9d629dc7ef46 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_nothrow_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T, class U>
void test_is_nothrow_assignable()
{
static_assert(( std::is_nothrow_assignable<T, U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_nothrow_assignable_v<T, U>), "");
+#endif
}
template <class T, class U>
void test_is_not_nothrow_assignable()
{
static_assert((!std::is_nothrow_assignable<T, U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_nothrow_assignable_v<T, U>), "");
+#endif
}
struct A
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
index fe0b5673bc44..c778a5d24b2e 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
@@ -13,35 +13,51 @@
// struct is_nothrow_constructible;
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_nothrow_constructible()
{
static_assert(( std::is_nothrow_constructible<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_nothrow_constructible_v<T>), "");
+#endif
}
template <class T, class A0>
void test_is_nothrow_constructible()
{
static_assert(( std::is_nothrow_constructible<T, A0>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_nothrow_constructible_v<T, A0>), "");
+#endif
}
template <class T>
void test_is_not_nothrow_constructible()
{
static_assert((!std::is_nothrow_constructible<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_nothrow_constructible_v<T>), "");
+#endif
}
template <class T, class A0>
void test_is_not_nothrow_constructible()
{
static_assert((!std::is_nothrow_constructible<T, A0>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_nothrow_constructible_v<T, A0>), "");
+#endif
}
template <class T, class A0, class A1>
void test_is_not_nothrow_constructible()
{
static_assert((!std::is_nothrow_constructible<T, A0, A1>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_nothrow_constructible_v<T, A0, A1>), "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
index d843803cf21d..01c9bd0d0941 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_nothrow_copy_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_has_nothrow_assign()
{
static_assert( std::is_nothrow_copy_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_copy_assignable_v<T>, "");
+#endif
}
template <class T>
void test_has_not_nothrow_assign()
{
static_assert(!std::is_nothrow_copy_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_nothrow_copy_assignable_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
index 99fce65dcc7e..9dbdc4e2acfb 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
@@ -12,12 +12,17 @@
// is_nothrow_copy_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_nothrow_copy_constructible()
{
static_assert( std::is_nothrow_copy_constructible<T>::value, "");
static_assert( std::is_nothrow_copy_constructible<const T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_copy_constructible_v<T>, "");
+ static_assert( std::is_nothrow_copy_constructible_v<const T>, "");
+#endif
}
template <class T>
@@ -27,6 +32,12 @@ void test_has_not_nothrow_copy_constructor()
static_assert(!std::is_nothrow_copy_constructible<const T>::value, "");
static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, "");
static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_nothrow_copy_constructible_v<T>, "");
+ static_assert(!std::is_nothrow_copy_constructible_v<const T>, "");
+ static_assert(!std::is_nothrow_copy_constructible_v<volatile T>, "");
+ static_assert(!std::is_nothrow_copy_constructible_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
index 1550dff08bb5..c89ac8944a93 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
@@ -12,6 +12,7 @@
// is_nothrow_default_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_nothrow_default_constructible()
@@ -20,6 +21,12 @@ void test_is_nothrow_default_constructible()
static_assert( std::is_nothrow_default_constructible<const T>::value, "");
static_assert( std::is_nothrow_default_constructible<volatile T>::value, "");
static_assert( std::is_nothrow_default_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_default_constructible_v<T>, "");
+ static_assert( std::is_nothrow_default_constructible_v<const T>, "");
+ static_assert( std::is_nothrow_default_constructible_v<volatile T>, "");
+ static_assert( std::is_nothrow_default_constructible_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_has_not_nothrow_default_constructor()
static_assert(!std::is_nothrow_default_constructible<const T>::value, "");
static_assert(!std::is_nothrow_default_constructible<volatile T>::value, "");
static_assert(!std::is_nothrow_default_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_nothrow_default_constructible_v<T>, "");
+ static_assert(!std::is_nothrow_default_constructible_v<const T>, "");
+ static_assert(!std::is_nothrow_default_constructible_v<volatile T>, "");
+ static_assert(!std::is_nothrow_default_constructible_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
index 8fd5bab5a019..42c9807efa83 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
@@ -12,6 +12,7 @@
// is_nothrow_destructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_nothrow_destructible()
@@ -20,6 +21,12 @@ void test_is_nothrow_destructible()
static_assert( std::is_nothrow_destructible<const T>::value, "");
static_assert( std::is_nothrow_destructible<volatile T>::value, "");
static_assert( std::is_nothrow_destructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_destructible_v<T>, "");
+ static_assert( std::is_nothrow_destructible_v<const T>, "");
+ static_assert( std::is_nothrow_destructible_v<volatile T>, "");
+ static_assert( std::is_nothrow_destructible_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,16 +36,31 @@ void test_is_not_nothrow_destructible()
static_assert(!std::is_nothrow_destructible<const T>::value, "");
static_assert(!std::is_nothrow_destructible<volatile T>::value, "");
static_assert(!std::is_nothrow_destructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_nothrow_destructible_v<T>, "");
+ static_assert(!std::is_nothrow_destructible_v<const T>, "");
+ static_assert(!std::is_nothrow_destructible_v<volatile T>, "");
+ static_assert(!std::is_nothrow_destructible_v<const volatile T>, "");
+#endif
}
+
+struct PublicDestructor { public: ~PublicDestructor() {}};
+struct ProtectedDestructor { protected: ~ProtectedDestructor() {}};
+struct PrivateDestructor { private: ~PrivateDestructor() {}};
+
+struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}};
+struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}};
+struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}};
+
+struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; };
+struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
+struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
+
class Empty
{
};
-class NotEmpty
-{
- virtual ~NotEmpty();
-};
union Union {};
@@ -52,40 +74,36 @@ class Abstract
virtual void foo() = 0;
};
-class AbstractDestructor
-{
- virtual ~AbstractDestructor() = 0;
-};
-
-struct A
-{
- ~A();
-};
int main()
{
test_is_not_nothrow_destructible<void>();
- test_is_not_nothrow_destructible<AbstractDestructor>();
- test_is_not_nothrow_destructible<NotEmpty>();
test_is_not_nothrow_destructible<char[]>();
+ test_is_not_nothrow_destructible<char[][3]>();
-#if __has_feature(cxx_noexcept)
- test_is_nothrow_destructible<A>();
-#endif
test_is_nothrow_destructible<int&>();
-#if __has_feature(cxx_unrestricted_unions)
- test_is_nothrow_destructible<Union>();
-#endif
-#if __has_feature(cxx_access_control_sfinae)
- test_is_nothrow_destructible<Empty>();
-#endif
test_is_nothrow_destructible<int>();
test_is_nothrow_destructible<double>();
test_is_nothrow_destructible<int*>();
test_is_nothrow_destructible<const int*>();
test_is_nothrow_destructible<char[3]>();
- test_is_nothrow_destructible<Abstract>();
-#if __has_feature(cxx_noexcept)
+
+#if TEST_STD_VER >= 11
+ // requires noexcept. These are all destructible.
+ test_is_nothrow_destructible<PublicDestructor>();
+ test_is_nothrow_destructible<VirtualPublicDestructor>();
+ test_is_nothrow_destructible<PurePublicDestructor>();
test_is_nothrow_destructible<bit_zero>();
+ test_is_nothrow_destructible<Abstract>();
+ test_is_nothrow_destructible<Empty>();
+ test_is_nothrow_destructible<Union>();
+
+ // requires access control
+ test_is_not_nothrow_destructible<ProtectedDestructor>();
+ test_is_not_nothrow_destructible<PrivateDestructor>();
+ test_is_not_nothrow_destructible<VirtualProtectedDestructor>();
+ test_is_not_nothrow_destructible<VirtualPrivateDestructor>();
+ test_is_not_nothrow_destructible<PureProtectedDestructor>();
+ test_is_not_nothrow_destructible<PurePrivateDestructor>();
#endif
}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
index fe51e438864f..11852f6aec98 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
@@ -12,17 +12,24 @@
// has_nothrow_move_assign
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_has_nothrow_assign()
{
static_assert( std::is_nothrow_move_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_move_assignable_v<T>, "");
+#endif
}
template <class T>
void test_has_not_nothrow_assign()
{
static_assert(!std::is_nothrow_move_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_nothrow_move_assignable_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
index f5a42afe0d50..b93dbb634e4d 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
@@ -12,12 +12,17 @@
// has_nothrow_move_constructor
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_nothrow_move_constructible()
{
static_assert( std::is_nothrow_move_constructible<T>::value, "");
static_assert( std::is_nothrow_move_constructible<const T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_nothrow_move_constructible_v<T>, "");
+ static_assert( std::is_nothrow_move_constructible_v<const T>, "");
+#endif
}
template <class T>
@@ -27,6 +32,12 @@ void test_has_not_nothrow_move_constructor()
static_assert(!std::is_nothrow_move_constructible<const T>::value, "");
static_assert(!std::is_nothrow_move_constructible<volatile T>::value, "");
static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_nothrow_move_constructible_v<T>, "");
+ static_assert(!std::is_nothrow_move_constructible_v<const T>, "");
+ static_assert(!std::is_nothrow_move_constructible_v<volatile T>, "");
+ static_assert(!std::is_nothrow_move_constructible_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
index 4ec1ae9949ef..2ca2b8640141 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
@@ -12,6 +12,7 @@
// is_pod
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_pod()
@@ -20,6 +21,12 @@ void test_is_pod()
static_assert( std::is_pod<const T>::value, "");
static_assert( std::is_pod<volatile T>::value, "");
static_assert( std::is_pod<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_pod_v<T>, "");
+ static_assert( std::is_pod_v<const T>, "");
+ static_assert( std::is_pod_v<volatile T>, "");
+ static_assert( std::is_pod_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_pod()
static_assert(!std::is_pod<const T>::value, "");
static_assert(!std::is_pod<volatile T>::value, "");
static_assert(!std::is_pod<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_pod_v<T>, "");
+ static_assert(!std::is_pod_v<const T>, "");
+ static_assert(!std::is_pod_v<volatile T>, "");
+ static_assert(!std::is_pod_v<const volatile T>, "");
+#endif
}
class Class
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
index 6e82cddc5166..b66e7a296f39 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
@@ -12,6 +12,7 @@
// is_polymorphic
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_polymorphic()
@@ -20,6 +21,12 @@ void test_is_polymorphic()
static_assert( std::is_polymorphic<const T>::value, "");
static_assert( std::is_polymorphic<volatile T>::value, "");
static_assert( std::is_polymorphic<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_polymorphic_v<T>, "");
+ static_assert( std::is_polymorphic_v<const T>, "");
+ static_assert( std::is_polymorphic_v<volatile T>, "");
+ static_assert( std::is_polymorphic_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_polymorphic()
static_assert(!std::is_polymorphic<const T>::value, "");
static_assert(!std::is_polymorphic<volatile T>::value, "");
static_assert(!std::is_polymorphic<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_polymorphic_v<T>, "");
+ static_assert(!std::is_polymorphic_v<const T>, "");
+ static_assert(!std::is_polymorphic_v<volatile T>, "");
+ static_assert(!std::is_polymorphic_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
index 479c2529f02a..94bf7fb58041 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
@@ -12,6 +12,7 @@
// is_signed
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_signed()
@@ -20,6 +21,12 @@ void test_is_signed()
static_assert( std::is_signed<const T>::value, "");
static_assert( std::is_signed<volatile T>::value, "");
static_assert( std::is_signed<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_signed_v<T>, "");
+ static_assert( std::is_signed_v<const T>, "");
+ static_assert( std::is_signed_v<volatile T>, "");
+ static_assert( std::is_signed_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_signed()
static_assert(!std::is_signed<const T>::value, "");
static_assert(!std::is_signed<volatile T>::value, "");
static_assert(!std::is_signed<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_signed_v<T>, "");
+ static_assert(!std::is_signed_v<const T>, "");
+ static_assert(!std::is_signed_v<volatile T>, "");
+ static_assert(!std::is_signed_v<const volatile T>, "");
+#endif
}
class Class
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
index 668c4cdc7dd6..6e601c1ac04b 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
@@ -12,6 +12,7 @@
// is_standard_layout
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_standard_layout()
@@ -20,6 +21,12 @@ void test_is_standard_layout()
static_assert( std::is_standard_layout<const T>::value, "");
static_assert( std::is_standard_layout<volatile T>::value, "");
static_assert( std::is_standard_layout<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_standard_layout_v<T>, "");
+ static_assert( std::is_standard_layout_v<const T>, "");
+ static_assert( std::is_standard_layout_v<volatile T>, "");
+ static_assert( std::is_standard_layout_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_standard_layout()
static_assert(!std::is_standard_layout<const T>::value, "");
static_assert(!std::is_standard_layout<volatile T>::value, "");
static_assert(!std::is_standard_layout<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_standard_layout_v<T>, "");
+ static_assert(!std::is_standard_layout_v<const T>, "");
+ static_assert(!std::is_standard_layout_v<volatile T>, "");
+ static_assert(!std::is_standard_layout_v<const volatile T>, "");
+#endif
}
template <class T1, class T2>
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
index af38699d881b..2d2df14d3bbc 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
@@ -12,6 +12,7 @@
// is_trivial
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_trivial()
@@ -20,6 +21,12 @@ void test_is_trivial()
static_assert( std::is_trivial<const T>::value, "");
static_assert( std::is_trivial<volatile T>::value, "");
static_assert( std::is_trivial<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivial_v<T>, "");
+ static_assert( std::is_trivial_v<const T>, "");
+ static_assert( std::is_trivial_v<volatile T>, "");
+ static_assert( std::is_trivial_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_trivial()
static_assert(!std::is_trivial<const T>::value, "");
static_assert(!std::is_trivial<volatile T>::value, "");
static_assert(!std::is_trivial<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivial_v<T>, "");
+ static_assert(!std::is_trivial_v<const T>, "");
+ static_assert(!std::is_trivial_v<volatile T>, "");
+ static_assert(!std::is_trivial_v<const volatile T>, "");
+#endif
}
struct A {};
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
index 735d05fa6ee4..3ebb9dba429d 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_trivially_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T, class U>
void test_is_trivially_assignable()
{
static_assert(( std::is_trivially_assignable<T, U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_trivially_assignable_v<T, U>), "");
+#endif
}
template <class T, class U>
void test_is_not_trivially_assignable()
{
static_assert((!std::is_trivially_assignable<T, U>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_trivially_assignable_v<T, U>), "");
+#endif
}
struct A
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
index 4171d4d32f5d..212245f00691 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
@@ -13,35 +13,51 @@
// struct is_trivially_constructible;
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_trivially_constructible()
{
static_assert(( std::is_trivially_constructible<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_trivially_constructible_v<T>), "");
+#endif
}
template <class T, class A0>
void test_is_trivially_constructible()
{
static_assert(( std::is_trivially_constructible<T, A0>::value), "");
+#if TEST_STD_VER > 14
+ static_assert(( std::is_trivially_constructible_v<T, A0>), "");
+#endif
}
template <class T>
void test_is_not_trivially_constructible()
{
static_assert((!std::is_trivially_constructible<T>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_trivially_constructible_v<T>), "");
+#endif
}
template <class T, class A0>
void test_is_not_trivially_constructible()
{
static_assert((!std::is_trivially_constructible<T, A0>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_trivially_constructible_v<T, A0>), "");
+#endif
}
template <class T, class A0, class A1>
void test_is_not_trivially_constructible()
{
static_assert((!std::is_trivially_constructible<T, A0, A1>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((!std::is_trivially_constructible_v<T, A0, A1>), "");
+#endif
}
struct A
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
index 7d72565e40ca..25429f5470e7 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_trivially_copy_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_has_trivially_copy_assignable()
{
static_assert( std::is_trivially_copy_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_copy_assignable_v<T>, "");
+#endif
}
template <class T>
void test_has_not_trivially_copy_assignable()
{
static_assert(!std::is_trivially_copy_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_copy_assignable_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
index 6bd78ec9e7a1..9556959e1262 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
@@ -12,12 +12,17 @@
// is_trivially_copy_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_trivially_copy_constructible()
{
static_assert( std::is_trivially_copy_constructible<T>::value, "");
static_assert( std::is_trivially_copy_constructible<const T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_copy_constructible_v<T>, "");
+ static_assert( std::is_trivially_copy_constructible_v<const T>, "");
+#endif
}
template <class T>
@@ -25,6 +30,10 @@ void test_has_not_trivial_copy_constructor()
{
static_assert(!std::is_trivially_copy_constructible<T>::value, "");
static_assert(!std::is_trivially_copy_constructible<const T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_copy_constructible_v<T>, "");
+ static_assert(!std::is_trivially_copy_constructible_v<const T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
index d65882378fc4..c19a29ffb586 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -13,6 +13,7 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
template <class T>
void test_is_trivially_copyable()
@@ -21,6 +22,12 @@ void test_is_trivially_copyable()
static_assert( std::is_trivially_copyable<const T>::value, "");
static_assert(!std::is_trivially_copyable<volatile T>::value, "");
static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_copyable_v<T>, "");
+ static_assert( std::is_trivially_copyable_v<const T>, "");
+ static_assert(!std::is_trivially_copyable_v<volatile T>, "");
+ static_assert(!std::is_trivially_copyable_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -30,6 +37,12 @@ void test_is_not_trivially_copyable()
static_assert(!std::is_trivially_copyable<const T>::value, "");
static_assert(!std::is_trivially_copyable<volatile T>::value, "");
static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_copyable_v<T>, "");
+ static_assert(!std::is_trivially_copyable_v<const T>, "");
+ static_assert(!std::is_trivially_copyable_v<volatile T>, "");
+ static_assert(!std::is_trivially_copyable_v<const volatile T>, "");
+#endif
}
struct A
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
index 1f63401dacb7..2d367159ca30 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
@@ -12,6 +12,7 @@
// is_trivially_default_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_trivially_default_constructible()
@@ -20,6 +21,12 @@ void test_is_trivially_default_constructible()
static_assert( std::is_trivially_default_constructible<const T>::value, "");
static_assert( std::is_trivially_default_constructible<volatile T>::value, "");
static_assert( std::is_trivially_default_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_default_constructible_v<T>, "");
+ static_assert( std::is_trivially_default_constructible_v<const T>, "");
+ static_assert( std::is_trivially_default_constructible_v<volatile T>, "");
+ static_assert( std::is_trivially_default_constructible_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_has_not_trivial_default_constructor()
static_assert(!std::is_trivially_default_constructible<const T>::value, "");
static_assert(!std::is_trivially_default_constructible<volatile T>::value, "");
static_assert(!std::is_trivially_default_constructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_default_constructible_v<T>, "");
+ static_assert(!std::is_trivially_default_constructible_v<const T>, "");
+ static_assert(!std::is_trivially_default_constructible_v<volatile T>, "");
+ static_assert(!std::is_trivially_default_constructible_v<const volatile T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
index b18ace44bda1..9e2507067d2d 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
@@ -12,6 +12,7 @@
// is_trivially_destructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_trivially_destructible()
@@ -20,6 +21,12 @@ void test_is_trivially_destructible()
static_assert( std::is_trivially_destructible<const T>::value, "");
static_assert( std::is_trivially_destructible<volatile T>::value, "");
static_assert( std::is_trivially_destructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_destructible_v<T>, "");
+ static_assert( std::is_trivially_destructible_v<const T>, "");
+ static_assert( std::is_trivially_destructible_v<volatile T>, "");
+ static_assert( std::is_trivially_destructible_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,15 +36,29 @@ void test_is_not_trivially_destructible()
static_assert(!std::is_trivially_destructible<const T>::value, "");
static_assert(!std::is_trivially_destructible<volatile T>::value, "");
static_assert(!std::is_trivially_destructible<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_destructible_v<T>, "");
+ static_assert(!std::is_trivially_destructible_v<const T>, "");
+ static_assert(!std::is_trivially_destructible_v<volatile T>, "");
+ static_assert(!std::is_trivially_destructible_v<const volatile T>, "");
+#endif
}
-class Empty
-{
-};
+struct PublicDestructor { public: ~PublicDestructor() {}};
+struct ProtectedDestructor { protected: ~ProtectedDestructor() {}};
+struct PrivateDestructor { private: ~PrivateDestructor() {}};
+
+struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}};
+struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}};
+struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}};
+
+struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; };
+struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; };
+struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; };
-class NotEmpty
+
+class Empty
{
- virtual ~NotEmpty();
};
union Union {};
@@ -66,18 +87,28 @@ int main()
{
test_is_not_trivially_destructible<void>();
test_is_not_trivially_destructible<A>();
- test_is_not_trivially_destructible<AbstractDestructor>();
- test_is_not_trivially_destructible<NotEmpty>();
test_is_not_trivially_destructible<char[]>();
+ test_is_not_trivially_destructible<VirtualPublicDestructor>();
+ test_is_not_trivially_destructible<PurePublicDestructor>();
test_is_trivially_destructible<Abstract>();
- test_is_trivially_destructible<int&>();
test_is_trivially_destructible<Union>();
test_is_trivially_destructible<Empty>();
+ test_is_trivially_destructible<int&>();
test_is_trivially_destructible<int>();
test_is_trivially_destructible<double>();
test_is_trivially_destructible<int*>();
test_is_trivially_destructible<const int*>();
test_is_trivially_destructible<char[3]>();
test_is_trivially_destructible<bit_zero>();
+
+#if TEST_STD_VER >= 11
+ // requires access control sfinae
+ test_is_not_trivially_destructible<ProtectedDestructor>();
+ test_is_not_trivially_destructible<PrivateDestructor>();
+ test_is_not_trivially_destructible<VirtualProtectedDestructor>();
+ test_is_not_trivially_destructible<VirtualPrivateDestructor>();
+ test_is_not_trivially_destructible<PureProtectedDestructor>();
+ test_is_not_trivially_destructible<PurePrivateDestructor>();
+#endif
}
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
index c3fc7ac0a3df..eca596ee1c19 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
@@ -12,17 +12,24 @@
// is_trivially_move_assignable
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_has_trivial_assign()
{
static_assert( std::is_trivially_move_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_move_assignable_v<T>, "");
+#endif
}
template <class T>
void test_has_not_trivial_assign()
{
static_assert(!std::is_trivially_move_assignable<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_move_assignable_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
index 54cb5e853a81..313da175f715 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
@@ -12,17 +12,24 @@
// is_trivially_move_constructible
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_trivially_move_constructible()
{
static_assert( std::is_trivially_move_constructible<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_trivially_move_constructible_v<T>, "");
+#endif
}
template <class T>
void test_has_not_trivial_move_constructor()
{
static_assert(!std::is_trivially_move_constructible<T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_trivially_move_constructible_v<T>, "");
+#endif
}
class Empty
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
index dfdb15542610..9ca42432df16 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
@@ -12,6 +12,7 @@
// is_unsigned
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_unsigned()
@@ -20,6 +21,12 @@ void test_is_unsigned()
static_assert( std::is_unsigned<const T>::value, "");
static_assert( std::is_unsigned<volatile T>::value, "");
static_assert( std::is_unsigned<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert( std::is_unsigned_v<T>, "");
+ static_assert( std::is_unsigned_v<const T>, "");
+ static_assert( std::is_unsigned_v<volatile T>, "");
+ static_assert( std::is_unsigned_v<const volatile T>, "");
+#endif
}
template <class T>
@@ -29,6 +36,12 @@ void test_is_not_unsigned()
static_assert(!std::is_unsigned<const T>::value, "");
static_assert(!std::is_unsigned<volatile T>::value, "");
static_assert(!std::is_unsigned<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_unsigned_v<T>, "");
+ static_assert(!std::is_unsigned_v<const T>, "");
+ static_assert(!std::is_unsigned_v<volatile T>, "");
+ static_assert(!std::is_unsigned_v<const volatile T>, "");
+#endif
}
class Class
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
index f6805bc1c4ff..36697a3f3eba 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
@@ -12,6 +12,7 @@
// is_volatile
#include <type_traits>
+#include "test_macros.h"
template <class T>
void test_is_volatile()
@@ -20,6 +21,12 @@ void test_is_volatile()
static_assert(!std::is_volatile<const T>::value, "");
static_assert( std::is_volatile<volatile T>::value, "");
static_assert( std::is_volatile<const volatile T>::value, "");
+#if TEST_STD_VER > 14
+ static_assert(!std::is_volatile_v<T>, "");
+ static_assert(!std::is_volatile_v<const T>, "");
+ static_assert( std::is_volatile_v<volatile T>, "");
+ static_assert( std::is_volatile_v<const volatile T>, "");
+#endif
}
int main()
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
index 78027f7e48b8..9331b7094f48 100644
--- a/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
@@ -11,46 +11,57 @@
#include <ratio>
+#include "test_macros.h"
+
+template <class Rat1, class Rat2, bool result>
+void test()
+{
+ static_assert((result == std::ratio_equal<Rat1, Rat2>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((result == std::ratio_equal_v<Rat1, Rat2>), "");
+#endif
+}
+
int main()
{
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, 1> R2;
- static_assert((std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, -1> R2;
- static_assert((!std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((!std::ratio_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
index 9182a9ec503c..7f7a74068299 100644
--- a/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
@@ -11,46 +11,57 @@
#include <ratio>
+#include "test_macros.h"
+
+template <class Rat1, class Rat2, bool result>
+void test()
+{
+ static_assert((result == std::ratio_greater<Rat1, Rat2>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((result == std::ratio_greater_v<Rat1, Rat2>), "");
+#endif
+}
+
int main()
{
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, 1> R2;
- static_assert((!std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((!std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, -1> R2;
- static_assert((std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((std::ratio_greater<R1, R2>::value), "");
+ test<R1, R2, true>();
}
}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
index a1f5a185e621..db78557ec4c1 100644
--- a/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
@@ -11,46 +11,57 @@
#include <ratio>
+#include "test_macros.h"
+
+template <class Rat1, class Rat2, bool result>
+void test()
+{
+ static_assert((result == std::ratio_greater_equal<Rat1, Rat2>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((result == std::ratio_greater_equal_v<Rat1, Rat2>), "");
+#endif
+}
+
int main()
{
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, 1> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, -1> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
index db53ab0ad448..a428be28aa56 100644
--- a/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
@@ -11,76 +11,87 @@
#include <ratio>
+#include "test_macros.h"
+
+template <class Rat1, class Rat2, bool result>
+void test()
+{
+ static_assert((result == std::ratio_less<Rat1, Rat2>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((result == std::ratio_less_v<Rat1, Rat2>), "");
+#endif
+}
+
int main()
{
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, 1> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, -1> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2;
- static_assert((std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
- static_assert((std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2;
- static_assert((std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<641981, 1339063> R1;
typedef std::ratio<1291640, 2694141LL> R2;
- static_assert((!std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1291640, 2694141LL> R1;
typedef std::ratio<641981, 1339063> R2;
- static_assert((std::ratio_less<R1, R2>::value), "");
+ test<R1, R2, true>();
}
}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
index 5b148f0e1435..7b224ab7c892 100644
--- a/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
@@ -11,46 +11,57 @@
#include <ratio>
+#include "test_macros.h"
+
+template <class Rat1, class Rat2, bool result>
+void test()
+{
+ static_assert((result == std::ratio_less_equal<Rat1, Rat2>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((result == std::ratio_less_equal_v<Rat1, Rat2>), "");
+#endif
+}
+
int main()
{
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, 1> R2;
- static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, -1> R2;
- static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
}
diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
index ebf930746585..fcd31207fdbf 100644
--- a/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
+++ b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
@@ -11,46 +11,57 @@
#include <ratio>
+#include "test_macros.h"
+
+template <class Rat1, class Rat2, bool result>
+void test()
+{
+ static_assert((result == std::ratio_not_equal<Rat1, Rat2>::value), "");
+#if TEST_STD_VER > 14
+ static_assert((result == std::ratio_not_equal_v<Rat1, Rat2>), "");
+#endif
+}
+
int main()
{
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, 1> R2;
- static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, false>();
}
{
typedef std::ratio<1, 1> R1;
typedef std::ratio<1, -1> R2;
- static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
- static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
{
typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
- static_assert((std::ratio_not_equal<R1, R2>::value), "");
+ test<R1, R2, true>();
}
}
diff --git a/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
index 7fe78bad1cc6..9411435e29e8 100644
--- a/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// template <class charT>
// explicit bitset(const charT* str,
// typename basic_string<charT>::size_type n = basic_string<charT>::npos,
@@ -14,6 +15,8 @@
#include <bitset>
#include <cassert>
+#include <algorithm> // for 'min' and 'max'
+#include <stdexcept> // for 'invalid_argument'
#pragma clang diagnostic ignored "-Wtautological-compare"
diff --git a/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
index bcee50c4c63a..b08720f57ee3 100644
--- a/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
@@ -7,10 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// test bitset(string, pos, n, zero, one);
#include <bitset>
#include <cassert>
+#include <algorithm> // for 'min' and 'max'
+#include <stdexcept> // for 'invalid_argument'
#pragma clang diagnostic ignored "-Wtautological-compare"
diff --git a/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
index 023fedc25839..f232447e08c3 100644
--- a/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
@@ -11,6 +11,7 @@
#include <bitset>
#include <cassert>
+#include <algorithm> // for 'min' and 'max'
#pragma clang diagnostic ignored "-Wtautological-compare"
diff --git a/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
index 3e09b202097d..cffca68fb1ea 100644
--- a/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// test bitset<N>& flip(size_t pos);
#include <bitset>
diff --git a/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
index ebaa9e7a8d72..6de256b00cc5 100644
--- a/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// test bitset<N>& reset(size_t pos);
#include <bitset>
diff --git a/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
index 116eaf3f46e0..debe5431d8d0 100644
--- a/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// test bitset<N>& set(size_t pos, bool val = true);
#include <bitset>
diff --git a/test/std/utilities/template.bitset/bitset.members/test.pass.cpp b/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
index 5102b46171a2..ce594d0ae891 100644
--- a/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// test constexpr bool test(size_t pos) const;
#include <bitset>
diff --git a/test/std/utilities/date.time/tested_elsewhere.pass.cpp b/test/std/utilities/time/date.time/ctime.pass.cpp
index 419f415dee19..d0a838e0c271 100644
--- a/test/std/utilities/date.time/tested_elsewhere.pass.cpp
+++ b/test/std/utilities/time/date.time/ctime.pass.cpp
@@ -30,9 +30,11 @@ int main()
static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+#endif
static_assert((std::is_same<decltype(std::strftime(str,s,"",&tm)), std::size_t>::value), "");
}
diff --git a/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp b/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp
new file mode 100644
index 000000000000..221004c568ce
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class Rep, class Period>
+// constexpr duration<Rep, Period> abs(duration<Rep, Period> d)
+
+// This function shall not participate in overload resolution unless numeric_limits<Rep>::is_signed is true.
+
+#include <chrono>
+
+typedef std::chrono::duration<unsigned> unsigned_secs;
+
+int main()
+{
+ std::chrono::abs(unsigned_secs(0));
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp b/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
new file mode 100644
index 000000000000..ec32c37a9423
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <chrono>
+
+// abs
+
+// template <class Rep, class Period>
+// constexpr duration<Rep, Period> abs(duration<Rep, Period> d)
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class Duration>
+void
+test(const Duration& f, const Duration& d)
+{
+ {
+ typedef decltype(std::chrono::abs(f)) R;
+ static_assert((std::is_same<R, Duration>::value), "");
+ assert(std::chrono::abs(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::milliseconds( 7290000));
+ test(std::chrono::milliseconds(-7290000), std::chrono::milliseconds( 7290000));
+ test(std::chrono::minutes( 122), std::chrono::minutes( 122));
+ test(std::chrono::minutes(-122), std::chrono::minutes( 122));
+ test(std::chrono::hours(0), std::chrono::hours(0));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::abs(std::chrono::hours(-3));
+ static_assert(h1.count() == 3, "");
+ constexpr std::chrono::hours h2 = std::chrono::abs(std::chrono::hours(3));
+ static_assert(h2.count() == 3, "");
+ }
+}
diff --git a/test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp
index c9e55c8fd3a6..909e8573247c 100644
--- a/test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp
+++ b/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp
@@ -7,12 +7,20 @@
//
//===----------------------------------------------------------------------===//
-// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
-#include <ctime>
+// ceil
-int main() {
- // localtime is not thread-safe.
- std::time_t t = 0;
- std::localtime(&t);
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// ceil(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::ceil<int>(std::chrono::milliseconds(3));
}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp
new file mode 100644
index 000000000000..6fb73b97db17
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// ceil(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::ceil<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::ceil<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::ceil<std::chrono::hours>(std::chrono::milliseconds(9000000));
+ static_assert(h1.count() == 3, "");
+ constexpr std::chrono::hours h2 = std::chrono::ceil<std::chrono::hours>(std::chrono::milliseconds(-9000000));
+ static_assert(h2.count() == -2, "");
+ }
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp
new file mode 100644
index 000000000000..14d9ca878df8
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// floor(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::floor<int>(std::chrono::milliseconds(3));
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp
new file mode 100644
index 000000000000..57929dd91228
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// floor(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::floor<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::floor<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-3));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 121));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::floor<std::chrono::hours>(std::chrono::milliseconds(9000000));
+ static_assert(h1.count() == 2, "");
+ constexpr std::chrono::hours h2 = std::chrono::floor<std::chrono::hours>(std::chrono::milliseconds(-9000000));
+ static_assert(h2.count() == -3, "");
+ }
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp
new file mode 100644
index 000000000000..6f9f5bd29b63
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Rep, class Period>
+// ToDuration
+// round(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::round<int>(std::chrono::milliseconds(3));
+}
diff --git a/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp
new file mode 100644
index 000000000000..e50b85c991a2
--- /dev/null
+++ b/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Rep, class Period>
+// constexpr
+// ToDuration
+// ceil(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+ {
+ typedef decltype(std::chrono::round<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToDuration>::value), "");
+ assert(std::chrono::round<ToDuration>(f) == d);
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+ {
+// 9000000ms is 2 hours and 30 minutes
+ constexpr std::chrono::hours h1 = std::chrono::round<std::chrono::hours>(std::chrono::milliseconds(9000000));
+ static_assert(h1.count() == 2, "");
+ constexpr std::chrono::hours h2 = std::chrono::round<std::chrono::hours>(std::chrono::milliseconds(-9000000));
+ static_assert(h2.count() == -2, "");
+ }
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp
new file mode 100644
index 000000000000..1c92d75b97ca
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// ceil(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::ceil<int>(std::chrono::system_clock::now());
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp
new file mode 100644
index 000000000000..379929c7f2d8
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// ceil
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// ceil(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+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::ceil<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::ceil<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::ceil<ToDuration>(f) == t, "");
+ }
+}
+
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121));
+
+// 9000000ms is 2 hours and 30 minutes
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::hours, 3> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::hours, -2> ();
+ test_constexpr<std::chrono::milliseconds, 9000001, std::chrono::minutes, 151> ();
+ test_constexpr<std::chrono::milliseconds,-9000001, std::chrono::minutes,-150> ();
+
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::seconds, 9000> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::seconds,-9000> ();
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp
new file mode 100644
index 000000000000..ea48e1219e34
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// floor(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::floor<int>(std::chrono::system_clock::now());
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp
new file mode 100644
index 000000000000..d0a908fa932a
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// floor
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// floor(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+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::floor<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::floor<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::floor<ToDuration>(f) == t, "");
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-3));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 121));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+// 9000000ms is 2 hours and 30 minutes
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::hours, 2> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::hours, -3> ();
+ test_constexpr<std::chrono::milliseconds, 9000001, std::chrono::minutes, 150> ();
+ test_constexpr<std::chrono::milliseconds,-9000001, std::chrono::minutes,-151> ();
+
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::seconds, 9000> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::seconds,-9000> ();
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp
new file mode 100644
index 000000000000..53c14f47de69
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// round(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+ std::chrono::round<int>(std::chrono::system_clock::now());
+}
diff --git a/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp
new file mode 100644
index 000000000000..ab8bf3a75e79
--- /dev/null
+++ b/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <chrono>
+
+// round
+
+// template <class ToDuration, class Clock, class Duration>
+// time_point<Clock, ToDuration>
+// round(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+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::round<ToDuration>(f)) R;
+ static_assert((std::is_same<R, ToTimePoint>::value), "");
+ assert(std::chrono::round<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::round<ToDuration>(f) == t, "");
+ }
+}
+
+int main()
+{
+// 7290000ms is 2 hours, 1 minute, and 30 seconds
+ test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
+ test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
+ test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
+ test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
+
+// 9000000ms is 2 hours and 30 minutes
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::hours, 2> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::hours, -2> ();
+ test_constexpr<std::chrono::milliseconds, 9000001, std::chrono::minutes, 150> ();
+ test_constexpr<std::chrono::milliseconds,-9000001, std::chrono::minutes,-150> ();
+
+ test_constexpr<std::chrono::milliseconds, 9000000, std::chrono::seconds, 9000> ();
+ test_constexpr<std::chrono::milliseconds,-9000000, std::chrono::seconds,-9000> ();
+}
diff --git a/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp b/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
index c32350faa83b..f9ddc87a7a14 100644
--- a/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
+++ b/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
@@ -20,6 +20,10 @@ test()
{
static_assert((std::is_base_of<std::is_floating_point<T>,
std::chrono::treat_as_floating_point<T> >::value), "");
+#if TEST_STD_VER > 14
+ static_assert((std::is_base_of<std::is_floating_point<T>,
+ std::chrono::treat_as_floating_point_v<T> >), "");
+#endif
}
struct A {};
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
new file mode 100644
index 000000000000..58df2df7679a
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// const typename tuple_element<I, tuple<Types...> >::type&&
+// get(const tuple<Types...>&& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+
+template <class T> void cref(T const&) {};
+template <class T> void cref(T const&&) = delete;
+
+std::tuple<int> const tup4() { return std::make_tuple(4); }
+
+int main()
+{
+ // LWG2485: tuple should not open a hole in the type system, get() should
+ // imitate [expr.ref]'s rules for accessing data members
+ {
+ cref(std::get<0>(tup4())); // expected-error {{call to deleted function 'cref'}}
+ }
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
new file mode 100644
index 000000000000..720a9064015d
--- /dev/null
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// const typename tuple_element<I, tuple<Types...> >::type&&
+// get(const tuple<Types...>&& t);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <tuple>
+#include <utility>
+#include <string>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ {
+ typedef std::tuple<int> T;
+ const T t(3);
+ static_assert(std::is_same<const int&&, decltype(std::get<0>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(t))), "");
+ const int&& i = std::get<0>(std::move(t));
+ assert(i == 3);
+ }
+
+ {
+ typedef std::tuple<std::string, int> T;
+ const T t("high", 5);
+ static_assert(std::is_same<const std::string&&, decltype(std::get<0>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(t))), "");
+ static_assert(std::is_same<const int&&, decltype(std::get<1>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<1>(std::move(t))), "");
+ const std::string&& s = std::get<0>(std::move(t));
+ const int&& i = std::get<1>(std::move(t));
+ assert(s == "high");
+ assert(i == 5);
+ }
+
+ {
+ int x = 42;
+ int const y = 43;
+ std::tuple<int&, int const&> const p(x, y);
+ static_assert(std::is_same<int&, decltype(std::get<0>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(p))), "");
+ static_assert(std::is_same<int const&, decltype(std::get<1>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<1>(std::move(p))), "");
+ }
+
+ {
+ int x = 42;
+ int const y = 43;
+ std::tuple<int&&, int const&&> const p(std::move(x), std::move(y));
+ static_assert(std::is_same<int&&, decltype(std::get<0>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(p))), "");
+ static_assert(std::is_same<int const&&, decltype(std::get<1>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<1>(std::move(p))), "");
+ }
+
+#if TEST_STD_VER > 11
+ {
+ typedef std::tuple<double, int> T;
+ constexpr const T t(2.718, 5);
+ static_assert(std::get<0>(std::move(t)) == 2.718, "");
+ static_assert(std::get<1>(std::move(t)) == 5, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
index aa020dab47c7..b661a78de8db 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
@@ -10,30 +10,31 @@
// UNSUPPORTED: c++98, c++03, c++11
#include <tuple>
+#include <utility>
#include <string>
#include <complex>
+#include <type_traits>
#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<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, "" );
@@ -53,8 +54,40 @@ int main()
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
+ assert(std::get<upint>(t) == nullptr); // has been moved from
+ }
+
+ {
+ typedef std::unique_ptr<int> upint;
+ const std::tuple<upint> t(upint(new int(4)));
+ const upint&& p = std::get<upint>(std::move(t)); // get const rvalue
+ assert(*p == 4);
+ assert(std::get<upint>(t) != nullptr);
}
-#endif
+ {
+ int x = 42;
+ int y = 43;
+ std::tuple<int&, int const&> const t(x, y);
+ static_assert(std::is_same<int&, decltype(std::get<int&>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<int&>(std::move(t))), "");
+ static_assert(std::is_same<int const&, decltype(std::get<int const&>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<int const&>(std::move(t))), "");
+ }
+
+ {
+ int x = 42;
+ int y = 43;
+ std::tuple<int&&, int const&&> const t(std::move(x), std::move(y));
+ static_assert(std::is_same<int&&, decltype(std::get<int&&>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<int&&>(std::move(t))), "");
+ static_assert(std::is_same<int const&&, decltype(std::get<int const&&>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<int const&&>(std::move(t))), "");
+ }
+
+ {
+ constexpr const std::tuple<int, const int, double, double> t { 1, 2, 3.4, 5.6 };
+ static_assert(std::get<int>(std::move(t)) == 1, "");
+ static_assert(std::get<const int>(std::move(t)) == 2, "");
+ }
}
diff --git a/test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp b/test/std/utilities/utility/as_const/as_const.fail.cpp
index a6debcbd98d8..6334e1460259 100644
--- a/test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp
+++ b/test/std/utilities/utility/as_const/as_const.fail.cpp
@@ -7,12 +7,16 @@
//
//===----------------------------------------------------------------------===//
-// REQUIRES: libcpp-has-no-thread-unsafe-c-functions
+// UNSUPPORTED: c++98, c++03, c++11, c++14
-#include <ctime>
+// template <class T> constexpr add_const<T>& as_const(T& t) noexcept; // C++17
+// template <class T> add_const<T>& as_const(const T&&) = delete; // C++17
-int main() {
- // gmtime is not thread-safe.
- std::time_t t = 0;
- std::gmtime(&t);
+#include <utility>
+
+struct S {int i;};
+
+int main()
+{
+ std::as_const(S{});
}
diff --git a/test/std/utilities/utility/as_const/as_const.pass.cpp b/test/std/utilities/utility/as_const/as_const.pass.cpp
new file mode 100644
index 000000000000..ff3f84a5532f
--- /dev/null
+++ b/test/std/utilities/utility/as_const/as_const.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template <class T> constexpr add_const<T>& as_const(T& t) noexcept; // C++17
+// template <class T> add_const<T>& as_const(const T&&) = delete; // C++17
+
+#include <utility>
+#include <cassert>
+
+struct S {int i;};
+bool operator==(const S& x, const S& y) { return x.i == y.i; }
+bool operator==(const volatile S& x, const volatile S& y) { return x.i == y.i; }
+
+template<typename T>
+void test(T& t)
+{
+ static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const (t))>::type>::value, "");
+ static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const< T>(t))>::type>::value, "");
+ static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const<const T>(t))>::type>::value, "");
+ static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const<volatile T>(t))>::type>::value, "");
+ static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const<const volatile T>(t))>::type>::value, "");
+
+ assert(std::as_const(t) == t);
+ assert(std::as_const< T>(t) == t);
+ assert(std::as_const<const T>(t) == t);
+ assert(std::as_const<volatile T>(t) == t);
+ assert(std::as_const<const volatile T>(t) == t);
+}
+
+int main()
+{
+ int i = 3;
+ double d = 4.0;
+ S s{2};
+ test(i);
+ test(d);
+ test(s);
+}
diff --git a/test/std/utilities/utility/declval/declval.pass.cpp b/test/std/utilities/utility/declval/declval.pass.cpp
index 81f4df8e8b2b..aabd0e6f6c74 100644
--- a/test/std/utilities/utility/declval/declval.pass.cpp
+++ b/test/std/utilities/utility/declval/declval.pass.cpp
@@ -14,6 +14,8 @@
#include <utility>
#include <type_traits>
+#include "test_macros.h"
+
class A
{
A(const A&);
@@ -22,9 +24,9 @@ class A
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), "");
#else
- static_assert((std::is_same<decltype(std::declval<A>()), A>::value), "");
+ static_assert((std::is_same<decltype(std::declval<A>()), A&>::value), "");
#endif
}
diff --git a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
index c8375e9d7238..bc60d3d27614 100644
--- a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
+++ b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
@@ -56,13 +56,14 @@ int main()
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
#else // C++ < 11
- // libc++ defines decltype to be __typeof__ in C++03. __typeof__ does not
- // deduce the reference qualifiers.
- static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
- static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy>::value), "");
+ // In C++03 libc++ #define's decltype to be __decltype on clang and
+ // __typeof__ for other compilers. __typeof__ does not deduce the reference
+ // qualifiers and will cause this test to fail.
+ static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&>::value), "");
+ static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
#endif
#if TEST_STD_VER > 11
diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
new file mode 100644
index 000000000000..edd2f3d0752f
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+// const typename tuple_element<I, std::pair<T1, T2> >::type&&
+// get(const pair<T1, T2>&&);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <utility>
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+ {
+ typedef std::pair<std::unique_ptr<int>, short> P;
+ const P p(std::unique_ptr<int>(new int(3)), 4);
+ static_assert(std::is_same<const std::unique_ptr<int>&&, decltype(std::get<0>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(p))), "");
+ const std::unique_ptr<int>&& ptr = std::get<0>(std::move(p));
+ assert(*ptr == 3);
+ }
+
+ {
+ int x = 42;
+ int const y = 43;
+ std::pair<int&, int const&> const p(x, y);
+ static_assert(std::is_same<int&, decltype(std::get<0>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(p))), "");
+ static_assert(std::is_same<int const&, decltype(std::get<1>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<1>(std::move(p))), "");
+ }
+
+ {
+ int x = 42;
+ int const y = 43;
+ std::pair<int&&, int const&&> const p(std::move(x), std::move(y));
+ static_assert(std::is_same<int&&, decltype(std::get<0>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<0>(std::move(p))), "");
+ static_assert(std::is_same<int const&&, decltype(std::get<1>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<1>(std::move(p))), "");
+ }
+
+#if TEST_STD_VER > 11
+ {
+ typedef std::pair<int, short> P;
+ constexpr const P p1(3, 4);
+ static_assert(std::get<0>(std::move(p1)) == 3, "");
+ static_assert(std::get<1>(std::move(p1)) == 4, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
index 176d58330d16..efcc2cedc6e1 100644
--- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
+++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
@@ -7,15 +7,17 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
+
#include <utility>
#include <string>
+#include <type_traits>
#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 } );
@@ -23,7 +25,7 @@ int main()
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);
@@ -35,10 +37,48 @@ int main()
{
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
+ upint p = std::get<upint>(std::move(t)); // get rvalue
+ assert(*p == 4);
+ assert(std::get<upint>(t) == nullptr); // has been moved from
+ }
+
+ {
+ typedef std::unique_ptr<int> upint;
+ const std::pair<upint, int> t(upint(new int(4)), 42);
+ static_assert(std::is_same<const upint&&, decltype(std::get<upint>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<upint>(std::move(t))), "");
+ static_assert(std::is_same<const int&&, decltype(std::get<int>(std::move(t)))>::value, "");
+ static_assert(noexcept(std::get<int>(std::move(t))), "");
+ auto&& p = std::get<upint>(std::move(t)); // get const rvalue
+ auto&& i = std::get<int>(std::move(t)); // get const rvalue
assert(*p == 4);
- assert(std::get<0>(t) == nullptr); // has been moved from
+ assert(i == 42);
+ assert(std::get<upint>(t) != nullptr);
}
-#endif
+ {
+ int x = 42;
+ int const y = 43;
+ std::pair<int&, int const&> const p(x, y);
+ static_assert(std::is_same<int&, decltype(std::get<int&>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<int&>(std::move(p))), "");
+ static_assert(std::is_same<int const&, decltype(std::get<int const&>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<int const&>(std::move(p))), "");
+ }
+
+ {
+ int x = 42;
+ int const y = 43;
+ std::pair<int&&, int const&&> const p(std::move(x), std::move(y));
+ static_assert(std::is_same<int&&, decltype(std::get<int&&>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<int&&>(std::move(p))), "");
+ static_assert(std::is_same<int const&&, decltype(std::get<int const&&>(std::move(p)))>::value, "");
+ static_assert(noexcept(std::get<int const&&>(std::move(p))), "");
+ }
+
+ {
+ constexpr const std::pair<int, const int> p { 1, 2 };
+ static_assert(std::get<int>(std::move(p)) == 1, "");
+ static_assert(std::get<const int>(std::move(p)) == 2, "");
+ }
}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp
new file mode 100644
index 000000000000..8f9fc669251a
--- /dev/null
+++ b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// Test the SFINAE required by LWG Issue #2367.
+// is_default_constructible<pair>
+
+// UNSUPPORTED: c++98, c++03
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if TEST_STD_VER > 11
+#define CONSTEXPR_CXX14 constexpr
+#define STATIC_ASSERT_CXX14(Pred) static_assert(Pred, "")
+#else
+#define CONSTEXPR_CXX14
+#define STATIC_ASSERT_CXX14(Pred) assert(Pred)
+#endif
+
+struct DeletedDefault {
+ // A class with a deleted default constructor. Used to test the SFINAE
+ // on std::pairs default constructor.
+ constexpr explicit DeletedDefault(int x) : value(x) {}
+ constexpr DeletedDefault() = delete;
+ int value;
+};
+
+template <class Tp, bool>
+struct DependantType: public Tp {};
+
+template <class T, bool Val>
+using DependantIsDefault = DependantType<std::is_default_constructible<T>, Val>;
+
+template <class T>
+struct DefaultSFINAES {
+ template <bool Dummy = false, class = typename std::enable_if<
+ DependantIsDefault<T, Dummy>::value
+ >::type
+ >
+ constexpr DefaultSFINAES() : value() {}
+ constexpr explicit DefaultSFINAES(T const& x) : value(x) {}
+ T value;
+};
+
+struct NoDefault {
+ constexpr NoDefault(int v) : value(v) {}
+ int value;
+};
+
+template <class Tp>
+void test_not_is_default_constructible()
+{
+ {
+ typedef std::pair<int, Tp> P;
+ static_assert(!std::is_default_constructible<P>::value, "");
+ static_assert(std::is_constructible<P, int, Tp>::value, "");
+ }
+ {
+ typedef std::pair<Tp, int> P;
+ static_assert(!std::is_default_constructible<P>::value, "");
+ static_assert(std::is_constructible<P, Tp, int>::value, "");
+ }
+ {
+ typedef std::pair<Tp, Tp> P;
+ static_assert(!std::is_default_constructible<P>::value, "");
+ static_assert(std::is_constructible<P, Tp, Tp>::value, "");
+ }
+}
+
+template <class Tp>
+void test_is_default_constructible()
+{
+ {
+ typedef std::pair<int, Tp> P;
+ static_assert(std::is_default_constructible<P>::value, "");
+ }
+ {
+ typedef std::pair<Tp, int> P;
+ static_assert(std::is_default_constructible<P>::value, "");
+ }
+ {
+ typedef std::pair<Tp, Tp> P;
+ static_assert(std::is_default_constructible<P>::value, "");
+ }
+}
+
+template <class T>
+struct IllFormedDefaultImp {
+ constexpr explicit IllFormedDefaultImp(int v) : value(v) {}
+ constexpr IllFormedDefaultImp() : value(T::DoesNotExistAndShouldNotCompile) {}
+ int value;
+};
+
+typedef IllFormedDefaultImp<int> IllFormedDefault;
+ // A class which provides a constexpr default constructor with a valid
+ // signature but an ill-formed body. The A compile error will be emitted if
+ // the default constructor is instantiated.
+
+
+// Check that the SFINAE on the default constructor is not evaluated when
+// it isn't needed. If the default constructor of 'IllFormedDefault' is evaluated
+// in C++11, even with is_default_constructible, then this test should fail to
+// compile. In C++14 and greater evaluate each test is evaluated as a constant
+// expression.
+// See LWG issue #2367
+void test_illformed_default()
+{
+ {
+ typedef std::pair<IllFormedDefault, int> P;
+ static_assert((std::is_constructible<P, IllFormedDefault, int>::value), "");
+ CONSTEXPR_CXX14 P p(IllFormedDefault(42), -5);
+ STATIC_ASSERT_CXX14(p.first.value == 42 && p.second == -5);
+ }
+ {
+ typedef std::pair<int, IllFormedDefault> P;
+ static_assert((std::is_constructible<P, int, IllFormedDefault>::value), "");
+ CONSTEXPR_CXX14 IllFormedDefault dd(-5);
+ CONSTEXPR_CXX14 P p(42, dd);
+ STATIC_ASSERT_CXX14(p.first == 42 && p.second.value == -5);
+ }
+ {
+ typedef std::pair<IllFormedDefault, IllFormedDefault> P;
+ static_assert((std::is_constructible<P, IllFormedDefault, IllFormedDefault>::value), "");
+ CONSTEXPR_CXX14 P p(IllFormedDefault(42), IllFormedDefault(-5));
+ STATIC_ASSERT_CXX14(p.first.value == 42 && p.second.value == -5);
+ }
+}
+
+
+int main()
+{
+ {
+ // Check that pair<T, U> can still be used even if
+ // is_default_constructible<T> or is_default_constructible<U> cause
+ // a compilation error.
+ test_illformed_default();
+ }
+ {
+ // pair::pair() is only disable in C++11 and beyond.
+ test_not_is_default_constructible<NoDefault>();
+ test_not_is_default_constructible<DeletedDefault>();
+ test_not_is_default_constructible<DefaultSFINAES<int&>>();
+ test_not_is_default_constructible<DefaultSFINAES<int&&>>();
+ test_not_is_default_constructible<int&>();
+ test_not_is_default_constructible<int&&>();
+ }
+ {
+ test_is_default_constructible<int>();
+ test_is_default_constructible<DefaultSFINAES<int>>();
+ }
+}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
index bb6661f7966c..d83328b8f2d0 100644
--- a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
+++ b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
@@ -13,9 +13,15 @@
// constexpr pair();
+// NOTE: The SFINAE on the default constructor is tested in
+// default-sfinae.pass.cpp
+
#include <utility>
+#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
{
@@ -24,13 +30,12 @@ int main()
assert(p.first == 0.0f);
assert(p.second == nullptr);
}
-
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER >= 11
{
- typedef std::pair<float, short*> P;
- constexpr P p;
- static_assert(p.first == 0.0f, "");
- static_assert(p.second == nullptr, "");
+ typedef std::pair<float, short*> P;
+ constexpr P p;
+ static_assert(p.first == 0.0f, "");
+ static_assert(p.second == nullptr, "");
}
#endif
}
diff --git a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
index a912df00d7bb..0ad5786bce29 100644
--- a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
+++ b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
@@ -16,6 +16,15 @@
#include <utility>
#include <cassert>
+struct S {
+ int i;
+ S() : i(0) {}
+ S(int j) : i(j) {}
+ S * operator& () { assert(false); return this; }
+ S const * operator& () const { assert(false); return this; }
+ bool operator==(int x) const { return i == x; }
+ };
+
int main()
{
{
@@ -28,4 +37,14 @@ int main()
assert(p2.first == 3);
assert(p2.second == 4);
}
+ {
+ typedef std::pair<int, S> P1;
+ P1 p1(3, S(4));
+ P1 p2(5, S(6));
+ p1.swap(p2);
+ assert(p1.first == 5);
+ assert(p1.second == 6);
+ assert(p2.first == 3);
+ assert(p2.second == 4);
+ }
}