mirror of
https://github.com/boostorg/callable_traits.git
synced 2026-02-11 23:52:21 +00:00
adding result_of example
This commit is contained in:
34
example/result_of/example.cpp
Normal file
34
example/result_of/example.cpp
Normal 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)>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user