Skip to content

Commit a8438a1

Browse files
committed
Use std::is_assignable for enabling shape conversions (fixes #20).
1 parent a4a53f6 commit a8438a1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

array.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,11 @@ class shape {
791791
private:
792792
dims_type dims_;
793793

794-
// TODO: This should use std::is_constructible<dims_type, std::tuple<OtherDims...>>
795-
// but it is broken on some compilers (https://github.com/dsharlet/array/issues/20).
794+
// This uses std::is_assignable because std::is_constructible is broken
795+
// on some C++ STLs (https://github.com/dsharlet/array/issues/20).
796796
template <class... OtherDims>
797-
using enable_if_dims_compatible = typename std::enable_if<sizeof...(OtherDims) == rank()>::type;
797+
using enable_if_dims_compatible = typename std::enable_if<
798+
std::is_assignable<dims_type, std::tuple<OtherDims...>>::value>::type;
798799

799800
template <class... Args>
800801
using enable_if_same_rank = typename std::enable_if<(sizeof...(Args) == rank())>::type;

test/errors.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ void shape_shape_too_many_dims() {
7070
shape<dim<>> s2(0, 1);
7171
}
7272

73-
// TODO: This builds due to https://github.com/dsharlet/array/issues/20
74-
//void shape_shape_incompatible() {
75-
// shape<dim<dynamic, dynamic, 4>> s2;
76-
// shape<dense_dim<>> s3(s2);
77-
//}
73+
void shape_shape_incompatible() {
74+
shape<dim<1, 2, 3>> s2;
75+
shape<dim<4, 5, 6>> s3(s2);
76+
}
7877

7978
void shape_at_too_many_indices() {
8079
s(0, 1, 2);

0 commit comments

Comments
 (0)