3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 06:14:14 +01:00

clef: further little corrections

- declaration order in template.
- some eval details
- do not undef the macro TRIQS_CLEF_STD_MATH_FNT_TO_MAKE_LAZY
for reuse in other part of the lib
This commit is contained in:
Olivier Parcollet 2014-02-09 21:04:26 +01:00
parent 7e1f2eb34b
commit 786bd7095e
3 changed files with 11 additions and 4 deletions

View File

@ -33,7 +33,7 @@ namespace triqs { namespace clef {
#define AUX(r, data, elem) TRIQS_CLEF_MAKE_STD_FNT_LAZY(elem) #define AUX(r, data, elem) TRIQS_CLEF_MAKE_STD_FNT_LAZY(elem)
BOOST_PP_SEQ_FOR_EACH(AUX , nil , TRIQS_CLEF_STD_MATH_FNT_TO_MAKE_LAZY); BOOST_PP_SEQ_FOR_EACH(AUX , nil , TRIQS_CLEF_STD_MATH_FNT_TO_MAKE_LAZY);
#undef AUX #undef AUX
#undef TRIQS_CLEF_STD_MATH_FNT_TO_MAKE_LAZY //#undef TRIQS_CLEF_STD_MATH_FNT_TO_MAKE_LAZY
}} }}

View File

@ -134,6 +134,8 @@ namespace triqs { namespace clef {
// if we want that subexpression are copied ? // if we want that subexpression are copied ?
template<typename Tag, typename... T> struct force_copy_in_expr< expr<Tag,T... > > : std::true_type{}; template<typename Tag, typename... T> struct force_copy_in_expr< expr<Tag,T... > > : std::true_type{};
template <typename Tag, typename... T> using expr_node_t = expr<Tag, expr_storage_t<T>...>;
/* --------------------------------------------------------------------------------------------------- /* ---------------------------------------------------------------------------------------------------
* The basic operations put in a template.... * The basic operations put in a template....
* --------------------------------------------------------------------------------------------------- */ * --------------------------------------------------------------------------------------------------- */
@ -233,6 +235,10 @@ namespace triqs { namespace clef {
T const & operator()(T const& k, Pairs const&... pairs) const { return k; } T const & operator()(T const& k, Pairs const&... pairs) const { return k; }
}; };
// The general eval function for expressions : declaration only
template<typename T, typename... Pairs>
auto eval (T const & ex, Pairs const &... pairs) ->decltype( evaluator<T, Pairs...>()(ex, pairs...));
// placeholder // placeholder
template <int N, int i, typename T, typename... Pairs> struct evaluator<placeholder<N>, pair<i, T>, Pairs...> { template <int N, int i, typename T, typename... Pairs> struct evaluator<placeholder<N>, pair<i, T>, Pairs...> {
using eval_t = evaluator<placeholder<N>, Pairs...>; using eval_t = evaluator<placeholder<N>, Pairs...>;
@ -248,9 +254,9 @@ namespace triqs { namespace clef {
// any object hold by reference wrapper is redirected to the evaluator of the object // any object hold by reference wrapper is redirected to the evaluator of the object
template <typename T, typename... Contexts> struct evaluator<std::reference_wrapper<T>, Contexts...> { template <typename T, typename... Contexts> struct evaluator<std::reference_wrapper<T>, Contexts...> {
using ev_t = evaluator<T, Contexts...>; //using ev_t = evaluator<T, Contexts...>;
static constexpr bool is_lazy = ev_t::is_lazy; static constexpr bool is_lazy = false;//ev_t::is_lazy;
auto operator()(std::reference_wrapper<T> const& x, Contexts const&... contexts) const DECL_AND_RETURN(ev_t {}(x.get(), contexts...)); auto operator()(std::reference_wrapper<T> const& x, Contexts const&... contexts) const DECL_AND_RETURN(eval(x.get(), contexts...));
}; };
// dispatching the evaluation : if lazy, we make a new clef expression, if not we call the operation // dispatching the evaluation : if lazy, we make a new clef expression, if not we call the operation

View File

@ -35,6 +35,7 @@ namespace std {
template <class T> using remove_reference_t = typename remove_reference<T>::type; template <class T> using remove_reference_t = typename remove_reference<T>::type;
template <class T> using add_const_t = typename add_const<T>::type; template <class T> using add_const_t = typename add_const<T>::type;
template <class T> using remove_const_t = typename remove_const<T>::type; template <class T> using remove_const_t = typename remove_const<T>::type;
template <bool B, class T = void> using enable_if_t = typename enable_if<B, T>::type;
// use simply std::c14::plus<>() ... // use simply std::c14::plus<>() ...
template<typename T = void> struct plus: std::plus<T>{}; template<typename T = void> struct plus: std::plus<T>{};