Boost logo

Boost :

From: boost (boost_at_[hidden])
Date: 2001-05-02 05:34:07


Salut,

On Tuesday 01 May 2001 20:14, you wrote:
> I have investigated this further but see snags.
>
> namespace boost
> {
> namespace math
> {
> // Example from // B Stroustrup ISBN 0 201 70073 5, p 854
> template<class T> class X
> {
> static T d; // Must be separately defined.
> // static T const d; // const not allowed by MSVC
> };
> template<class T>T X<T>::d = 0; // template NOT specialised.
> template<>int X<int>::d = 0; // Specialised for int.
[...]

I have one question:
My g++ v2.95.4 (and 2.95.3) allows static const members to be initialized in
the the class declaration:

template< typename F> class Q
{
  public:
      static const F zz = 17;
}
  
and it works fine. Is this a g++ extension?

BTW,
template<typename T>
class Q
{
  public:
    static const T pi;
}

template<>
const double Q<double>::pi = 3.1415;

works under MS VC++ 6 (SP5). I've just tested it.

Best wishes
Peter


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk