@@ -89,10 +89,38 @@ class any {
89 using map = std::vector<std::pair<const char * const, const any>>;
89 using map = std::vector<std::pair<const char * const, const any>>;
90 using vector = std::vector<any>;
90 using vector = std::vector<any>;
91 using fn = auto (*)(const any&) -> any;
91 using fn = auto (*)(const any&) -> any;
92− using closure = std::function<any(const any&)>;
93− using eff_fn = std::function<any()>;
94 using thunk = auto (*)(const as_thunk) -> const any&;
92 using thunk = auto (*)(const as_thunk) -> const any&;
96+ virtual any operator()(const any&) = 0;
99+ template <typename T>
100+ class _closure : public closure {
103+ _closure(const T& l) noexcept : lambda(l) {}
104+ any operator()(const any& arg) {
111+ virtual any operator()() = 0;
114+ template <typename T>
115+ class _eff_fn : public eff_fn {
118+ _eff_fn(const T& l) noexcept : lambda(l) {}
96 template <typename T>
124 template <typename T>
97 using shared = std::shared_ptr<T>;
125 using shared = std::shared_ptr<T>;
@@ -151,12 +179,12 @@ class any {
152 template <typename T, typename = typename std::enable_if<!std::is_same<any,T>::value &&
180 template <typename T, typename = typename std::enable_if<!std::is_same<any,T>::value &&
153 !std::is_convertible<T,fn>::value>::type>
181 !std::is_convertible<T,fn>::value>::type>
154− any(const T& val, typename std::enable_if<std::is_assignable<closure,T>::value>::type* = 0)
182+ any(const T& val, typename std::enable_if<std::is_assignable<std::function<any(const any&)>,T>::value>::type* = 0)
155− : type(Type::Closure), l(make_shared<closure>(val)) {}
183+ : type(Type::Closure), l(make_shared<_closure<T>>(val)) {}
157 template <typename T>
185 template <typename T>
158− any(const T& val, typename std::enable_if<std::is_assignable<eff_fn,T>::value>::type* = 0)
186+ any(const T& val, typename std::enable_if<std::is_assignable<std::function<any()>,T>::value>::type* = 0)
159− : type(Type::EffFunction), e(make_shared<eff_fn>(val)) {}
187+ : type(Type::EffFunction), e(make_shared<_eff_fn<T>>(val)) {}
161 template <typename T>
189 template <typename T>
162 any(const T& val, typename std::enable_if<std::is_convertible<T,thunk>::value>::type* = 0)
190 any(const T& val, typename std::enable_if<std::is_convertible<T,thunk>::value>::type* = 0)