Boost logo

Boost :

Subject: [boost] Style Guideline
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-10-31 06:51:38


Writing the kind of code that you see in the Boost libraries is something
of a step change from the day-to-day production code that I write, and I
suspect most of us write (Joel, Eric, Dave, Peter and others excepted
of course! :-) ), and writing it, I find, is a rather different matter from
reading
it and broadly understanding it!

So,....enable_if....

Is enable_if intended only to include or exclude complementary
instantiations
of different templates from the possible set, or also to control whether
a particular instantiation is available at all?

Say I have a class which I want to be able to instantiate only for vectors.
Is it
sensible to create an is_vector<> template and then use enable_if, or should
I simply allow instantiation to fail when the code uses some aspect of
vectors
which is specific to vectors?

Does the situation change if it is vectors or lists that are permissible?

Or if it's anything with begin() & end() defined?

Or am I making a complete hash of this, and ought to be thinking in a
different paradigm?

Thanks in advance.

- Rob.


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