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

arrays: rm has_view_type_tag & add_views

- has_view_type_tag mechanism was replaced by a decltype long ago.
Cleaning since it seems to work on all supported compiler now.

- removed add_views : not used any more.
This commit is contained in:
Olivier Parcollet 2013-08-21 16:17:51 +02:00
parent 41bc8d0338
commit 17a741ad9e
7 changed files with 5 additions and 33 deletions

View File

@ -20,7 +20,7 @@
******************************************************************************/ ******************************************************************************/
#ifndef TRIQS_ARRAYS_ARRAY_H #ifndef TRIQS_ARRAYS_ARRAY_H
#define TRIQS_ARRAYS_ARRAY_H #define TRIQS_ARRAYS_ARRAY_H
#include<triqs/utility/first_include.hpp> #include <triqs/utility/first_include.hpp>
#include "indexmaps/cuboid/map.hpp" #include "indexmaps/cuboid/map.hpp"
#include "indexmaps/cuboid/slice.hpp" #include "indexmaps/cuboid/slice.hpp"
#include "impl/indexmap_storage_pair.hpp" #include "impl/indexmap_storage_pair.hpp"
@ -45,7 +45,6 @@ namespace triqs { namespace arrays {
typedef array <ValueType,Rank,Opt,TraversalOrder> regular_type; typedef array <ValueType,Rank,Opt,TraversalOrder> regular_type;
typedef array_view<ValueType,Rank,Opt,TraversalOrder> view_type; typedef array_view<ValueType,Rank,Opt,TraversalOrder> view_type;
typedef array_view<ValueType,Rank,Opt,TraversalOrder,true> weak_view_type; typedef array_view<ValueType,Rank,Opt,TraversalOrder,true> weak_view_type;
typedef void has_view_type_tag;
/// Build from an IndexMap and a storage /// Build from an IndexMap and a storage
template<typename S> array_view (indexmap_type const & Ind,S const & Mem): IMPL_TYPE(Ind, Mem) {} template<typename S> array_view (indexmap_type const & Ind,S const & Mem): IMPL_TYPE(Ind, Mem) {}
@ -101,7 +100,6 @@ namespace triqs { namespace arrays {
typedef array <ValueType,Rank,Opt,TraversalOrder> regular_type; typedef array <ValueType,Rank,Opt,TraversalOrder> regular_type;
typedef array_view<ValueType,Rank,Opt,TraversalOrder> view_type; typedef array_view<ValueType,Rank,Opt,TraversalOrder> view_type;
typedef array_view<ValueType,Rank,Opt,TraversalOrder,true> weak_view_type; typedef array_view<ValueType,Rank,Opt,TraversalOrder,true> weak_view_type;
typedef void has_view_type_tag;
/// Empty array. /// Empty array.
explicit array(memory_layout<Rank> ml = memory_layout<Rank>(IMPL_TYPE::indexmap_type::traversal_order)) :IMPL_TYPE(ml){} explicit array(memory_layout<Rank> ml = memory_layout<Rank>(IMPL_TYPE::indexmap_type::traversal_order)) :IMPL_TYPE(ml){}

View File

@ -54,7 +54,6 @@ namespace triqs { namespace arrays {
typedef matrix <ValueType,Opt,TraversalOrder> regular_type; typedef matrix <ValueType,Opt,TraversalOrder> regular_type;
typedef matrix_view<ValueType,Opt,TraversalOrder> view_type; typedef matrix_view<ValueType,Opt,TraversalOrder> view_type;
typedef matrix_view<ValueType,Opt,TraversalOrder,true> weak_view_type; typedef matrix_view<ValueType,Opt,TraversalOrder,true> weak_view_type;
typedef void has_view_type_tag;
typedef typename IMPL_TYPE::indexmap_type indexmap_type; typedef typename IMPL_TYPE::indexmap_type indexmap_type;
typedef typename IMPL_TYPE::storage_type storage_type; typedef typename IMPL_TYPE::storage_type storage_type;
@ -116,7 +115,6 @@ namespace triqs { namespace arrays {
typedef matrix <ValueType,Opt,TraversalOrder> regular_type; typedef matrix <ValueType,Opt,TraversalOrder> regular_type;
typedef matrix_view<ValueType,Opt,TraversalOrder> view_type; typedef matrix_view<ValueType,Opt,TraversalOrder> view_type;
typedef matrix_view<ValueType,Opt,TraversalOrder,true> weak_view_type; typedef matrix_view<ValueType,Opt,TraversalOrder,true> weak_view_type;
typedef void has_view_type_tag;
/// Empty matrix. /// Empty matrix.
matrix(memory_layout<2> ml = memory_layout<2>(IMPL_TYPE::indexmap_type::traversal_order) ): IMPL_TYPE(indexmap_type(ml)) {} matrix(memory_layout<2> ml = memory_layout<2>(IMPL_TYPE::indexmap_type::traversal_order) ): IMPL_TYPE(indexmap_type(ml)) {}

View File

@ -43,7 +43,6 @@ namespace triqs { namespace arrays {
typedef vector <ValueType,Opt> regular_type; typedef vector <ValueType,Opt> regular_type;
typedef vector_view<ValueType,Opt,false> view_type; typedef vector_view<ValueType,Opt,false> view_type;
typedef vector_view<ValueType,Opt,true> weak_view_type; typedef vector_view<ValueType,Opt,true> weak_view_type;
typedef void has_view_type_tag;
typedef typename IMPL_TYPE::indexmap_type indexmap_type; typedef typename IMPL_TYPE::indexmap_type indexmap_type;
typedef typename IMPL_TYPE::storage_type storage_type; typedef typename IMPL_TYPE::storage_type storage_type;
@ -110,7 +109,6 @@ namespace triqs { namespace arrays {
typedef vector <ValueType,Opt> regular_type; typedef vector <ValueType,Opt> regular_type;
typedef vector_view<ValueType,Opt> view_type; typedef vector_view<ValueType,Opt> view_type;
typedef vector_view<ValueType,Opt,true> weak_view_type; typedef vector_view<ValueType,Opt,true> weak_view_type;
typedef void has_view_type_tag;
/// Empty vector. /// Empty vector.
vector(){} vector(){}

View File

@ -50,7 +50,6 @@ namespace triqs { namespace gfs { namespace local {
/// A common implementation class. Idiom : ValueView /// A common implementation class. Idiom : ValueView
template<bool IsView> class tail_impl { template<bool IsView> class tail_impl {
public : public :
typedef void has_view_type_tag; // Idiom : ValueView
typedef tail_view view_type; typedef tail_view view_type;
typedef tail regular_type; typedef tail regular_type;

View File

@ -74,7 +74,6 @@ namespace triqs { namespace gfs {
struct nothing { struct nothing {
template<typename... Args> explicit nothing(Args...) {} // takes anything, do nothing.. template<typename... Args> explicit nothing(Args...) {} // takes anything, do nothing..
nothing() {} nothing() {}
typedef void has_view_type_tag; // Idiom : ValueView
typedef nothing view_type; typedef nothing view_type;
typedef nothing regular_type; typedef nothing regular_type;
void rebind (nothing){} void rebind (nothing){}

View File

@ -35,7 +35,6 @@ namespace triqs {
friend class value_view<T,false>; friend class value_view<T,false>;
public: public:
typedef void has_view_type_tag; // Idiom : ValueView
typedef value_view<T,true> view_type; typedef value_view<T,true> view_type;
typedef value_view<T,false> regular_type; typedef value_view<T,false> regular_type;
typedef typename std::remove_cv<typename std::remove_reference <T>::type >::type value_type; typedef typename std::remove_cv<typename std::remove_reference <T>::type >::type value_type;
@ -66,7 +65,6 @@ namespace triqs {
std::shared_ptr<T> p; std::shared_ptr<T> p;
friend class value_view<T,true>; friend class value_view<T,true>;
public: public:
typedef void has_view_type_tag; // Idiom : ValueView
typedef value_view<T,true> view_type; typedef value_view<T,true> view_type;
typedef value_view<T,false> regular_type; typedef value_view<T,false> regular_type;
typedef typename std::remove_cv<typename std::remove_reference <T>::type >::type value_type; typedef typename std::remove_cv<typename std::remove_reference <T>::type >::type value_type;

View File

@ -24,10 +24,6 @@
namespace triqs { namespace triqs {
// keep old solution for a while to check portability and then remove tag
#define TRIQS_DETECT_VIEWS
#ifdef TRIQS_DETECT_VIEWS
template<typename T> void nop(T ...){}; template<typename T> void nop(T ...){};
template<typename T, typename Enable=void> struct has_view : std::false_type {}; template<typename T, typename Enable=void> struct has_view : std::false_type {};
template<typename T> struct has_view<T, decltype(nop(std::declval<typename T::view_type>(),std::declval<typename T::regular_type>()))> : std::true_type {}; template<typename T> struct has_view<T, decltype(nop(std::declval<typename T::view_type>(),std::declval<typename T::regular_type>()))> : std::true_type {};
@ -43,28 +39,14 @@ namespace triqs {
template<typename T, bool HasView = has_view<T>::value> struct const_view_type_if_exists_else_type; template<typename T, bool HasView = has_view<T>::value> struct const_view_type_if_exists_else_type;
template<typename T> struct const_view_type_if_exists_else_type<T,false> {typedef T type;}; template<typename T> struct const_view_type_if_exists_else_type<T,false> {typedef T type;};
template<typename T> struct const_view_type_if_exists_else_type<T,true> {typedef const typename T::view_type type;}; template<typename T> struct const_view_type_if_exists_else_type<T,true> {typedef const typename T::view_type type;};
// template<typename T> struct const_view_type_if_exists_else_type<const T, typename T::has_view_type_tag> {typedef const typename T::view_type type;};
#else
template<typename T, typename Void =void> struct regular_type_if_exists_else_type {typedef T type;};
template<typename T> struct regular_type_if_exists_else_type<T, typename T::has_view_type_tag> {typedef typename T::regular_type type;};
template<typename T, typename Void =void> struct view_type_if_exists_else_type {typedef T type;};
template<typename T> struct view_type_if_exists_else_type<T, typename T::has_view_type_tag> {typedef typename T::view_type type;};
template<typename T, typename Void =void> struct const_view_type_if_exists_else_type {typedef T type;};
template<typename T> struct const_view_type_if_exists_else_type<T, typename T::has_view_type_tag> {typedef const typename T::view_type type;};
// template<typename T> struct const_view_type_if_exists_else_type<const T, typename T::has_view_type_tag> {typedef const typename T::view_type type;};
#endif
/*
// replacement of std::plus for views ... // replacement of std::plus for views ...
template <class T> struct add_views : std::binary_function <T,T,T> { template <class T> struct add_views : std::binary_function <T,T,T> {
T operator() (const T& x, const T& y) const T operator() (const T& x, const T& y) const
{ typename T::regular_type r(x); r =r + y; return r;} { typename T::regular_type r(x); r =r + y; return r;}
}; };
*/
}//namespace triqs }//namespace triqs
#endif #endif