@@ -468,7 +468,6 @@ template <class Fn, class Args, size_t... Is>
468
468
NDARRAY_INLINE auto apply (Fn&& fn, const Args& args, index_sequence<Is...>) {
469
469
return fn (std::get<Is>(args)...);
470
470
}
471
-
472
471
template <class Fn , class ... Args>
473
472
NDARRAY_INLINE auto apply (Fn&& fn, const std::tuple<Args...>& args) {
474
473
return apply (fn, args, make_index_sequence<sizeof ...(Args)>());
@@ -774,31 +773,31 @@ shape<Dims...> make_shape_from_tuple(const std::tuple<Dims...>& dims) {
774
773
* 'outermost' dimension. */
775
774
template <class ... Dims>
776
775
class shape {
777
- std::tuple<Dims...> dims_;
778
-
779
776
public:
777
+ /* * The type of the dims tuple of this shape. */
778
+ using dims_type = std::tuple<Dims...>;
779
+
780
780
/* * Number of dims in this shape. */
781
- static constexpr size_t rank () { return std::tuple_size<std::tuple<Dims...> >::value; }
781
+ static constexpr size_t rank () { return std::tuple_size<dims_type >::value; }
782
782
783
783
/* * A shape is scalar if it is rank 0. */
784
784
static constexpr bool is_scalar () { return rank () == 0 ; }
785
785
786
786
/* * The type of an index for this shape. */
787
787
using index_type = typename internal::tuple_of_n<index_t , rank()>::type;
788
788
789
- /* * The type of the dims tuple of this shape. */
790
- using dims_type = std::tuple<Dims...>;
791
-
792
789
using size_type = size_t ;
793
790
794
791
private:
795
- // TODO: This should use std::is_constructible<std::tuple<Dims...>, std::tuple<OtherDims...>>
792
+ dims_type dims_;
793
+
794
+ // TODO: This should use std::is_constructible<dims_type, std::tuple<OtherDims...>>
796
795
// but it is broken on some compilers (https://github.com/dsharlet/array/issues/20).
797
796
template <class ... OtherDims>
798
797
using enable_if_dims_compatible = typename std::enable_if<sizeof ...(OtherDims) == rank()>::type;
799
798
800
799
template <class ... Args>
801
- using enable_if_same_rank = typename std::enable_if<sizeof ...(Args) == rank()>::type;
800
+ using enable_if_same_rank = typename std::enable_if<( sizeof ...(Args) == rank() )>::type;
802
801
803
802
template <class ... Args>
804
803
using enable_if_indices =
@@ -810,7 +809,7 @@ class shape {
810
809
!internal::all_of_type<index_t , Args...>::value>::type;
811
810
812
811
template <size_t Dim>
813
- using enable_if_dim = typename std::enable_if<Dim < rank()>::type;
812
+ using enable_if_dim = typename std::enable_if<( Dim < rank() )>::type;
814
813
815
814
public:
816
815
shape () {}
@@ -822,7 +821,7 @@ class shape {
822
821
shape (shape&&) = default ;
823
822
824
823
/* * Construct a shape from a tuple of `dims` of another type. */
825
- // We cannot have an std::tuple<Dims...> constructor because it will be
824
+ // We cannot have an dims_type constructor because it will be
826
825
// ambiguous with the Dims... constructor for 1D shapes.
827
826
template <class ... OtherDims, class = enable_if_dims_compatible<OtherDims...>>
828
827
shape (const std::tuple<OtherDims...>& dims) : dims_(dims) {}
@@ -909,8 +908,8 @@ class shape {
909
908
}
910
909
911
910
/* * Get a tuple of all of the dims of this shape. */
912
- std::tuple<Dims...> & dims () { return dims_; }
913
- const std::tuple<Dims...> & dims () const { return dims_; }
911
+ dims_type & dims () { return dims_; }
912
+ const dims_type & dims () const { return dims_; }
914
913
915
914
/* * Get an index pointing to the min or max index in each dimension of this
916
915
* shape. */
0 commit comments