Boost logo

Boost :

Subject: Re: [boost] [xint] Boost.XInt formal review
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2011-03-07 11:39:20


On 07/03/11 14:16, Eric Niebler wrote:
> It remains to be seen what, if anything, can be done to make expression
> templates and "auto" play nicely in C++0x. But I suspect the answer is:
> nothing.

Again, the question is what people expect auto to do in this case.

> Joel, I'm honored by your enthusiasm for Proto, but in this
> case, I think it's misplaced. For a simple value type like an infinite
> precision integer, expression templates are just plain dangerous.
>

I actually disagree. For me it depends of the underlying representation.
If the integer rep itself is static and dont incur any allocation, then
yeah,
let's play with ref-count or NRVO all along. I still think that for a
dynamic
sized large int, it is basically a subset of the "ET for matrix" problem.

And even for static sized large integer, what about pattern matching for
local
optimization ?

Then again, I can be the one dealing bollocks atm.

> I could imagine a design that uses a) the small object optimization for
> ints below a certain threshold, and b) a ref-counted handle/body idiom
> for everything else (like xpressive's regex objects), where the body
> could be either i) a simple big-int terminal or ii) a type-erased
> expression template that keeps its referenced bodies alive until an
> evaluation is needed, and so avoid unnecessary allocations for
> intermediate expressions.

I agree but in this case, you still use "expression template" in a type
erased
context.

> It must be done such that adding two big-ints
> yields a big-int. "auto i = x + y;" simply MUST work, always, though it
> need not actually do any addition.
>

Yeah, i wonder if the expression template stuff using recursive variant
in the old vault
can't be what we need. It is basically that: ET with Type Erasure that
keep everything
proper.


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