type/value mismatch at argument with Template

user1545583

I am writing some c++ template code to replace if-else conditions in present source. Here, I am deriving Helper data type based on two conditions, 1. isAdvice 2. SimpleOrComplex

See below template code:

template<bool isAdvice, class SH, class CH>
class IfThenElse;

template<class SH, class CH>
class IfThenElse<true, SH, CH>
{
    public:
    typedef SH Helper;
};

template<class SH, class CH>
class IfThenElse<false, SH, CH>
{
    public:
    typedef CH Helper;
};

template <bool isAdvice, bool SimpleOrComplex>
class DeriveHelper
{
    public:
        typedef typename IfThenElse<isAdvice,
                 IfThenElse<SimpleOrComplex, SimpleHelper, ComplexHelper>::Helper,
                 IfThenElse<SimpleOrComplex, SimpleNoAdvHelper, ComplexNoAdvHelper>::Helper>::Helper DerivedHelper;


};

However, Getting this error at compilation:

template.cpp:135: error: type/value mismatch at argument 2 in template parameter list for 'template<bool isTradeAdvice, class SH, class GH> struct IfThenElse'
template.cpp:135: error:   expected a type, got 'IfThenElse::Helper'
template.cpp:135: error: type/value mismatch at argument 3 in template parameter list for 'template<bool isTradeAdvice, class SH, class GH> struct IfThenElse'
template.cpp:135: error:   expected a type, got 'IfThenElse::Helper'

Can someone please suggest the reason?

Marco A.

You should prepend a typename keyword for the two template type parameters IfThenElse as you did for the first one

template <bool isAdvice, bool SimpleOrComplex>
class DeriveHelper
{
public:
    typedef typename IfThenElse<isAdvice,
                 typename IfThenElse<SimpleOrComplex, SimpleHelper, ComplexHelper>::Helper,
                 ^^^^^^^^
                 typename IfThenElse<SimpleOrComplex, SimpleNoAdvHelper, ComplexNoAdvHelper>::Helper>::Helper DerivedHelper;
                 ^^^^^^^^
};

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

type/value mismatch at argument with Template

From Dev

C++ template - type/value mismatch at argument

From Dev

C++ template - type/value mismatch at argument

From Dev

Argument type mismatch using nifi template import API

From Dev

Class Template Specialisation, C++, mismatch at argument 2 in template parameter list

From Dev

Specialization of a class template method, with typenames that are class template - error: type/value mismatch at argument

From Dev

Java Generics argument mismatch

From Dev

Argument mismatch in python constructor

From Dev

template argument of template class

From Dev

Template function as template argument

From Dev

Template Template argument not in scope

From Dev

Template function as template argument

From Dev

Restful service argument mismatch exception

From Dev

ByRef Argument type mismatch with Boolean

From Dev

JavaFx Event argument type mismatch

From Dev

ByRef Argument type mismatch with Boolean

From Dev

Type mismatch in variadic template inheritance

From Dev

Type mismatch in variadic template inheritance

From Dev

template argument deduction for const argument

From Dev

C++ template argument of template argument

From Dev

Using a template class as a template argument

From Dev

Invalid argument in template template parameter

From Dev

template method and default template argument

From Dev

Template class with no use of template argument

From Dev

Templated template specialization for template argument

From Dev

Java argument type mismatch while reflection

From Dev

VBA ByRef Argument Type Mismatch string into string

From Dev

Argument Mismatch when using the collect Stream method

From Dev

argument type mismatch by Using BeanUtils.copyProperties

Related Related

  1. 1

    type/value mismatch at argument with Template

  2. 2

    C++ template - type/value mismatch at argument

  3. 3

    C++ template - type/value mismatch at argument

  4. 4

    Argument type mismatch using nifi template import API

  5. 5

    Class Template Specialisation, C++, mismatch at argument 2 in template parameter list

  6. 6

    Specialization of a class template method, with typenames that are class template - error: type/value mismatch at argument

  7. 7

    Java Generics argument mismatch

  8. 8

    Argument mismatch in python constructor

  9. 9

    template argument of template class

  10. 10

    Template function as template argument

  11. 11

    Template Template argument not in scope

  12. 12

    Template function as template argument

  13. 13

    Restful service argument mismatch exception

  14. 14

    ByRef Argument type mismatch with Boolean

  15. 15

    JavaFx Event argument type mismatch

  16. 16

    ByRef Argument type mismatch with Boolean

  17. 17

    Type mismatch in variadic template inheritance

  18. 18

    Type mismatch in variadic template inheritance

  19. 19

    template argument deduction for const argument

  20. 20

    C++ template argument of template argument

  21. 21

    Using a template class as a template argument

  22. 22

    Invalid argument in template template parameter

  23. 23

    template method and default template argument

  24. 24

    Template class with no use of template argument

  25. 25

    Templated template specialization for template argument

  26. 26

    Java argument type mismatch while reflection

  27. 27

    VBA ByRef Argument Type Mismatch string into string

  28. 28

    Argument Mismatch when using the collect Stream method

  29. 29

    argument type mismatch by Using BeanUtils.copyProperties

HotTag

Archive