Boost logo

Boost :

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" <> 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
> 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?

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
> vectors
> which is specific to vectors?

Depends what kind of error messages and partial specialization behaviors
you want.

> 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

Good Luck,

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at