mgcpp
A C++ Math Library Based on CUDA
shape.hpp
Go to the documentation of this file.
1 
2 #ifndef _MGCPP_GLOBAL_SHAPE_HPP_
3 #define _MGCPP_GLOBAL_SHAPE_HPP_
4 
5 #include <tuple>
6 #include <type_traits>
7 
8 namespace mgcpp {
9 template <size_t Dims>
10 struct shape {
11  size_t dims[Dims];
12 
14 
15  shape();
16  shape(std::initializer_list<size_t> list);
17  shape(shape const&) = default;
18  shape& operator=(shape const&) = default;
19 
20  size_t operator[](size_t idx) const;
21  size_t& operator[](size_t idx);
22  bool operator==(shape const& rhs) const;
23  bool operator!=(shape const& rhs) const;
24 
25  template <std::size_t N>
26  size_t get() const;
27 };
28 
29 template <typename... Types>
30 shape<sizeof...(Types)> make_shape(Types... args);
31 } // namespace mgcpp
32 
33 namespace std {
34 template <size_t Dims>
35 class tuple_size<mgcpp::shape<Dims>>
36  : std::integral_constant<std::size_t, Dims> {};
37 
38 template <std::size_t N, size_t Dims>
39 struct tuple_element<N, mgcpp::shape<Dims>> {
40  using type = std::size_t;
41 };
42 } // namespace std
43 
44 #include <mgcpp/global/shape.tpp>
45 
46 #endif
size_t dims[Dims]
Definition: shape.hpp:11
Definition: adapter_base.hpp:12
shape & operator=(shape const &)=default
Definition: shape.hpp:33
size_t operator[](size_t idx) const
Definition: shape.hpp:10
std::size_t type
Definition: shape.hpp:40
shape< sizeof...(Types)> make_shape(Types... args)
bool operator==(shape const &rhs) const
bool operator!=(shape const &rhs) const