compiler support for partial template specialization

Hi all.

I am working on a class that I would like to specialize on a single template parameter, but fall back to something less efficient if the compiler does not support partial template specialization. In order for this to work I must wrap the specialization code in an #ifdef..#endif block so that older compilers don't choke.

However, I have not been able to verify very many compilers that support this feature of the C++ standard. This is what I currently have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//----------------------------------------------------------------------------
// Define PARTIAL_TEMPLATE_SPECIALIZATION macro if not already defined and
//
//   Microsoft C++ version 7.1 or greater
//   GCC       C++ version 3.4 or greater
//   Intel     C++ version 8.0 or greater
//   Comeau    C++ version 4.3 or greater
//
// I am not certain these are correct, but that's the best I can do for now.
//
#ifndef PARTIAL_TEMPLATE_SPECIALIZATION

  #if defined(_MSC_VER) && (_MSC_VER >= 1310)
    #define PARTIAL_TEMPLATE_SPECIALIZATION

  #elif defined(__GNUC_MINOR__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)
    #define PARTIAL_TEMPLATE_SPECIALIZATION

  #elif defined(__GNUC_MINOR__) && (__GNUC__ >= 4)
    #define PARTIAL_TEMPLATE_SPECIALIZATION

  #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)
    #define PARTIAL_TEMPLATE_SPECIALIZATION

  #elif defined(__COMO__) && (__COMO__ >= 430)
    #define PARTIAL_TEMPLATE_SPECIALIZATION
  #endif

#endif 

If you have any of these compilers, could you please verify that this lists the earliest version that properly implements partial template specialization? (By "properly" I mean, for example, you may be able to do it with earlier versions, but only in a non-standard way.)

Or if you have a compiler not listed here that supports PTS, could you please tell me what it is and its version?

Thank you for your time.
Duoas, have you checked Boost's headers?

BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION

It's defined in boost/config/compiler/*.hpp
Yes, I had looked at that, but I'm not so sure it is very complete. Boost tends to be targeted towards very modern systems... but then again, templates are a fairly modern thing also...

Maybe I'll just make a compile flag that allows the user to explicitly turn off code that does PTS...

Hmm..


[Power outages are making it hard to stay online...]
Topic archived. No new replies allowed.