Boost logo

Boost :

Subject: Re: [boost] [c++11]
From: Niall Douglas (ndouglas_at_[hidden])
Date: 2013-06-17 17:54:37

> I wasn't suggesting making the library strictly C++03-compatible. My main
> point was that the library has to be compatible with _todays_ and even
> - _yesterdays_ compilers to be actually useful. My choice of "reasonable"
> frame is 3-5 years, as I mentioned. That includes VS 2008 and VS 2010,
> already had some C++11 features, including rvalue references. Making VS
> absolute minimum is a no-go, IMHO.

I don't think anyone is making VS2013 an absolute minimum - rather they're
making variadic templates an absolute minimum. Something which any other
compiler than VS has had for years, and something which unlike many, if not
most other C++11 language features is something which lets you write a ton
of stuff you simply can't write without them.

Now, nothing in proposed Boost.AFIO uses variadic templates in a way not
replaceable with preprocessor programming. However it very /nearly/ did: I
had this neato bit of evil variadic instantiation which let you convert an
unknown set of trailing args into a std::tuple<> for storage, then /unpack/
said std::tuple<> back into an unknown set of trailing args, all with
perfect forwarding. Effectively it was a compile-time std::function<>

As proposed Boost.AFIO is also a closure execution engine where that closure
can take arbitrary args and return arbitrary returns, that evil variadic
template machinery was really useful because it lets you skip using
std::function<> with its implied virtual function call. As proposed
Boost.AFIO currently nests, in the worst case scenario, a fully bound
std::function<> calling a partially bound std::function<> calling a
partially bound std::function<>, that's three nested virtual indirect
function calls. Recent Intel CPUs can prefetch and branch predict two
nesting levels, but they can't cope with three, so performance takes a real
nose dive and hence one of the reasons we currently see a peak 80k IOPS.
That evil variadic template machinery gets rid of that problem. And its only
replacement is std::function<> - you *cannot* implement that functionality
(pure compile time std::function<>) without variadic templates because you
can't properly unpack them without.

None of this matters for proposed Boost.AFIO. But it certainly matters for
the forthcoming C++11 only libraries coming soon to Boost, because they make
/very/ heavy usage of functionality only possible with variadic templates.
That means that they will require, as an absolute minimum for VS, VS2013 or
Nov 2012 CTP. Other C++11 features one can make do without without too much
cost, but losing variadic templates means a ton of extra source code
complexity, much longer compile times and chopping out a lot of what C++11
enables which simply can't be done in C++03.

I suspect that those libraries are probably going to force a new "variadic
template support is mandatory" category of Boost libraries, probably sooner
rather than later. I agree it's going to be frustrating for those stuck with
older compilers: I pity those whose employers force MSVC6 on them to this
very day.


Opinions expressed here are my own and do not necessarily represent those of
BlackBerry Inc.

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