Changeset View
Changeset View
Standalone View
Standalone View
src/utils/lazy_val.h
Show All 32 Lines | 28 | public: | |||
---|---|---|---|---|---|
33 | } | 33 | } | ||
34 | 34 | | |||
35 | private: | 35 | private: | ||
36 | F _f; | 36 | F _f; | ||
37 | mutable decltype(_f()) value; | 37 | mutable decltype(_f()) value; | ||
38 | mutable bool valueRetrieved; | 38 | mutable bool valueRetrieved; | ||
39 | 39 | | |||
40 | public: | 40 | public: | ||
41 | operator decltype(_f()) () const | 41 | operator auto() const -> decltype(_f()) | ||
vonreth: Hm recently found out that this code doesn't compile with gcc..... | |||||
42 | { | 42 | { | ||
43 | if (!valueRetrieved) { | 43 | if (!valueRetrieved) { | ||
44 | valueRetrieved = true; | 44 | valueRetrieved = true; | ||
45 | value = _f(); | 45 | value = _f(); | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | return value; | 48 | return value; | ||
49 | } | 49 | } | ||
Show All 13 Lines |
Hm recently found out that this code doesn't compile with gcc.....