Commit requires lambdas


Just a heads up that the new commit: Refactored the way OSX main menu updating happens, to avoid some issu… …es when refreshing the whole menu bar uses

MessageManager::callAsync ([=]()





yes… but this is in OSX-specific code, so that should always be the case, right?



I just ran into it with an older project… I had to change the project settings to use:

C++ Standard Library: libc++ (LLVM C++ standard library with c++11 support)

That’s now my default setting for new projects… but I’m not sure if that’s a given… unless you make that a JUCE MacOS requirement.



Yes, we are making C++11 a requirement for the latest code. We’ll probably remove the JUCE_COMPILER_SUPPORTS_LAMBDAS flag at some point too for the JUCE 5 release.


Cool, I have no problem changing my project settings… I actually didn’t realize it wasn’t set on this project… so I’m glad to have had the nudge… but since this is the first commit which requires C++11 you may want to make an announcement/sticky.




Thanks. TBH I thought we’d already used some lambdas in there - we’re certainly already using a bunch of other C++11 features.


Projects targetting 10.6.8 break by this commit which doesn’t work with libstdc++ required by 10.6.8. The problem is not lambdas per se. These are supported by the compiler, but the libstd++ library that doesn’t support std::function and some other lambda related stuff. So far you have worked around this issue and in my opinion it would be good to do this here to.


It would be possible to rewrite MessageManager::callAsync using templates btw. As gcc4.2 does have template support and can therefore insert lambda code in templates. I use this to get the same functionality as the new MessageManager::callAsync.

// lambdas on the message thread without std::function for OSX 10.6 support
template<typename Func>
class LambdaMessage : public CallbackMessage {
    LambdaMessage(Func f_) : f(f_) {}
    void messageCallback() override {
        auto f2 = f;
        delete this;
    Func f;

template<typename Func>
void performOnMessageThreadAsync(Func f) {
    (new LambdaMessage<Func>(f))->post();

and then I call like this:

performOnMessageThreadAsync([=]() { myAwesomeCode(); });


Yeah, good point - let me have a look, I’ll remove the std::function…