|
Boost : |
From: Andrew Sutton (asutton_at_[hidden])
Date: 2007-10-16 08:37:02
> Looking at C++0x I failed to see a future improvement in that
> direction, also 'concepts' that will be quite new, apart from helping
> in decoding error messages (and this is a BIG help I would add), does
> not immediately seem to extend the language in that direction.
>
> For what I have understood 'refinements' are more or less similar to
> tag dispatching so does not seem to open completely new gates (of
> course this is just a first look opinion, it means that is not
> immediately visible to me how to use concepts to add to what you
> already can do using a more verbose approach, not that for sure it
> does not exist a way).
They do all that and more :) Concepts are actually derived from the
old STL documentation - a way of expressing requirements (and
guarantees via axioms) on types in template code. So one way to use
them is to require that your template arguments types have specific
interfaces. The other way is to use them to /provide/ those
interfaces for types that don't support them (via concept_maps).
Think of them as adapter classes. This means you could
(theoretically) take the old CArrary from MFC, and provide a
concept_map that makes it look like a std::vector, and be able to use
that as the internals of a std::stack. I'm not saying it's a good
idea, but you can probably do it.
> I would like to ask you if someone has never dreamed of something like
>
> try well_formed
> {
>
> .... your code here...
>
> } catch {
>
> .... fall back code in case former is not compilable...
>
> };
>
>
> I would think this would be an extension that greatly will open new
> gates to C++.
I think there are probably too many places where a compiler can fail.
Try to find all of the broken language aspects in Boost.Config, and
then generalize this solution to all of those. You'd end up having
this construct around, well, most of your program. The only viable
solution to this is the preprocessor - it's ugly, but it's been
effective for 30 years, and I don't see it going away any time soon :)
Andrew Sutton
asutton_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk