Skip to content

Commit dc1378f

Browse files
committed
making adapt work with const_array.
1 parent 299be1d commit dc1378f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

include/xtensor/xadapt.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ namespace xt
3535
static constexpr std::size_t value = N;
3636
};
3737

38+
template <class T, std::size_t N>
39+
struct array_size_impl<const_array<T, N>>
40+
{
41+
static constexpr std::size_t value = N;
42+
};
43+
3844
template <class C>
3945
using array_size = array_size_impl<std::decay_t<C>>;
4046

include/xtensor/xcontainer.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ namespace xt
5252
{
5353
using type = std::allocator<T>; // fake allocator for testing
5454
};
55+
56+
57+
template <class T, std::size_t N>
58+
struct allocator_type_impl<const_array<T, N>>
59+
{
60+
using type = std::allocator<T>; // fake allocator for testing
61+
};
62+
5563
}
5664

5765
template <class T>

include/xtensor/xshape.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ namespace xt
351351
{
352352
static constexpr bool value = true;
353353
};
354+
355+
template <class T, std::size_t N>
356+
struct is_array<const_array<T, N>>
357+
{
358+
static constexpr bool value = true;
359+
};
354360

355361
template <class S>
356362
struct is_fixed : std::false_type

0 commit comments

Comments
 (0)