Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. how to fix error C2993: 'float' : illegal type for non-type template parameter '

how to fix error C2993: 'float' : illegal type for non-type template parameter '

Scheduled Pinned Locked Moved ATL / WTL / STL
helpquestiontutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hemant kulkarni
    wrote on last edited by
    #1

    Hi, I am porting a VC6.0 code to VS2008. I have a class with following decalration template type lowerBound, type upperBound> class TempClass { public: TempClass(void ); //virtual ~TempClass(void); protected: type mValue; }; template TempClass<type,>::TempClass(void) { // TBI } I am declaring a pointer to this class as TempClass <float, 1,2> *pT1; I am getting the error error C2993: 'float' : illegal type for non-type template parameter 'lowerBound' error C2993: 'float' : illegal type for non-type template parameter 'upperBound' how can I fix this problem? I cannot use the pointers for lowerBound, upperBound.

    S J 2 Replies Last reply
    0
    • H Hemant kulkarni

      Hi, I am porting a VC6.0 code to VS2008. I have a class with following decalration template type lowerBound, type upperBound> class TempClass { public: TempClass(void ); //virtual ~TempClass(void); protected: type mValue; }; template TempClass<type,>::TempClass(void) { // TBI } I am declaring a pointer to this class as TempClass <float, 1,2> *pT1; I am getting the error error C2993: 'float' : illegal type for non-type template parameter 'lowerBound' error C2993: 'float' : illegal type for non-type template parameter 'upperBound' how can I fix this problem? I cannot use the pointers for lowerBound, upperBound.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Directly? You can't - C++ requires integral types for non-type template parameters. How about supplying the parameters as ints and casting to the required type in the class, like this?

      template<class Type, int LowerBound, int HigherBound>
      class TempClass { ... };

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      1 Reply Last reply
      0
      • H Hemant kulkarni

        Hi, I am porting a VC6.0 code to VS2008. I have a class with following decalration template type lowerBound, type upperBound> class TempClass { public: TempClass(void ); //virtual ~TempClass(void); protected: type mValue; }; template TempClass<type,>::TempClass(void) { // TBI } I am declaring a pointer to this class as TempClass <float, 1,2> *pT1; I am getting the error error C2993: 'float' : illegal type for non-type template parameter 'lowerBound' error C2993: 'float' : illegal type for non-type template parameter 'upperBound' how can I fix this problem? I cannot use the pointers for lowerBound, upperBound.

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        template<class lowerBoundType, class upperBoundType>
        Class TempClass
        {
        …
        };

        OR

        template<typename lowerBoundType, typename upperBoundType>
        Class TempClass
        {
        …
        };

        Reasonable Declarations:

        TempClass<float, float>* pT1.
        TempClass<double, double>* pT1.
        TempClass<int, int>* pT1.

        If both upper and lower bounds use the same type, which would make since, then a more reasonable template would be:

        template<typename boundryType>
        Class TempClass
        {
        …
        };

        Declaration:

        TempClass<float>* pT1.

        INTP
        "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups