decltype((dosomething))
dosomethingwront
int
float
#include <boost/concept_check.hpp>
void dosomething(int x, int y);
void dosomethingwront(float x, float y);
int main() {
BOOST_CONCEPT_ASSERT((boost::BinaryFunction<decltype((dosomething)),void,int,int>));
BOOST_CONCEPT_ASSERT((boost::BinaryFunction<decltype((dosomethingwront)),void,int,int>));
}
#include <iostream>
#include <type_traits>
template <typename F>
struct is_void_int_int : std::false_type {};
// Free function
template <>
struct is_void_int_int<void(int, int)> : std::true_type {};
// Pointer to function
template <>
struct is_void_int_int<void (*)(int, int)> : std::true_type {};
// Reference to function
template <>
struct is_void_int_int<void (&)(int, int)> : std::true_type {};
// Pointer to member function
template <typename C>
struct is_void_int_int<void (C::*)(int, int)> : std::true_type {};
void dosomething(int x, int y);
void dosomethingwront(float x, float y);
struct A {
void operator()(int, int) {}
};
struct B {
void bar(int, int) {}
};
int main() {
static_assert(is_void_int_int<decltype(dosomething)>::value, "!");
static_assert(is_void_int_int<decltype((dosomething))>::value, "!");
static_assert(is_void_int_int<decltype(&dosomething)>::value, "!");
static_assert(is_void_int_int<decltype(&A::operator())>::value, "!");
static_assert(is_void_int_int<decltype(&B::bar)>::value, "!");
//static_assert(is_void_int_int<decltype(dosomethingwront)>::value, "!"); // BOOM!
}