mirror of
https://github.com/boostorg/callable_traits.git
synced 2026-02-11 11:42:15 +00:00
documentation and examples
This commit is contained in:
29
example/can_invoke_member_function_pointer.cpp
Normal file
29
example/can_invoke_member_function_pointer.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*<-
|
||||
Copyright Barrett Adair 2016
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt)
|
||||
->*/
|
||||
|
||||
//[ can_invoke_member_function_pointer
|
||||
#include <callable_traits/callable_traits.hpp>
|
||||
|
||||
namespace ct = callable_traits;
|
||||
|
||||
struct foo {
|
||||
int bar(int) const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
// can_invoke returns std::true_type here because the
|
||||
// arguments are valid to INVOKE
|
||||
static_assert(ct::can_invoke(&foo::bar, foo{}, 0), "");
|
||||
|
||||
// can_invoke returns std::false_type here because the
|
||||
// arguments are NOT valid to INVOKE - foo::bar can't be
|
||||
// invoked like a void member function.
|
||||
static_assert(!ct::can_invoke(&foo::bar, foo{}), "");
|
||||
|
||||
int main() {}
|
||||
|
||||
//]
|
||||
Reference in New Issue
Block a user