Forbid adding of two functions with the exact same signature

This commit is contained in:
Jason Turner
2009-06-17 02:17:27 +00:00
parent e231cb4cf7
commit 4bb66255ef
3 changed files with 53 additions and 7 deletions

View File

@@ -102,7 +102,7 @@ namespace dispatchkit
virtual ~Proxy_Function() {}
virtual Boxed_Value operator()(const std::vector<Boxed_Value> &params) = 0;
virtual std::vector<Type_Info> get_param_types() = 0;
virtual bool operator==(const Proxy_Function &) const = 0;
};
class Dynamic_Proxy_Function : public Proxy_Function
@@ -113,6 +113,11 @@ namespace dispatchkit
{
}
bool operator==(const Proxy_Function &f) const
{
return false;
}
virtual ~Dynamic_Proxy_Function() {}
virtual Boxed_Value operator()(const std::vector<Boxed_Value> &params)
@@ -146,7 +151,16 @@ namespace dispatchkit
virtual ~Proxy_Function_Impl() {}
virtual bool operator==(const Proxy_Function &t_func) const
{
try {
dynamic_cast<const Proxy_Function_Impl<Func> &>(t_func);
return true;
} catch (const std::bad_cast &) {
return false;
}
}
virtual Boxed_Value operator()(const std::vector<Boxed_Value> &params)
{
return call_func(m_f, params);