maniacbug / StandardCplusplus

Standard C++ for Arduino (port of uClibc++)
594 stars 182 forks source link

functional not functional #14

Closed Makuna closed 1 year ago

Makuna commented 9 years ago

using the latest Arduino IDE, I try to define a callback type that will be lambda compatible like...

typedef std::function<void(float progress)> AnimUpdateCallback;

and I get a compile error about std.

ziqin commented 8 years ago

@Makuna

Seems there is no std::function template in the functional file of this project.

As Vlpp library implement vl::Func (which acts like std::function) without relying on STL, it may be of use to you. I've ported it to Arduino: https://github.com/ziqin/ArdComLib/tree/lambda/Vlpp

marcusrugger commented 8 years ago

@ziqin

Thanks for that link. Very helpful. I created a repo with just Vlpp and set it up as a proper Adruino library. You can now pull it down as a git submodule under the libraries folder in your project.

functional-vlpp repo

I also wanted to point out that I discovered a bug in the Adruino port. vl::Func does reference counting on the object it holds. Instead of increment/decrementing the counter, the port was increment/decrementing the pointer to the counter, causing bizarre, hard to identify problems. I have fixed it in my repo.

Since my repo isn't a clone of yours, I don't think using a pull request will work well. If you're interested in the fix, please take a look at this commit.

maniacbug commented 1 year ago

Sorry, functional objects came in C+11, and are not here in this library.

Makuna commented 1 year ago

@maniacbug What? I don't understand your comment. Std::Function objects are part of STL, not c++. Lamda support is part c++. They are two different things. Using Lamda is improved/made easier using functional. But as stated above, it is missing from "functional" header file (part of stl).