Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-02-12 08:12:40

Alan Gutierrez wrote:

> Has there been any consderation given to the use of named parameters
> with boost::format?
> use boost::format;
> std::cout << format ("%first-name% %last-name%")
> % format::arg("first-name", "Alan")
> % format::arg("last-name", "Gutierrez")
> << std::endl;
> It would not be terribly difficult to implement.

I did something like this some time ago.

    named_param p_name("name"), p_age("age");
    std::string your_name = get_your_name();
    unsigned int your_age = get_your_age();
    std::cout << format("{name} is {age} years old.\n",
                        p_name = your_name,
                        p_age = your_age);

IMHO, it's very useful feature.

Alexander Nasonov
Remove -mycop from my e-mail address for timely response

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