I've got my_error exception type, defined as:
class my_error : public std::runtime_er ror {
public:
my_error(const std::string& msg) : std::runtime_er ror(msg) {}
};
Then, I've got Wrapper class, that wraps my classes. I create it:
Wrapper<my_erro rmy_error_wrapp er;
my_error_wrappe r.addMethod(&my _error::what);
The template method addMethod looks like:
template <class T>
class Wrapper {
public:
[...]
template <class Result>
void addMethod(Resul t (T::*method)()) {
}
};
The problem is, that.. it doesn't work. It appears that, my_error::what
has the type
const char* (std::runtime_e rror::*)() const
not:
const char* (my_error::*)() const
Quite tricky, because std::runtime_er ror also derives what() from
std::exception.
Is there any way to give pointer to such method as an argument?
Except form:
template <class Result, class Base>
void addMethod(Resul t (Base::*method) ()) {
STATIC_ASSERT(i s_derived<Base, T>::value);
}
Another question:
Is it possible to obtain method type in some way like:
template <class Method>
void addMethod(Metho d m_ptr) {
}
I know there is something like "function type" used e.g. in
boost::signals to write:
boost::signal<v oid (const char*)my_signal ;
Is there something like that for methods?
thanks in advance ;)
JRX
--
JRX --dev \dot jrx \at gmail \dot com
If the words "open source" get you more excited than
the words "free porn"...you might be a Game Developer.
Registered Linux user# 383163
class my_error : public std::runtime_er ror {
public:
my_error(const std::string& msg) : std::runtime_er ror(msg) {}
};
Then, I've got Wrapper class, that wraps my classes. I create it:
Wrapper<my_erro rmy_error_wrapp er;
my_error_wrappe r.addMethod(&my _error::what);
The template method addMethod looks like:
template <class T>
class Wrapper {
public:
[...]
template <class Result>
void addMethod(Resul t (T::*method)()) {
}
};
The problem is, that.. it doesn't work. It appears that, my_error::what
has the type
const char* (std::runtime_e rror::*)() const
not:
const char* (my_error::*)() const
Quite tricky, because std::runtime_er ror also derives what() from
std::exception.
Is there any way to give pointer to such method as an argument?
Except form:
template <class Result, class Base>
void addMethod(Resul t (Base::*method) ()) {
STATIC_ASSERT(i s_derived<Base, T>::value);
}
Another question:
Is it possible to obtain method type in some way like:
template <class Method>
void addMethod(Metho d m_ptr) {
}
I know there is something like "function type" used e.g. in
boost::signals to write:
boost::signal<v oid (const char*)my_signal ;
Is there something like that for methods?
thanks in advance ;)
JRX
--
JRX --dev \dot jrx \at gmail \dot com
If the words "open source" get you more excited than
the words "free porn"...you might be a Game Developer.
Registered Linux user# 383163
Comment