From 840fa745ca493123c44d7e9b62676f3a0cd23c0d Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 20 Apr 2016 00:14:32 +0000 Subject: Add 'is_callable' and 'is_nothrow_callable' traits and cleanup INVOKE. The primary purpose of this patch is to add the 'is_callable' traits. Since 'is_nothrow_callable' required making 'INVOKE' conditionally noexcept I also took this oppertunity to implement a constexpr version of INVOKE. This fixes 'std::experimental::apply' which required constexpr 'INVOKE support'. This patch will be followed up with some cleanup. Primarly removing most of "__member_function_traits" since it's no longer used by INVOKE (in C++11 at least). llvm-svn: 266836 --- .../allocate_shared.pass.cpp | 4 +- .../allocate_shared_cxx03.pass.cpp | 118 +++++++++++++++++++++ .../allocate_shared_no_variadics.pass.cpp | 118 --------------------- 3 files changed, 120 insertions(+), 120 deletions(-) create mode 100644 libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp delete mode 100644 libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp (limited to 'libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared') diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp index aa77dab5151..3e4a99e981d 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // shared_ptr @@ -55,7 +57,6 @@ int main() } assert(A::count == 0); assert(test_allocator::alloc_count == 0); -#if __cplusplus >= 201103L { int i = 67; char c = 'e'; @@ -74,5 +75,4 @@ int main() assert(p->get_char() == 'f'); } assert(A::count == 0); -#endif } diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp new file mode 100644 index 00000000000..f6350c72bcc --- /dev/null +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp @@ -0,0 +1,118 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// shared_ptr + +// template +// shared_ptr allocate_shared(const A& a, Args&&... args); + + +#include +#include +#include +#include +#include "test_allocator.h" +#include "min_allocator.h" + +struct Zero +{ + static int count; + Zero() {++count;} + Zero(Zero const &) {++count;} + ~Zero() {--count;} +}; + +int Zero::count = 0; + +struct One +{ + static int count; + int value; + explicit One(int v) : value(v) {++count;} + One(One const & o) : value(o.value) {++count;} + ~One() {--count;} +}; + +int One::count = 0; + + +struct Two +{ + static int count; + int value; + Two(int v, int) : value(v) {++count;} + Two(Two const & o) : value(o.value) {++count;} + ~Two() {--count;} +}; + +int Two::count = 0; + +struct Three +{ + static int count; + int value; + Three(int v, int, int) : value(v) {++count;} + Three(Three const & o) : value(o.value) {++count;} + ~Three() {--count;} +}; + +int Three::count = 0; + +template +void test() +{ + int const bad = -1; + { + std::shared_ptr p = std::allocate_shared(Alloc()); + assert(Zero::count == 1); + } + assert(Zero::count == 0); + { + int const i = 42; + std::shared_ptr p = std::allocate_shared(Alloc(), i); + assert(One::count == 1); + assert(p->value == i); + } + assert(One::count == 0); + { + int const i = 42; + std::shared_ptr p = std::allocate_shared(Alloc(), i, bad); + assert(Two::count == 1); + assert(p->value == i); + } + assert(Two::count == 0); + { + int const i = 42; + std::shared_ptr p = std::allocate_shared(Alloc(), i, bad, bad); + assert(Three::count == 1); + assert(p->value == i); + } + assert(Three::count == 0); +} + +int main() +{ + { + int i = 67; + int const bad = -1; + std::shared_ptr p = std::allocate_shared(test_allocator(54), i, bad); + assert(test_allocator::alloc_count == 1); + assert(Two::count == 1); + assert(p->value == 67); + } + assert(Two::count == 0); + assert(test_allocator::alloc_count == 0); + + test >(); +#if __cplusplus >= 201103L + test >(); +#endif +} diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp deleted file mode 100644 index 8dcd50e4941..00000000000 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp +++ /dev/null @@ -1,118 +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. -// -//===----------------------------------------------------------------------===// - -// - -// shared_ptr - -// template -// shared_ptr allocate_shared(const A& a, Args&&... args); - -#define _LIBCPP_HAS_NO_VARIADICS -#include -#include -#include -#include -#include "test_allocator.h" -#include "min_allocator.h" - -struct Zero -{ - static int count; - Zero() {++count;} - Zero(Zero const &) {++count;} - ~Zero() {--count;} -}; - -int Zero::count = 0; - -struct One -{ - static int count; - int value; - explicit One(int v) : value(v) {++count;} - One(One const & o) : value(o.value) {++count;} - ~One() {--count;} -}; - -int One::count = 0; - - -struct Two -{ - static int count; - int value; - Two(int v, int) : value(v) {++count;} - Two(Two const & o) : value(o.value) {++count;} - ~Two() {--count;} -}; - -int Two::count = 0; - -struct Three -{ - static int count; - int value; - Three(int v, int, int) : value(v) {++count;} - Three(Three const & o) : value(o.value) {++count;} - ~Three() {--count;} -}; - -int Three::count = 0; - -template -void test() -{ - int const bad = -1; - { - std::shared_ptr p = std::allocate_shared(Alloc()); - assert(Zero::count == 1); - } - assert(Zero::count == 0); - { - int const i = 42; - std::shared_ptr p = std::allocate_shared(Alloc(), i); - assert(One::count == 1); - assert(p->value == i); - } - assert(One::count == 0); - { - int const i = 42; - std::shared_ptr p = std::allocate_shared(Alloc(), i, bad); - assert(Two::count == 1); - assert(p->value == i); - } - assert(Two::count == 0); - { - int const i = 42; - std::shared_ptr p = std::allocate_shared(Alloc(), i, bad, bad); - assert(Three::count == 1); - assert(p->value == i); - } - assert(Three::count == 0); -} - -int main() -{ - { - int i = 67; - int const bad = -1; - std::shared_ptr p = std::allocate_shared(test_allocator(54), i, bad); - assert(test_allocator::alloc_count == 1); - assert(Two::count == 1); - assert(p->value == 67); - } - assert(Two::count == 0); - assert(test_allocator::alloc_count == 0); - - test >(); -#if __cplusplus >= 201103L - test >(); -#endif -} -- cgit v1.2.3