diff --git a/deps/src/cxx_wrap/containers/const_array.hpp b/deps/src/cxx_wrap/containers/const_array.hpp index 040efdd..7b178fb 100644 --- a/deps/src/cxx_wrap/containers/const_array.hpp +++ b/deps/src/cxx_wrap/containers/const_array.hpp @@ -8,13 +8,36 @@ namespace cxx_wrap { +namespace detail +{ + template + struct IndexTChooser + { + }; + + template<> + struct IndexTChooser<4> + { + typedef int32_t type; + }; + + template<> + struct IndexTChooser<8> + { + typedef int64_t type; + }; + +} + +typedef typename detail::IndexTChooser::type index_t; + namespace detail { // Helper to make a C++ tuple of longs based on the number of elements - template + template struct LongNTuple { - typedef typename LongNTuple::type type; + typedef typename LongNTuple::type type; }; template @@ -51,7 +74,7 @@ struct InstantiateParametricType> /// Wrap a pointer, providing the Julia array interface for it /// The parameter N represents the number of dimensions -template +template class ConstArray { public: @@ -90,9 +113,9 @@ ConstArray make_const_array(const T* p, const SizesT... si return ConstArray(p, sizes...); } -template struct IsImmutable> : std::true_type {}; +template struct IsImmutable> : std::true_type {}; -template +template struct ConvertToJulia, false, true, false> { jl_value_t* operator()(const ConstArray& arr) @@ -109,7 +132,7 @@ struct ConvertToJulia, false, true, false> } }; -template +template struct InstantiateParametricType> { int operator()(Module& m) const diff --git a/deps/src/cxx_wrap/containers/containers.cpp b/deps/src/cxx_wrap/containers/containers.cpp index 34f4070..e9d058b 100644 --- a/deps/src/cxx_wrap/containers/containers.cpp +++ b/deps/src/cxx_wrap/containers/containers.cpp @@ -29,7 +29,7 @@ struct static_type_mapping>> RegisterHook const_array_reg([]() { Module m("CxxWrap"); g_constptr_dt = m.add_bits>>("ConstPtr").dt(); - m.add_immutable, TypeVar<2>>>("ConstArray", FieldList>, NTuple, long>>("ptr", "size"), julia_type("CppArray")); + m.add_immutable, TypeVar<2>>>("ConstArray", FieldList>, NTuple, index_t>>("ptr", "size"), julia_type("CppArray")); m.bind_types(g_cxx_wrap_module); });