+++ /dev/null
-//
-// C++ Implementation: lambda object
-//
-// Description: allows to use lambda expressions (C++ 11) with Qt4
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2012
-//
-// Copyright: See README/COPYING.GPL files that come with this distribution
-//
-//
-
-#include "lambda.h"
-
-MLambda::MLambda(std::function< void() > l, QObject* parent): QObject(parent)
-{
- m_ptr=l;
-}
-
-void MLambda::call()
-{
- if(m_ptr)
- m_ptr();
-}
class MLambda:public QObject
{
Q_OBJECT
+ private:
+ std::function<void()>m_ptr;
public:
///instantiates the lambda object, e.g.
/// \code
///button.show();
/// \endcode
///the above code will show the value of the variable 'x' whenever the user clicks the button
- MLambda(std::function<void ()>l,QObject* parent = 0);
+ MLambda(std::function<void ()>l,QObject* parent = 0):QObject(parent),m_ptr(l){}
public slots:
///generic slot that transparently executes the lambda expression
- void call();
- private:
- std::function<void()>m_ptr;
+ void call(){if(m_ptr)m_ptr();}
};
#endif