Boost Parameter Minialbeispiel kompiliert nicht



  • Ich spiele Gerade etwas mit Boost Parameter rum, bekomme aber nichts zum kompilieren. Dabei habe ich festgestellt, dass nicht mal das minimalbeispiel aus der Boost Doku kompiliert:

    #include <iostream>
    #include<boost/parameter/keyword.hpp>
    #include<boost/parameter/name.hpp>
    #include<boost/parameter/parameters.hpp>
    
    BOOST_PARAMETER_NAME(name)
    BOOST_PARAMETER_NAME(index)
    
    struct myclass_impl
    {
        template <class ArgumentPack>
        myclass_impl(ArgumentPack const& args)
        {
            std::cout << "name = " << args[_name]
                      << "; index = " << args[_index | 42]
                      << std::endl;
        }
    };
    
    struct myclass : myclass_impl
    {
        BOOST_PARAMETER_CONSTRUCTOR(
            myclass, (myclass_impl), tag
          , (required (name,*)) (optional (index,*))) // no semicolon
    };
    int main(int argc, char **argv) {
    }
    

    liefert:

    /home/andreas/projects/Testboost/main.cpp:23:18: error: expected identifier before ‘(’ token
    /home/andreas/projects/Testboost/main.cpp:23:34: error: ‘tag’ is not a type
    /home/andreas/projects/Testboost/main.cpp:24:9: error: expected identifier before ‘(’ token
    /home/andreas/projects/Testboost/main.cpp:24:19: error: expected ‘)’ before ‘(’ token
    /home/andreas/projects/Testboost/main.cpp:24:19: error: expected ‘)’ before ‘(’ token
    /home/andreas/projects/Testboost/main.cpp:24:20: error: ‘name’ has not been declared
    /home/andreas/projects/Testboost/main.cpp:24:25: error: expected identifier before ‘*’ token
    /home/andreas/projects/Testboost/main.cpp:24:26: error: ISO C++ forbids declaration of ‘BOOST_PARAMETER_CONSTRUCTOR’ with no type [-fpermissive]
    /home/andreas/projects/Testboost/main.cpp:24:26: error: ‘BOOST_PARAMETER_CONSTRUCTOR’ declared as function returning a function
    /home/andreas/projects/Testboost/main.cpp:24:26: error: expected ‘;’ at end of member declaration
    /home/andreas/projects/Testboost/main.cpp:24:27: error: expected unqualified-id before ‘)’ token
    

    Wie kann das sein?



  • Hat sich erledigt, war ein vergessenes include. Wobei das nirgendwo erläutert war und auch die Fehlermeldung nicht geholfen hat.


Anmelden zum Antworten