Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Overload resolve function pointer
//g++ 4.9.3 #include <iostream> #ifndef KS_CONSTEXPR # if defined(__GNUC__) || _MSC_VER >= 1900 # define KS_CONSTEXPR_IMPLED # define KS_CONSTEXPR constexpr # define KS_CONST constexpr # else # define KS_CONSTEXPR # define KS_CONST const # endif #endif template <typename... Args> struct SNonConstOverload { template <typename R, typename T> KS_CONSTEXPR auto operator() (R(T::*ptr)(Args...)) const { return ptr; } }; template <typename... Args> struct SConstOverload { template <typename R, typename T> KS_CONSTEXPR auto operator() (R(T::*ptr)(Args...) const) const { return ptr; } }; template <typename... Args> struct SOverload : SConstOverload<Args...>, SNonConstOverload < Args... > { using SConstOverload<Args...>::operator(); using SNonConstOverload<Args...>::operator(); template <typename R> KS_CONSTEXPR auto operator() (R(*ptr)(Args...)) const { return ptr; } }; struct CS { double cos(double d){ return 0.0;} double cos(int, int){return 0.0;} }; int main() { auto x = SOverload<double>{}(&CS::cos); auto y = SOverload<int, int>{}(&CS::cos); std::cout << "Hello, world!\n"; }
run
|
edit
|
history
|
help
0
ToString library for C++
Problem_rstring_1
hangman
asock
c++ eval - double numbers v1.0
Number of paths in matrix
Double_wrapper vc++
inherited
Visual Studio 2015 Compiler Bug: 64bit multiplication
Not Common Numbers