adding result_of example

This commit is contained in:
badair
2016-04-04 20:53:43 -05:00
parent 1cba0cbdac
commit 2bdfcf5df5
3 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/*!
Copyright (c) 2016 Barrett Adair
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <callable_traits/callable_traits.hpp>
namespace ct = callable_traits;
using expect = int;
struct foo;
template<typename T>
void test() {
using result = ct::result_of<T>;
static_assert(std::is_same<expect, result>{}, "");
}
int main() {
test<int()>();
test<int(*)()>();
test<int(&)()>();
test<int() const>();
test<int(foo::*)() const>();
auto x = []() -> int { return 0; };
test<decltype(x)>();
}

View File

@@ -0,0 +1,34 @@
/*!
Copyright (c) 2016 Barrett Adair
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <callable_traits/callable_traits.hpp>
namespace ct = callable_traits;
using expect = int;
struct foo;
template<typename T>
void test() {
using result = ct::result_of<T>;
static_assert(std::is_same<expect, result>{}, "");
}
int main() {
test<int()>();
test<int(*)()>();
test<int(&)()>();
test<int() const>();
test<int(foo::*)() const>();
auto x = []() -> int { return 0; };
test<decltype(x)>();
}

View File

@@ -11,3 +11,4 @@ OTHER_FILES += ../../test/*.cpp \
../../example/signature/*.cpp \
../../example/apply_member_pointer/*.cpp \
../../example/remove_member_pointer/*.cpp \
../../example/result_of/*.cpp \