Skip to content

StaticFunction const, nonconst #20

@user706

Description

@user706

Hi,

related to #19 (and thus using code from branch develop) ... I'm just meddling with a similar library (ref),
and came across an issue, that affects StaticFunction as well:

// ...

#include <iostream>

struct Func {
    void operator()() const {
        std::cout << "const   ";
    }

    void operator()()  {
        std::cout << "nonconst";
    }
};



int main()
{
    {
        Func func{};
        embxx::util::StaticFunction<void(), 32> f(func);
        f();
        std::cout << "\t should get ";
        func();
        std::cout << std::endl;
    }
    {
        const Func func{};
        embxx::util::StaticFunction<void(), 32> f(func);
        f();
        std::cout << "\t should get ";
        func();
        std::cout << std::endl;
    }
}

This prints

nonconst	 should get nonconst
nonconst	 should get const   

So with the mutable (ref)... the void operator()() const is not called in the end...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions