Well I read the standard, and it really more or less discusses what you *can't* use to initialize default parameters. Amongst that list I didn't see functions. And behold, it worked! I guess I don't need boost after all. All these years I kept thinking that only compile-time constants could be used to initialize default parameters. I never use default parameters anyway, so I can understand. Just goes to show that you learn new things every day, regardless of how obvious things are :)

Thanks guys.

On Dec 12, 2007 10:08 AM, Stjepan Rajko <stipe@asu.edu> wrote:
On Dec 12, 2007 8:07 AM, Robert Dailey <rcdailey@gmail.com> wrote:
> Are function calls allowed to default initialize a construction parameter?
> Does the compiler turn the function into a constant? How does that work? I
> wasn't aware you could do this...
>

I was asking the same questions, which is what prompted me to try to
find the answers in the standard.  If you can get your hands on it
(I'm looking at ISO/IEC 14882:2003), section 8.3.6. talks about what
can and can't be used for default argument values.  Anyway, the
compiler will evaluate the expression when the function is called, but
not all expressions are valid (the ones I put in the example should
be).  If this doesn't work for you, you can always have two
constructors - one taking 4 arguments and one taking 3, initializing
the alpha value to just about anything.

I would suggest a C++ list or channel to get more info, we've strayed
a bit from Boost :-)  But I found it helpful too.

Cheers,

Stjepan
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users