Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2002-12-17 16:34:00


From: "William E. Kempf" <wekempf_at_[hidden]>
> David Abrahams said:
> > "William E. Kempf" <wekempf_at_[hidden]> writes:
> >> Augustus Saunders said:
> >
> >> I wouldn't be overly concerned. I'd find this to be a programmer
> >> error (passing a type to a template that doesn't meet the template's
> >> requirements). Concept checking libraries can even be employed to
> >> insure such mistakes don't happen (assuming the concepts are well
> >> defined enough for such checks to be written), though this would be a
> >> QoI issue in the implementation of the template.
> >
> > Those concept checks can only look at syntactic and type constraints,
> > not semantic (behavioral) ones like the ones they're worried about.

While it may well be a programmer error to misuse the template, I
prefer solutions that allow the compiler to diagnose the problem
insofar as practicable.

> That's why I said "assuming the concepts are well defined enough for such
> checks to be written". What I'm thinking is that a type with deep
> comparison semantics might be required (by the concept definition) to
> include a typedef or some other public interface that could be used to
> distinguish it.
>
> However, thinking this through more carefully, such a concept definition
> would exclude pointers needlessly, so you are right, there's probably not
> a way to do this.

Use a traits class.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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