/******************************************************************************* * * TRIQS: a Toolbox for Research in Interacting Quantum Systems * * Copyright (C) 2011 by O. Parcollet * * TRIQS is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * TRIQS. If not, see . * ******************************************************************************/ #ifndef TRIQS_UTILITY_VIEWTOOLS_H #define TRIQS_UTILITY_VIEWTOOLS_H #include namespace triqs { // keep old solution for a while to check portability and then remove tag #define TRIQS_DETECT_VIEWS #ifdef TRIQS_DETECT_VIEWS template void nop(T ...){}; template struct has_view : std::false_type {}; template struct has_view(),std::declval()))> : std::true_type {}; template::value> struct regular_type_if_exists_else_type; template struct regular_type_if_exists_else_type {typedef T type;}; template struct regular_type_if_exists_else_type {typedef typename T::regular_type type;}; template::value> struct view_type_if_exists_else_type; template struct view_type_if_exists_else_type {typedef T type;}; template struct view_type_if_exists_else_type {typedef typename T::view_type type;}; template::value> struct const_view_type_if_exists_else_type; template struct const_view_type_if_exists_else_type {typedef T type;}; template struct const_view_type_if_exists_else_type {typedef const typename T::view_type type;}; // template struct const_view_type_if_exists_else_type {typedef const typename T::view_type type;}; #else template struct regular_type_if_exists_else_type {typedef T type;}; template struct regular_type_if_exists_else_type {typedef typename T::regular_type type;}; template struct view_type_if_exists_else_type {typedef T type;}; template struct view_type_if_exists_else_type {typedef typename T::view_type type;}; template struct const_view_type_if_exists_else_type {typedef T type;}; template struct const_view_type_if_exists_else_type {typedef const typename T::view_type type;}; // template struct const_view_type_if_exists_else_type {typedef const typename T::view_type type;}; #endif // replacement of std::plus for views ... template struct add_views : std::binary_function { T operator() (const T& x, const T& y) const { typename T::regular_type r(x); r =r + y; return r;} }; }//namespace triqs #endif