R
Robert J. Hansen
I'm exploring the use of type traits (which, I hasten to say, I've
hardly ever used before) as a way to help simplify some complex
special-case logic in an existing codebase. I'm finding that I'm
running into some of the sharp corners of the C++ template facility.
I'm hoping someone can answer a couple of questions about the following
code snippet:
=====
template <
class D, template <D> class S,
struct MetaTraits {
typedef typename D Data;
typedef typename S Solution;
typedef typename E Engine;
};
=====
.... I've tried pretty much every variation I can on this, and for
naught. Does anyone know the necessary incantation?
The task is to produce a framework for AI problems which can be
addressed by search methods. Any given engine for computing solutions
will need to know the type of the data it's operating upon, and the
type of the solutions it's generating: hence the existence of
ProblemTraits. Likewise, there are many kinds of engines which have
their solutions generate new potentials in the same neighborhood, which
means their solutions have to be able to reflect into the data.
Finally, the runtime system needs to know the types of all three
components (data, solutions and engine), hence the metatrait which
encompasses ProblemTrait<D, S> and Engine<ProblemTrait<D, S> >.
Of course, trying to hook up incompatible Engines to incompatible
ProblemTraits should cause the compile to blow up, as will incompatible
solutions to incompatible data--that's a feature I'm looking forward
to, since right now we're catching these things at runtime.
Thanks in advance for any help you can give.
hardly ever used before) as a way to help simplify some complex
special-case logic in an existing codebase. I'm finding that I'm
running into some of the sharp corners of the C++ template facility.
I'm hoping someone can answer a couple of questions about the following
code snippet:
=====
template <
class D, template <D> class S,
struct MetaTraits {
typedef typename D Data;
typedef typename S Solution;
typedef typename E Engine;
};
=====
.... I've tried pretty much every variation I can on this, and for
naught. Does anyone know the necessary incantation?
The task is to produce a framework for AI problems which can be
addressed by search methods. Any given engine for computing solutions
will need to know the type of the data it's operating upon, and the
type of the solutions it's generating: hence the existence of
ProblemTraits. Likewise, there are many kinds of engines which have
their solutions generate new potentials in the same neighborhood, which
means their solutions have to be able to reflect into the data.
Finally, the runtime system needs to know the types of all three
components (data, solutions and engine), hence the metatrait which
encompasses ProblemTrait<D, S> and Engine<ProblemTrait<D, S> >.
Of course, trying to hook up incompatible Engines to incompatible
ProblemTraits should cause the compile to blow up, as will incompatible
solutions to incompatible data--that's a feature I'm looking forward
to, since right now we're catching these things at runtime.
Thanks in advance for any help you can give.