|
Boost Users : |
From: Stjepan Rajko (stipe_at_[hidden])
Date: 2007-12-11 21:02:29
On Dec 11, 2007 1:03 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:
>
> 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 );
> };
>
So why not use Jeff Flinn's suggestion:
template< typename T >
struct default_alpha;
template<>
struct default_alpha<float>
{
static float value() { return 1.0f; }
};
template<>
struct default_alpha<unsigned char>
{
static unsigned char value() { return 255; }
};
template< typename T >
class Color
{
public:
Color( T r, T g, T b, T a = default_alpha<T>::value() );
};
...?
Stjepan
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