too few template-parameter-lists

Discussion in 'C++' started by Kaushal, Nov 18, 2008.

  1. Kaushal

    Kaushal Guest

    #include <iostream>

    #include <boost/mpl/vector.hpp>
    #include <boost/mpl/find.hpp>

    using namespace std ;
    using namespace boost ;

    template <typename numericTypes>
    struct evalThis
    {
    void operator()()
    {
    typedef mpl::find<numericTypes, char>::type iter ; //
    ERROR : error: too few template-parameter-lists
    }
    } ;

    int main()
    {
    typedef mpl::vector<int, float, char, double, long>
    myNumericTypes ;

    evalThis<myNumericTypes> myObj ;
    myObj.operator()() ;

    return 0 ;
    }
    Kaushal, Nov 18, 2008
    #1
    1. Advertising

  2. Kaushal

    Guest

    On Nov 18, 1:13 pm, Kaushal <> wrote:
    [...]
    > // ERROR : error: too few template-parameter-lists
    > typedef mpl::find<numericTypes, char>::type iter;



    It's just another C++ wart: the problem is that
    mpl::find<numericTypes, char>::type could be a value
    or a type, depending on the template arguments.
    The language assumes it's a value, so what you've
    got there would be like saying:

    struct Person { string name; };
    ...
    typedef Person::name iter;

    where name is obviously a value and not a type.

    The solution is to explicitly tell the compiler that it's
    a type with "typename":

    typedef typename mpl::find<numericTypes, char>::type iter ;

    You can read more about the issue here:

    http://www.comeaucomputing.com/techtalk/templates/#typename

    Cheers,
    Sean

    PS: the previous post asking how the hell mpl::find is defined is
    this newsgroup's surprising vernacular for telling you that your
    post is off-topic. You might have a friendlier reception
    on a Boost mailing list.
    , Nov 18, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron B.
    Replies:
    2
    Views:
    6,500
    Erich Reimberg N.
    Nov 23, 2004
  2. geletine

    Too few parameters. Expected 2

    geletine, May 21, 2006, in forum: Java
    Replies:
    3
    Views:
    7,790
    geletine
    May 22, 2006
  3. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    390
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  4. Murali
    Replies:
    2
    Views:
    544
    Jerry Coffin
    Mar 9, 2006
  5. Stuart Redmann
    Replies:
    5
    Views:
    469
    Stuart Redmann
    Dec 14, 2007
Loading...

Share This Page