Boost logo

Boost Users :

From: William Xue (william.xue_at_[hidden])
Date: 2006-10-11 21:36:28


On Thu, 12 Oct 2006 03:20:33 +0800, Aaron Griffin
<aaronmgriffin_at_[hidden]> wrote:

> On 10/11/06, William Xue <william.xue_at_[hidden]> wrote:
>> First, I am a new user of boost. I wonder of the style of
>> 'boost::format( format-string ) % arg1 % arg2 % ... % argN'.
>> I think it, format(...), as a function, but it seems not function in C
>> or
>> C++ style.
>
> variable arguments are very nasty in C++. Not only that, but the va_*
> macros do not allow for type safe generic programming (or type safety
> in general).
>
> The way it works is that boost::format("..."); returns an object which
> has the % operator defined. object % <anything> performs the
> operation and returns the same object. This allows for chaining.
>

Thank you very much! Your explanation is very clear. I am agree with you,
it's nasty.

As someone had said, the style smelt very bad.

Though C/C++ is very flexible, I do not like to broke the regular rules of
them.

Micrisoft have done something like this in their sample codes:
---8<--------------------------------------------->8---
#define PURE =0
...
interface xxx
{
...
int foo(...) PURE;
...
};
---8<--------------------------------------------->8---

I can not to find out any wisdom in doing things like this.

As a C/C++ user, I am very glad to see someone to extend the features of
them,
But IMHO, C/C++ is C/C++, do not go far away from the regular way.

Again, thanks.

> I'd assume the goal is to mirror python syntax.
>
> The problem with something like this:
> boost::format("...") % (a,b,c,d); is that C++ does not allow it. It
> is not syntactically correct.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
Sincerely yours,
William

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net