   Template constructor syntax
  I have a very basic question regarding templated class contructor syntax. What is the difference in the way they are declared between these two classes?edit: To save you time, the only difference is range<datatype>() compared to range() - ie, without <datatype> in the constructor dec.template <typename datatype>struct range{range<datatype>() {}range<datatype>(const range<datatype> &that) : Minimum(that.Minimum), Maximum(that.Maximum) {}range<datatype>(const datatype &minimum,const datatype &maximum) : Minimum(minimum), Maximum(maximum) {}datatype Minimum;datatype Maximum;};template <typename datatype>struct range{range() {}range(const range<datatype> &that) : Minimum(that.Minimum), Maximum(that.Maximum) {}range(const datatype &minimum,const datatype &maximum) : Minimum(minimum), Maximum(maximum) {}datatype Minimum;datatype Maximum;};My Microsoft compiler seems to be perfectly fine with both. But for some reason, intellisense malfunctions through the entire module if I use the first syntax.Thanks for any help.[Edited by - Kest on September 9, 2007 11:04:37 AM]
  Without being 100% sure, i 'm quite confident that the template argument in the first case is just redundant. It looks like an (unneeded) function template specialization.   ;  Compiler might not pick up the syntax difference, depending upon the compiler that you use.  I expect that a recent version of GCC would.However, have you instantiated both cases?  I think that this would pick up a problem.  It is usually at instantiation that these types of things reveal an error, and I suspect that is where the MS compiler complains about the first version.In my view the ctor templated identifiers are wrong in the first version, but some compilers are pretty liberal when parsing template syntax.--random   ;  Just FYI guys , both versions compile cleanly in gcc 4.1.2 (including integer instantiation and output of Minimun/Maximum). But i also agree the second version is better.   ;  As far as I can discern, both versions compile and perform correctly at runtime with MSVS 2003.   ;  According to the standard (section 14.6, template name resolution) if you have a template <class T> struct A. inside the class template, A and A<T> are synonyms.   ;  I think the first version is deprecated or non-official. Edit: As SiCrane mentioned, 14.6-6 states that A is synonymous to A<T>.I work with VS, Metrowerks and GCC and I remember getting a warning on one of those compilers when using the construct in the first example.I didn't find anything definite in C++ 14882/2003, but all the examples use the second form. If you have the standard, see for example 14.5.1-2, 14.5.1.1-2.Tried a bit similar construct on a version of GCC:template<typename T>class Foo{   Foo();}; template<typename T>Foo<T>::Foo<T>(){}Error: invalid use of constructor as a templateThis compiles fine:template<typename T>class Foo{    Foo(); };template<typename T>Foo<T>::Foo() // The only difference on this line.{};  I appreciate the information. I'm happy using only the second syntax.Extra thanks to you, SiCrane.   ;Quote:Original post by clbError: invalid use of constructor as a templateAfaik, this is always an error. There is no such thing as a templated constructor.   ;Quote:Original post by iMalcAfaik, this is always an error. There is no such thing as a templated constructor.Sure there is, the standard library uses then quite heavily. Ex: all the versions of the container class constructors that take input iterator ranges. The problem with clb's code is that the Foo<T> isn't inside the class template.   