Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2002-01-28 00:44:25


on 1/27/02 6:11 PM, James Kanze at kanze_at_[hidden] wrote:

> "mfdylan" <dylan_at_[hidden]> writes:
[SNIP]
> |> I'd prefer
>
> |> format("array[%1] = %2", i, array[i]);
>
> The cleanest is obviously something like:
>
> format( "array[%1] = %2" ).with( i ).with( array[ i ] );
>
> The grouping is obvious (and the compiler's grouping matches up with
> what the programmer expects), and since the operation doesn't really
> correspond to anything for which there is a pre-defined operator (except
> <<).
>
> |> Although if you allow for manipulators between parameters, even with
> |> only 9 parameters you would have to support a helluva lot of
> |> template variants.
>
> Manipulators, as such, are a hack, which aren't needed. What can be
> useful is passing additional parameters to with (above), when the width
> or the precision are calculated dynamically.
[TRUNCATE]

Maybe there can be several (template) member functions:

with
    indicates a value to be printed
apply
    indicates a stream-changing function (object) to be run
apply_once
    like "apply," but its effects wear off after the next "with"

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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