Amitha Perera wrote:
> On Wed 04 Oct 2006, Peter Vanroose wrote:
>> We've (had) the policy, certainly in the core, to not use partial
>> specialisation, to be able to support some compilers, and/or to
>> simplify code maintenance.
>>
>> Maybe it's time to address this choice again.
>
> I agree. With the C++ standard now 8 years old, and with a good
> dashboard, I think we should revisit the choices of allowable C++
> constructs in core.
>
> My own opinion is that the C++ allowed in the core should be the C++
> intersection of the C++ accepted by all the compilers on the dashboard
> and by the 98 standard.
FYI, this particular problem can be addressed in a way that still allows
VS6 to work compile the code. See below for example code.
The partialspec block is probably the proper way to implement the
constructors anyway.
For the nonpartialspec version the vnl_vector_fixed_construct function
is a template that initializes the data members using the arguments
given. I'm pretty sure the template can be implemented in VS6. It
won't restrict the user from providing the wrong number of arguments but
code that compiles with the partial spec version will compile and work
in VS6.
Brad
template <class T, int n>
class vnl_vector_fixed_impl
{
public:
// ... most of current vnl_vector_fixed
protected:
T data_[n];
};
#if VCL_CAN_DO_PARTIAL_SPECIALIZATION
template <class T, int n> class vnl_vector_fixed;
template <class T>
class vnl_vector_fixed<T, 2>: public vnl_vector_fixed_impl<T,2>
{
public:
vnl_vector_fixed(T const& a1, T const& a2)
{
this>data_[0] = a1;
this>data_[1] = a2;
}
};
//... other overloads
#else
template <class T, int n>
class vnl_vector_fixed: public vnl_vector_fixed_impl<T,n>
{
public:
vnl_vector_fixed(T const& a1, T const& a2)
{
vnl_vector_fixed_construct<T,n>(this>data_, a1, a2);
}
vnl_vector_fixed(T const& a1, T const& a2, T const& a3)
{
vnl_vector_fixed_construct<T,n>(this>data_, a1, a2, a3);
}
};
#endif
typedef vnl_vector_fixed<double, 2> vnl_double_2;
