Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-09-07 12:24:47


AMDG

Marco Costalba <mcostalba <at> gmail.com> writes:

> At compile time it's not a problem, also is not a problem to check for
> the same signature parameter types at runtime.
>
> The real problem is to support automatic conversions (int -> double,
> derived* -> base*) at runtime.
>

I would try this

struct implicit_conversion {
    const std::type_info* from_type;
    const std::type_info* to_type;
    void* (convert)(void*);
    void (*destroy)(void*);
}

class implicit_conversion_set {
    std::set<implicit_conversion> conversions;
};

template<class R>
class dispatcher {
    implicit_conversion_set conversions;
    R (*f0)();
    std::map<tuple<const std::type_info*>, R(*)(void*)> f1;
    std::map<tuple<const std::type_info*, const std::type_info*>,
             R(*)(void*, void*)> f2;
    //...
};

i.e. implicit conversions need to be registered.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk