3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-25 13:53:40 +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
#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/slice.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_view<ValueType,Rank,Opt,TraversalOrder> 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
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_view<ValueType,Rank,Opt,TraversalOrder> view_type;
typedef array_view<ValueType,Rank,Opt,TraversalOrder,true> weak_view_type;
typedef void has_view_type_tag;
/// Empty array.
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_view<ValueType,Opt,TraversalOrder> 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::storage_type storage_type;
@ -116,7 +115,6 @@ namespace triqs { namespace arrays {
typedef matrix <ValueType,Opt,TraversalOrder> regular_type;
typedef matrix_view<ValueType,Opt,TraversalOrder> view_type;
typedef matrix_view<ValueType,Opt,TraversalOrder,true> weak_view_type;
typedef void has_view_type_tag;
/// Empty matrix.
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_view<ValueType,Opt,false> 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::storage_type storage_type;
@ -110,7 +109,6 @@ namespace triqs { namespace arrays {
typedef vector <ValueType,Opt> regular_type;
typedef vector_view<ValueType,Opt> view_type;
typedef vector_view<ValueType,Opt,true> weak_view_type;
typedef void has_view_type_tag;
/// Empty vector.
vector(){}

View File

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

View File

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

View File

@ -35,7 +35,6 @@ namespace triqs {
friend class value_view<T,false>;
public:
typedef void has_view_type_tag; // Idiom : ValueView
typedef value_view<T,true> view_type;
typedef value_view<T,false> regular_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;
friend class value_view<T,true>;
public:
typedef void has_view_type_tag; // Idiom : ValueView
typedef value_view<T,true> view_type;
typedef value_view<T,false> regular_type;
typedef typename std::remove_cv<typename std::remove_reference <T>::type >::type value_type;

View File

@ -24,10 +24,6 @@
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, 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 {};
@ -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> 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<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 ...
template <class T> struct add_views : std::binary_function <T,T,T> {
T operator() (const T& x, const T& y) const
{ typename T::regular_type r(x); r =r + y; return r;}
T operator() (const T& x, const T& y) const
{ typename T::regular_type r(x); r =r + y; return r;}
};
*/
}//namespace triqs
#endif