Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-01-28 14:56:19


"Rozental, Gennadiy" <gennadiy.rozental_at_[hidden]> writes:

> Hi,
>
> Is there neat way with MPL to implement conditional expessions without
> introducing aditional structures. For example:
>
> template<typename Container>
> void
> foo( Container& c )
> {
> // pseudo code
> [if ( c is reservable , i.e. has method reserve )
> c.reserve( 100 );
> ]
> ...
> }
>
> Gennadiy.

If I understand the question correctly (not sure I do because it's
vaguely worded), the answer is no. C++ compilation in general is not
lazy, so you can't defer the call to reserve() unless you go through a
level of template indirection.

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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