Sorry, small corrections to my last code example (I had a few typos):

template< typename T >
struct default_alpha;

template<>
struct default_alpha<float>
{
    static const float value = 1.0f; // Note that this is not legal. I'm simply just presenting pseudo code.
};

template<>
struct default_alpha<unsigned char>
{
    static const unsigned char value = 255;
};

template< typename T >
class Color
{
    Color( T r, T g, T b, T a = default_alpha<T>::value );
};


On Dec 11, 2007 2:01 PM, Robert Dailey <rcdailey@gmail.com > wrote:
Well, the namespace idea won't work either. There's certain details I omitted because I wasn't sure if they would be directly related to the issue. However I'll go ahead and elaborate now.

I plan to specialize the struct containing the float to determine what 'value' I want. For example:

template< typename T >
struct default_alpha;

template<>
struct default_alpha<float>
{
    static const float alpha = 1.0f;
};

template<>
struct default_alpha<unsigned char>
{
    static const unsigned char = 255;
};

So, if I have a 'color' class that takes a template parameter, like below, I can use the above specialized structures to figure out how to default initialize the 'a' construction parameter.

template< typename T >
class Color
{
    Color( T r, T g, T b, T a = default_alpha<T>::value );
};

Again, I wasn't sure if these new details were required from the very beginning. Apologies for this. Thank you for everyone's continued help.

On Dec 11, 2007 1:14 AM, Roman Perepelitsa <roman.perepelitsa@db.com> wrote:
Robert Dailey <rcdailey <at> gmail.com> writes:
>
>
> I'm going to be using this float to default-initialize a construction
> parameter. For example:
> struct default_alpha
> {
>     static const float value = 1.0f;
> };
> class foo
> {
>  foo( float r, float g, float b, float a = default_alpha::value );
> };
>

You can use constant in namespace scope:

namespace default_alpha
{
   static const float value = 1.0f;
}

HTH,
Roman Perepelitsa.

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