diff --git a/triqs/arrays/impl/indexmap_storage_pair.hpp b/triqs/arrays/impl/indexmap_storage_pair.hpp index 0cc80e98..5bc3c7a2 100644 --- a/triqs/arrays/impl/indexmap_storage_pair.hpp +++ b/triqs/arrays/impl/indexmap_storage_pair.hpp @@ -260,7 +260,24 @@ namespace triqs { namespace arrays { return make_expr_call(std::move(*this),args...); } - template friend void triqs_clef_auto_assign (indexmap_storage_pair & x, Fnt f) { assign_foreach(x,f);} + // ------------------------------- clef auto assign -------------------------------------------- + + // For simple cases, it is assign_foreach. But when f(args...) is a function from a clef expression + // we make a chain call like cf clef vector adapter + template struct _worker { + indexmap_storage_pair &A; + Function const &f; + template void assign(T &x, RHS &&rhs) { x = std::forward(rhs); } + template void assign(T &x, clef::make_fun_impl &&rhs) { + triqs_clef_auto_assign(x, std::forward>(rhs)); + } + template void operator()(Args const &... args) { this->assign(A(args...), f(args...)); } + }; + + template friend void triqs_clef_auto_assign(indexmap_storage_pair &x, Fnt f) { + foreach(x, _worker{x, f}); + } + // template friend void triqs_clef_auto_assign (indexmap_storage_pair & x, Fnt f) { assign_foreach(x,f);} // ------------------------------- Iterators -------------------------------------------- typedef iterator_adapter const_iterator; diff --git a/triqs/gfs/gf.hpp b/triqs/gfs/gf.hpp index a995f222..9545524a 100644 --- a/triqs/gfs/gf.hpp +++ b/triqs/gfs/gf.hpp @@ -431,6 +431,15 @@ namespace gfs { } }; + // in most expression, the gf_impl version is enough. + // But in chained clef expression, A(i_)(om_) where A is an array of gf + // we need to call it with the gf, not gf_impl (or the template resolution find the deleted funciton in clef). + // Another fix is to make gf, gf_view in the expression tree, but this requires using CRPT in gf_impl... + template + void triqs_clef_auto_assign(gf &g, RHS const &rhs) { + triqs_clef_auto_assign( static_cast&>(g), rhs); + } + // --------------------------The const View class of GF ------------------------------------------------------- template