Question: Could anyone tell me why this doesn't work? 

```
enum CompCriteria{ByKey,ByValue,ByeKeyAndValue};

template<class T>
struct X;

template<>
struct X<CompCriteria>
{
};

int _tmain(int argc, _TCHAR* argv[])
{
    X<CompCriteria::ByeKeyAndValue> x;
    return 0;
}

```

Answer: 
You're conflating the idea of parameterized *types* and parameterized *values*. A template parameter can be a type, or a constant. For example:

```
template <typename T>
struct Foo;

```

versus..

```
template <int N>
struct Foo;

```

It looks like you want to specialize your template based on an enum *constant*, rather than a type. Meaning, you need to say:

```
enum CompCriteria{ByKey,ByValue,ByeKeyAndValue};

template<CompCriteria>
struct X;

// Specialization for ByKeyAndValue
//
template<>
struct X<ByeKeyAndValue>
{
};

int main()
{
    X<ByeKeyAndValue> x; // instantiate specialization 
    return 0;
}

```

Also, you can't refer to enums using the `namespace` operator. If you want to encapsulate your enums, you need to wrap them in a namespace:

```
namespace CompCriteria
{
   enum type {ByKey,ByValue,ByeKeyAndValue};
}

```
```
enum CompCriteria{ByKey,ByValue,ByeKeyAndValue};

template<CompCriteria crit_>
struct X
{
    static const CompCriteria crit = crit_;
};

int _tmain(int argc, _TCHAR* argv[])
{
    X<CompCriteria::ByeKeyAndValue> x;
    return 0;
}

```