```
goals:
1. store constants with their assignments in a header
2. keep constants in a namespace (without using #define)
3. allow constants to be whatever precision is needed for the app

```

I am trying to keep all constants for my header only library in the same namespace. I decided to do away with `#define`s and do things the right way, such as using:

```
namespace studio
{
    namespace constant
    {
        const char* WHITE_SPACE = "\n\r\t ";
    }
}

```

The hope is to access this like so:
`studio::constant::WHITE_SPACE`

*This is all fine and good, from what I have gathered, doing it this way creates one of these for each translation unit, potentially to be optimized down to a single instance during linking. Even if it is not optimized like that, it is probably okay in this case.*

The trouble comes when I want to add other types besides const char \* as constants. For example, say I want to allow a float type (double or float) as a constant, but I would like to do it as a template so I don't have to do something like:

```
namespace studio
{
    namespace constant
    {
         const char* WHITE_SPACE = "\n\r\t ";
         const float PI_FLOAT = 3.141592653589793;
         const double PI_DOUBLE = 3.141592653589793;
    }
}

```

So I tried using a templated class instead of a namespace, with static functions which return the static constant like so:

```
namespace studio
{
    template <class FloatType = float>
    class constant
    {
    public:
        static const char* white_space_chars() {
            static const char* whiteSpaceChars = "\n\r\t ";
            return whiteSpaceChars;
        }
        static const FloatType pi() {
            static const FloatType _pi = 3.141592653589793;
            return _pi;
        }
    }
}

```

This would then be accessed this way: `studio::constant<float>::pi()`

But now I have the problem where I have to supply a template parameter if I want one of my const chars even though they have nothing to do with floats, they must be accessed like so:
`studio::constant<float>::white_space_chars()`
because
`studio::constant::white_space_chars()`
does not work, even though I specified a default template parameter, apparently that only works for classes. C++ does not allow defaults on function templates.

So now the only way I can see to get around this is to have studio::constant\_char, studio::constant\_float, studio::constant\_int, etc. That is ridiculous, right?

Really all I want is to have my defines in a namespace...

Do you know a better way to do what I am trying to do, where variables of different types can be used template like in the studio::constant namespace without forcing the user of the library to specify the type for each template parameter? Preferably not using C++11 to be more backward compatible.