mirror of
https://github.com/boostorg/multi_array.git
synced 2025-05-11 21:33:52 +00:00
Checkpoint: I will dance on MSVC 6's grave when it is finally buried
once and for all. It once again seems to be passing all regression tests. Some extra code will have to be removed now. [SVN r23855]
This commit is contained in:
parent
847bce350b
commit
0bba905b99
@ -26,6 +26,7 @@
|
||||
#include "boost/multi_array/multi_array_ref.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/mpl/if.hpp"
|
||||
#include "boost/type_traits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@ -47,6 +48,74 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
//
|
||||
// Compilers that don't support partial ordering may need help to
|
||||
// disambiguate multi_array's templated constructors. Even vc6/7 are
|
||||
// capable of some limited SFINAE, so we take the most-general version
|
||||
// out of the overload set with disable_multi_array_impl.
|
||||
//
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
char is_multi_array_impl_help(const_multi_array_view<T,NumDims,TPtr>&);
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
char is_multi_array_impl_help(const_sub_array<T,NumDims,TPtr>&);
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
char is_multi_array_impl_help(const_multi_array_ref<T,NumDims,TPtr>&);
|
||||
|
||||
char ( &is_multi_array_impl_help(...) )[2];
|
||||
|
||||
template <class T>
|
||||
struct is_multi_array_impl
|
||||
{
|
||||
static T x;
|
||||
BOOST_STATIC_CONSTANT(bool, value = sizeof((is_multi_array_impl_help)(x)) == 1);
|
||||
// typedef mpl::bool_< ( sizeof((is_multi_array_impl_help)(x)) == 1 ) > type;
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
|
||||
template <bool multi_array = false>
|
||||
struct disable_multi_array_impl_impl
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct disable_multi_array_impl_impl<true>
|
||||
{
|
||||
// forming a pointer to a reference triggers SFINAE
|
||||
typedef int& type;
|
||||
};
|
||||
|
||||
#if 0
|
||||
template <class T>
|
||||
struct disable_multi_array_impl
|
||||
{
|
||||
typedef typename disable_multi_array_impl_impl<is_multi_array_impl<T>::value>::type type;
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
|
||||
template <class T>
|
||||
struct disable_multi_array_impl :
|
||||
disable_multi_array_impl_impl<is_multi_array_impl<T>::value>
|
||||
{
|
||||
typedef disable_multi_array_impl_impl<is_multi_array_impl<T>::value> super_type;
|
||||
typedef typename super_type::type type;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // 0
|
||||
template <>
|
||||
struct disable_multi_array_impl<int>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} //namespace multi_array
|
||||
} // namespace detail
|
||||
|
||||
@ -86,12 +155,20 @@ public:
|
||||
/*index_bases=*/0, /*extents=*/0) {
|
||||
allocate_space();
|
||||
}
|
||||
|
||||
|
||||
template <class ExtentList>
|
||||
explicit multi_array(
|
||||
ExtentList const& extents
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
, typename detail::multi_array::disable_non_sub_array<ExtentList>::type* = 0
|
||||
#if 0
|
||||
, typename detail::multi_array::disable_non_sub_array<ExtentList>::type* = 0
|
||||
//#elif 0
|
||||
// , typename detail::multi_array::disable_multi_array_impl<ExtentList>::type* = 0
|
||||
#else
|
||||
, typename mpl::if_<
|
||||
detail::multi_array::is_multi_array_impl<ExtentList>,
|
||||
int&,int>::type* = 0
|
||||
#endif
|
||||
#endif
|
||||
) :
|
||||
super_type((T*)initial_base_,extents) {
|
||||
@ -99,6 +176,7 @@ public:
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
allocate_space();
|
||||
}
|
||||
|
||||
|
||||
template <class ExtentList>
|
||||
explicit multi_array(ExtentList const& extents,
|
||||
@ -197,8 +275,16 @@ public:
|
||||
// More limited support for MSVC
|
||||
|
||||
|
||||
multi_array(const const_multi_array_ref<T,NumDims,T const*>& rhs,
|
||||
const general_storage_order<NumDims>& so = c_storage_order())
|
||||
multi_array(const const_multi_array_ref<T,NumDims>& rhs)
|
||||
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
// Warning! storage order may change, hence the following copy technique.
|
||||
std::copy(rhs.begin(),rhs.end(),this->begin());
|
||||
}
|
||||
|
||||
multi_array(const const_multi_array_ref<T,NumDims>& rhs,
|
||||
const general_storage_order<NumDims>& so)
|
||||
: super_type(0,so,rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
@ -207,8 +293,16 @@ public:
|
||||
}
|
||||
|
||||
multi_array(const detail::multi_array::
|
||||
const_sub_array<T,NumDims,T const*>& rhs,
|
||||
const general_storage_order<NumDims>& so = c_storage_order())
|
||||
const_sub_array<T,NumDims>& rhs)
|
||||
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
std::copy(rhs.begin(),rhs.end(),this->begin());
|
||||
}
|
||||
|
||||
multi_array(const detail::multi_array::
|
||||
const_sub_array<T,NumDims>& rhs,
|
||||
const general_storage_order<NumDims>& so)
|
||||
: super_type(0,so,rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
@ -217,8 +311,16 @@ public:
|
||||
|
||||
|
||||
multi_array(const detail::multi_array::
|
||||
const_multi_array_view<T,NumDims,T const*>& rhs,
|
||||
const general_storage_order<NumDims>& so = c_storage_order())
|
||||
const_multi_array_view<T,NumDims>& rhs)
|
||||
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
std::copy(rhs.begin(),rhs.end(),this->begin());
|
||||
}
|
||||
|
||||
multi_array(const detail::multi_array::
|
||||
const_multi_array_view<T,NumDims>& rhs,
|
||||
const general_storage_order<NumDims>& so)
|
||||
: super_type(0,so,rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
@ -229,8 +331,16 @@ public:
|
||||
|
||||
// This constructor is necessary because of more exact template matches.
|
||||
// enable-if?
|
||||
multi_array(const multi_array_ref<T,NumDims>& rhs)
|
||||
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
// Warning! storage order may change, hence the following copy technique.
|
||||
std::copy(rhs.begin(),rhs.end(),this->begin());
|
||||
}
|
||||
|
||||
multi_array(const multi_array_ref<T,NumDims>& rhs,
|
||||
const general_storage_order<NumDims>& so = c_storage_order())
|
||||
const general_storage_order<NumDims>& so)
|
||||
: super_type(0,so,rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
@ -241,9 +351,17 @@ public:
|
||||
|
||||
// This constructor is necessary because of more exact template matches.
|
||||
// enable-if?
|
||||
multi_array(const detail::multi_array::
|
||||
sub_array<T,NumDims>& rhs)
|
||||
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
std::copy(rhs.begin(),rhs.end(),this->begin());
|
||||
}
|
||||
|
||||
multi_array(const detail::multi_array::
|
||||
sub_array<T,NumDims>& rhs,
|
||||
const general_storage_order<NumDims>& so = c_storage_order())
|
||||
const general_storage_order<NumDims>& so)
|
||||
: super_type(0,so,rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
@ -252,9 +370,17 @@ public:
|
||||
|
||||
// This constructor is necessary because of more exact template matches.
|
||||
// enable-if?
|
||||
multi_array(const detail::multi_array::
|
||||
multi_array_view<T,NumDims>& rhs)
|
||||
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
std::copy(rhs.begin(),rhs.end(),this->begin());
|
||||
}
|
||||
|
||||
multi_array(const detail::multi_array::
|
||||
multi_array_view<T,NumDims>& rhs,
|
||||
const general_storage_order<NumDims>& so = c_storage_order())
|
||||
const general_storage_order<NumDims>& so)
|
||||
: super_type(0,so,rhs.index_bases(),rhs.shape())
|
||||
{
|
||||
allocate_space();
|
||||
|
Loading…
x
Reference in New Issue
Block a user