Subject: Re: [boost] Style Guideline
From: David Abrahams (dave_at_[hidden])
Date: 2008-10-31 12:58:56
on Fri Oct 31 2008, "Robert Jones" <robertgbjones-AT-gmail.com> wrote:
> 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
> it and broadly understanding it!
> Is enable_if intended only to include or exclude complementary
> of different templates from the possible set, or also to control whether
> a particular instantiation is available at all?
Did you read the docs?
> 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
> which is specific to vectors?
Depends what kind of error messages and partial specialization behaviors
> 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?
My advice: you found a new toy; don't look for places to apply it. Wait
until a use case hits you over the head and forces you to use it. Been
there many times myself ;-P
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk