-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from andreasfertig/fixIssue205
Fixed #205: Make lambdas as in class initializer work.
- Loading branch information
Showing
8 changed files
with
271 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <functional> | ||
#include <iostream> | ||
class EventContainer { | ||
private: | ||
int val = 1234; | ||
std::function<void()> something = [=]() { | ||
std::cout << this->val; | ||
}; | ||
}; | ||
|
||
int main() { | ||
// get the default constructor generated. | ||
EventContainer e; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <functional> | ||
#include <iostream> | ||
class EventContainer | ||
{ | ||
|
||
private: | ||
int val; | ||
std::function<void ()> something; | ||
public: | ||
// inline EventContainer(const EventContainer &) = default; | ||
// inline EventContainer(EventContainer &&) = default; | ||
// inline EventContainer & operator=(EventContainer &&) = default; | ||
// inline ~EventContainer() noexcept = default; | ||
|
||
public: | ||
|
||
class __lambda_6_43 | ||
{ | ||
EventContainer * __this; | ||
public: | ||
inline /*constexpr */ void operator()() const | ||
{ | ||
std::cout.operator<<(__this->val); | ||
} | ||
|
||
// inline /*constexpr */ __lambda_6_43 & operator=(const __lambda_6_43 &) = default; | ||
// inline /*constexpr */ __lambda_6_43(const __lambda_6_43 &) noexcept = default; | ||
// inline /*constexpr */ __lambda_6_43(__lambda_6_43 &&) noexcept = default; | ||
public: __lambda_6_43(EventContainer * _this) | ||
: __this{_this} | ||
|
||
{} | ||
|
||
} __lambda_6_43{this}; | ||
|
||
// inline constexpr EventContainer() noexcept(false) = default; | ||
}; | ||
|
||
|
||
|
||
int main() | ||
{ | ||
EventContainer e = EventContainer(); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <functional> | ||
#include <iostream> | ||
class EventContainer { | ||
private: | ||
int val = 1234; | ||
std::function<void()> something = [=]() { | ||
std::cout << this->val; | ||
}; | ||
|
||
public: | ||
EventContainer() : val{1235}{} | ||
}; | ||
|
||
int main() { | ||
// get the default constructor generated. | ||
EventContainer e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <functional> | ||
#include <iostream> | ||
class EventContainer | ||
{ | ||
|
||
private: | ||
int val; | ||
std::function<void ()> something; | ||
|
||
public: | ||
|
||
class __lambda_6_43 | ||
{ | ||
EventContainer * __this; | ||
public: | ||
inline /*constexpr */ void operator()() const | ||
{ | ||
std::cout.operator<<(__this->val); | ||
} | ||
|
||
// inline /*constexpr */ __lambda_6_43 & operator=(const __lambda_6_43 &) = default; | ||
// inline /*constexpr */ __lambda_6_43(const __lambda_6_43 &) noexcept = default; | ||
// inline /*constexpr */ __lambda_6_43(__lambda_6_43 &&) noexcept = default; | ||
public: __lambda_6_43(EventContainer * _this) | ||
: __this{_this} | ||
|
||
{} | ||
|
||
} __lambda_6_43{this}; | ||
|
||
inline EventContainer() | ||
: val{1235} | ||
, something{std::function<void ()>(__lambda_6_43)} | ||
{ | ||
} | ||
|
||
// inline EventContainer(const EventContainer &) = default; | ||
// inline EventContainer(EventContainer &&) = default; | ||
// inline EventContainer & operator=(EventContainer &&) = default; | ||
// inline ~EventContainer() noexcept = default; | ||
|
||
}; | ||
|
||
|
||
|
||
int main() | ||
{ | ||
EventContainer e = EventContainer(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// std::function mock up | ||
template<typename ReturnValue, typename... Args> | ||
class function | ||
{ | ||
public: | ||
function() = default; | ||
|
||
template<typename T> | ||
function(T&& f) | ||
{} | ||
}; | ||
|
||
// part of #205 | ||
class EventContainer { | ||
private: | ||
int val = 1234; | ||
function<void()> something = [=]() { | ||
this->val; | ||
}; | ||
}; | ||
|
||
int main() { | ||
// get the default constructor generated. | ||
EventContainer e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// std::function mock up | ||
template<typename ReturnValue, typename... Args> | ||
class function | ||
{ | ||
public: | ||
function() = default; | ||
|
||
template<typename T> | ||
function(T&& f) | ||
{} | ||
}; | ||
|
||
/* First instantiated from: LambdaAndInClassInitializerTest.cpp:17 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
class function<void ()> | ||
{ | ||
|
||
public: | ||
inline constexpr function() = default; | ||
template<typename T> | ||
inline function(T && f); | ||
|
||
|
||
/* First instantiated from: LambdaAndInClassInitializerTest.cpp:17 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
inline function<__lambda_17_38>(__lambda_17_38 && f) | ||
{ | ||
} | ||
#endif | ||
|
||
|
||
|
||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
inline function<const function<void ()> &>(function<void ()> & f); | ||
#endif | ||
|
||
|
||
|
||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
inline function<function<void ()> >(function<void ()> && f); | ||
#endif | ||
|
||
|
||
// inline constexpr function(const function<void ()> &) = default; | ||
// inline constexpr function(function<void ()> &&) = default; | ||
// inline ~function() noexcept = default; | ||
}; | ||
|
||
#endif | ||
|
||
|
||
// part of #205 | ||
class EventContainer | ||
{ | ||
|
||
private: | ||
int val; | ||
function<void ()> something; | ||
|
||
public: | ||
|
||
class __lambda_17_38 | ||
{ | ||
EventContainer * __this; | ||
public: | ||
inline /*constexpr */ void operator()() const | ||
{ | ||
__this->val; | ||
} | ||
|
||
public: __lambda_17_38(EventContainer * _this) | ||
: __this{_this} | ||
|
||
{} | ||
|
||
} __lambda_17_38{this}; | ||
|
||
// inline constexpr EventContainer() noexcept(false) = default; | ||
// inline constexpr EventContainer(const EventContainer &) = default; | ||
// inline constexpr EventContainer(EventContainer &&) = default; | ||
}; | ||
|
||
|
||
|
||
int main() | ||
{ | ||
EventContainer e = EventContainer(); | ||
} | ||
|