//===----------------------------------------------------------------------===// // // 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 // // template constexpr decltype(auto) apply(F &&, T &&) // Stress testing large arities with tuple and array. #include #include #include #include //////////////////////////////////////////////////////////////////////////////// template struct always_imp { typedef T type; }; template using always_t = typename always_imp::type; //////////////////////////////////////////////////////////////////////////////// template struct make_function; template struct make_function> { using type = bool (*)(always_t...); }; template using make_function_t = typename make_function>::type; //////////////////////////////////////////////////////////////////////////////// template struct make_tuple_imp; //////////////////////////////////////////////////////////////////////////////// template struct make_tuple_imp> { using type = std::tuple...>; }; template using make_tuple_t = typename make_tuple_imp>::type; template bool test_apply_fn(Types...) { return true; } namespace ex = std::experimental; template void test_all() { using A = std::array; using ConstA = std::array; using Tuple = make_tuple_t; using CTuple = make_tuple_t; using ValFn = make_function_t; ValFn val_fn = &test_apply_fn; using RefFn = make_function_t; RefFn ref_fn = &test_apply_fn; using CRefFn = make_function_t; CRefFn cref_fn = &test_apply_fn; using RRefFn = make_function_t; RRefFn rref_fn = &test_apply_fn; { A a{}; assert(ex::apply(val_fn, a)); assert(ex::apply(ref_fn, a)); assert(ex::apply(cref_fn, a)); assert(ex::apply(rref_fn, std::move(a))); } { ConstA a{}; assert(ex::apply(val_fn, a)); assert(ex::apply(cref_fn, a)); } { Tuple a{}; assert(ex::apply(val_fn, a)); assert(ex::apply(ref_fn, a)); assert(ex::apply(cref_fn, a)); assert(ex::apply(rref_fn, std::move(a))); } { CTuple a{}; assert(ex::apply(val_fn, a)); assert(ex::apply(cref_fn, a)); } } template void test_one() { using A = std::array; using Tuple = make_tuple_t; using ValFn = make_function_t; ValFn val_fn = &test_apply_fn; { A a{}; assert(ex::apply(val_fn, a)); } { Tuple a{}; assert(ex::apply(val_fn, a)); } } int main() { // Instantiate with 1-5 arguments. test_all<1>(); test_all<2>(); test_all<3>(); test_all<4>(); test_all<5>(); // Stress test with 128. test_one<128>(); //test_one<256>(); }