Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-09-24 06:40:37

<< cross-posted to clc++m in reply to >>


Problem: Without typeof, what is the result type of the expressions
(x + y), (x += y), (c ? x : y), (++x), (x++), etc. ?

Jaakko Jarvi and I are working on the Boost Lambda Library
( and Phoenix
merger (
Hopefully that will happen sometime in the near future. In an attempt
to do a better type deduction mechanism than what's provided in LL
(and Phoenix), I experimented with this idea:

(see [ ] )

In many cases, the result type of a binary expression is related to one of
its operands. The limited form of type deduction presented can detect
common relations if the result of a binary or unary operation, given arguments
x and y with types X and Y (respectively), is X, Y, X&, Y&, X*, Y*, X
const*, Y const*, bool, int, unsigned, double, container and iterator
elements (e.g the T, where X is: T[N], T*, vector<T>, map<T>,
vector<T>::iterator). More arguments/return type relationships can be
established if needed.

The (fully commented) code is just a prototype. The final version is slightly
different (some tweaks and bug-fixes here and there). Email me if you wish
to see the latest code.


Joel de Guzman

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