Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-07-07 09:26:53


Ed Brey wrote:
>
> Email seemed somewhat boring, until Valentin Bonnard wrote:
> >
> >See
> >http://www.eleves.ens.fr:8080/home/bonnard/ContAlgo/ContTraits.hpp
> >for an _example_ (I will probably rewrite it).
>
> [And a quote from that example:
>
> namespace TypeLogic {
> struct yes {};
> struct no {};
> struct maybe {};
> } // TypeLogic
>
> // struct Container
>
> template <typename T>
> struct container_trait
> {
> static const bool is_specialised = false;
> typedef TypeLogic::maybe is_sequence;
> typedef TypeLogic::maybe is_associative;
> typedef TypeLogic::maybe is_node_based;
> };
>
> -- end quote]
>
> What is the rational behind using the TypeLogic. I would have expected
> something like this for the tri-state variables:
>
> enum tristate {yes, no, maybe};
>
> template <typename T>
> struct container_trait
> {
> static const bool is_specialised = false;
> static const tristate is_sequence = maybe;
> static const tristate is_associative = maybe;
> static const tristate is_node_based = maybe;
> };

Certainly a possible solution. But then auto-selection
is less simple:

template <typename T, T value>
struct holder {};

void foo (holder<tristate, maybe>);

vs

void foo (maybe);

OTOH holder is more general (holder<int, N> vs
struct one, struct two, struct three...).

FWIW, SGI uses my style (or I use SGI style).

-- 
Valentin Bonnard
------------------------------------------------------------------------
eGroups.com home: http://www.egroups.com/group/boost
http://www.egroups.com - Simplifying group communications

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