c++ - using a conditional type in a .cpp file -


I have a templated class and a type that depends on the template. How can I use this in my CCP file?

object.hpp:

  pair_d = std :: pair and lt; Double, double> Pair_f = std :: pair & lt; Float, float & gt; Template & lt; Typename T & gt; Class Object {Public: Static_AstTort (Study :: ISIm ; value; std :: is_same : value, "type is not allowed"); Pair = typename std :: conditional & lt; Std :: is_same & lt; T, float & gt; :: value, pair_f, pair_d & gt; :: By typing; // conditional type const pair doSomething (T, T) function using const; }   

object.cpp

  #include "object.hpp" template & lt; Typename T & gt; Const pair object & lt; T & gt; :: doSomething (TT1, TT2) const {// ....}   

but I'm getting:

Error: Unknown type name 'pair'

How can I use the 'pair' type in my .cpp file?

  1. Arguments have been named with the same name (t T, TT) , separate those names.

  2. Do not do this, you have divided the template declaration / definition into CPP and a header file.

  3. You forgot about a const qualification on a return type in the definition (which is in the declaration).

  4. You are not a typename keyword for a dependent name.

    Your definition should be:

      template & lt; Typename T & gt; Const typame object & lt; T & gt; :: Pair object & lt; T & gt; :: doSomething (TT1, TT2) const {// stuff}   

    or (to avoid the dependent name):

      template & Lt; Typename T & gt; Auto Object & lt; T & gt; :: doSomething (TT1, TT2) const - & gt; Const pair {// stuff}    

Comments

Post a Comment

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -