45 #define G4AnyMethod_h 1 54 virtual const char*
what()
const throw() {
55 return "G4BadArgument: failed operator()";
59 #if defined(G4USE_STD11) || defined(G4USE_STD14) 60 #include <type_traits> 61 using std::remove_reference;
87 template <
class S,
class T,
class A0>
G4AnyMethod(
S (T::*f)(A0)) : narg(1) {
90 template <
class S,
class T,
class A0,
class A1>
G4AnyMethod(
S (T::*f)(A0,A1)) : narg(2) {
94 fContent(other.fContent ? other.fContent->Clone() : 0),narg(other.narg) {}
102 std::swap(narg, rhs.
narg);
111 template <
class S,
class T,
class A0>
G4AnyMethod& operator =(
S (T::*f)(A0)) {
116 template <
class S,
class T,
class A0,
class A1>
G4AnyMethod& operator =(
S (T::*f)(A0, A1)) {
133 fContent->operator()(obj);
136 fContent->operator()(obj,
a0);
139 size_t NArg()
const {
return narg; }
141 const std::type_info&
ArgType(
size_t n = 0)
const {
142 return fContent ? fContent->ArgType(
n) :
typeid(void);
151 virtual void operator()(
void*) = 0;
152 virtual void operator()(
void*,
const std::string&) = 0;
153 virtual const std::type_info& ArgType(
size_t)
const = 0;
168 virtual const std::type_info&
ArgType(
size_t)
const {
184 std::stringstream strs(s0);
186 ((T*)obj->*fRef)(
a0);
191 virtual const std::type_info&
ArgType(
size_t)
const {
209 std::stringstream strs(s0);
211 ((T*)obj->*fRef)(
a0,
a1);
216 virtual const std::type_info&
ArgType(
size_t i)
const {
217 return i == 0 ?
typeid(A0) :
typeid(A1);
219 S (T::*fRef)(A0, A1);
virtual void operator()(void *, const std::string &)
G4AnyMethod(S(T::*f)(A0))
G4AnyMethod(const G4AnyMethod &other)
G4AnyMethod(S(T::*f)(A0, A1))
virtual const char * what() const
virtual Placeholder * Clone() const
virtual void operator()(void *)
remove_reference< A0 >::type nakedA0
G4AnyMethod & Swap(G4AnyMethod &rhs)
FuncRef2(S(T::*f)(A0, A1))
virtual void operator()(void *obj, const std::string &s0)
virtual const std::type_info & ArgType(size_t) const
remove_reference< A1 >::type nakedA1
const std::type_info & ArgType(size_t n=0) const
virtual const std::type_info & ArgType(size_t i) const
virtual void operator()(void *obj, const std::string &s0)
void operator()(void *obj)
virtual const std::type_info & ArgType(size_t) const
virtual Placeholder * Clone() const
remove_reference< A0 >::type nakedA0
virtual Placeholder * Clone() const
void operator()(void *obj, const std::string &a0)
virtual void operator()(void *obj)
virtual void operator()(void *)