Skip to content

Instantly share code, notes, and snippets.

View taketwo's full-sized avatar

Sergey Alexandrov taketwo

  • Aeolus Robotics, Inc.
  • Vienna, Austria
View GitHub Profile

Keybase proof

I hereby claim:

  • I am taketwo on github.
  • I am alexandrov (https://keybase.io/alexandrov) on keybase.
  • I have a public key ASBxy3fFjxH0eYlEyB9wID155PCSPNioAuApKqPaPful_wo

To claim this, I am signing this object:

@taketwo
taketwo / has_method_def.h
Created September 14, 2015 20:50
A c++11 metafunction to check if a class has a method
// Create a metafunction "has_xxx_method" that can be used
// to check if a class has a method called "xxx". Note the
// limitation: only existence of parameterless methods can
// be checked this way.
// Credits: http://stackoverflow.com/a/21827727/1525865
#define HAS_METHOD_DEF(xxx) \
template<typename T> \
constexpr auto has_ ## xxx ## _method(int) \
-> decltype(std::declval<T>(). xxx (), bool()) \
{ return true; } \