add static own type function to range classes

This commit is contained in:
Christian Zimmermann 2017-03-30 14:41:57 +02:00
parent b050ea4466
commit 8c2ced598f
3 changed files with 19 additions and 4 deletions

View file

@ -710,14 +710,14 @@ namespace MultiArrayTools
template <class... Ranges> template <class... Ranges>
template <size_t N> template <size_t N>
auto MultiRange<Ranges...>::getRange() -> decltype( std::get<N>(MultiRange<Ranges...>::SpaceType()) ) typename std::tuple_element<N, std::tuple<Ranges...> >::type& MultiRange<Ranges...>::getRange()
{ {
return std::get<N>(mSpace); return std::get<N>(mSpace);
} }
template <class... Ranges> template <class... Ranges>
template <size_t N> template <size_t N>
auto MultiRange<Ranges...>::getRange() const -> decltype( std::get<N>(MultiRange<Ranges...>::SpaceType()) ) typename std::tuple_element<N, std::tuple<Ranges...> >::type const& MultiRange<Ranges...>::getRange() const
{ {
return std::get<N>(mSpace); return std::get<N>(mSpace);
} }

View file

@ -112,11 +112,13 @@ namespace MultiArrayTools
static const size_t dim = sizeof...(Ranges); static const size_t dim = sizeof...(Ranges);
template <size_t N> static MultiRange<Ranges...> oType() { return MultiRange<Ranges...>(); }
auto getRange() -> decltype( std::get<N>(SpaceType()) );
template <size_t N> template <size_t N>
auto getRange() const -> decltype( std::get<N>(SpaceType()) ); typename std::tuple_element<N, std::tuple<Ranges...> >::type& getRange();
template <size_t N>
typename std::tuple_element<N, std::tuple<Ranges...> >::type const& getRange() const;
size_t size() const override; size_t size() const override;
const SpaceType& space() const; const SpaceType& space() const;

View file

@ -71,6 +71,8 @@ namespace MultiArrayTools
SingleRange(const std::vector<U>& space); SingleRange(const std::vector<U>& space);
static SingleRange<U,TYPE> oType() { return SingleRange<U,TYPE>(); }
virtual size_t size() const override; virtual size_t size() const override;
//U get(size_t pos) const; //U get(size_t pos) const;
@ -98,6 +100,8 @@ namespace MultiArrayTools
SingleRange(size_t ext); SingleRange(size_t ext);
static SingleRange<int,RangeType::SPACE> oType() { return SingleRange<int,RangeType::SPACE>(); }
virtual size_t size() const override; virtual size_t size() const override;
int get(size_t pos) const; int get(size_t pos) const;
@ -122,6 +126,8 @@ namespace MultiArrayTools
SingleRange(size_t ext); SingleRange(size_t ext);
static SingleRange<size_t,RangeType::DISTANCE> oType() { return SingleRange<size_t,RangeType::DISTANCE>(); }
virtual size_t size() const override; virtual size_t size() const override;
size_t get(size_t pos) const; size_t get(size_t pos) const;
@ -146,6 +152,8 @@ namespace MultiArrayTools
SingleRange(size_t num); SingleRange(size_t num);
static SingleRange<size_t,RangeType::ENSEMBLE> oType() { return SingleRange<size_t,RangeType::ENSEMBLE>(); }
virtual size_t size() const override; virtual size_t size() const override;
size_t get(size_t pos) const; size_t get(size_t pos) const;
@ -176,6 +184,9 @@ namespace MultiArrayTools
DEFAULT_MEMBERS(SingleRange); DEFAULT_MEMBERS(SingleRange);
static SingleRange<VET,RangeType::VALUE_ERROR> oType()
{ return SingleRange<VET,RangeType::VALUE_ERROR>(); }
virtual size_t size() const override; virtual size_t size() const override;
VET get(size_t pos) const; VET get(size_t pos) const;
@ -195,6 +206,8 @@ namespace MultiArrayTools
DEFAULT_MEMBERS(SingleRange); DEFAULT_MEMBERS(SingleRange);
static SingleRange<size_t,RangeType::LORENTZ> oType() { return SingleRange<size_t,RangeType::LORENTZ>(); }
virtual size_t size() const override; virtual size_t size() const override;
size_t get(size_t pos) const; size_t get(size_t pos) const;