I want to define a set of floating point constants using templates insteand

of macros. I'd like to determine whether these constants are floats or

doubles at compile time. In my header file, I have this:

template<bool DoublePrecision >

struct Constants

{

typedef double SampleType;

static const double pi;

static const double piDoubled;

static const double SampleRateDefau lt;

static const double DenormalOffset;

};

template<>

struct Constants<false >

{

typedef float SampleType;

static const float pi;

static const float piDoubled;

static const float SampleRateDefau lt;

static const float DenormalOffset;

};

In my implementation file, I have this

#include "Constants. h"

const double Constants<true> ::pi = 3.1415926535897 9;

const double Constants<true> ::piDoubled = Constants<true> ::pi * 2.0;

const double Constants<true> ::SampleRateDef ault = 44100.0;

const double Constants<true> ::DenormalOffse t = 1.0E-25;

const float Constants<false >::pi = 3.141593f;

const float Constants<false >::piDoubled = 6.283185f;

const float Constants<false >::SampleRateDe fault = 44100.0f;

const float Constants<false >::DenormalOffs et = 1.0E-25f;

My question is whether the values definined here will ultimately be inlined

by the compiler where they are used. They are definined in one compilation

unit but will be used in other compilation units. Will this prevent them

from being inlined? In other words, will this ultimately be less efficient

than using macros?