From f39fdf871bfaa6d1ef78c0a903083bade49b44cb Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 23 Nov 2003 15:49:55 +0000 Subject: [PATCH] Workarounds for vc7 [SVN r20920] --- include/boost/multi_array.hpp | 11 ++++-- include/boost/multi_array/concept_checks.hpp | 23 ++++++------ include/boost/multi_array/subarray.hpp | 39 ++++++++++++++++++++ 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/include/boost/multi_array.hpp b/include/boost/multi_array.hpp index 03a601e..4674d0a 100644 --- a/include/boost/multi_array.hpp +++ b/include/boost/multi_array.hpp @@ -85,15 +85,20 @@ public: super_type((T*)initial_base_) { allocate_space(); } - + template - explicit multi_array(ExtentList const& extents) : + explicit multi_array( + ExtentList const& extents +#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + , typename detail::multi_array::disable_non_sub_array::type* = 0 +#endif + ) : super_type((T*)initial_base_,extents) { boost::function_requires< detail::multi_array::CollectionConcept >(); allocate_space(); } - + template explicit multi_array(ExtentList const& extents, const general_storage_order& so) : diff --git a/include/boost/multi_array/concept_checks.hpp b/include/boost/multi_array/concept_checks.hpp index 6586618..148b691 100644 --- a/include/boost/multi_array/concept_checks.hpp +++ b/include/boost/multi_array/concept_checks.hpp @@ -61,7 +61,11 @@ namespace multi_array { struct ConstMultiArrayConcept { void constraints() { - // function_requires< CopyConstructibleConcept >(); + // function_requires< CopyConstructibleConcept >(); + function_requires< boost_concepts::ForwardTraversalConcept >(); + function_requires< boost_concepts::ReadableIteratorConcept >(); + function_requires< boost_concepts::ForwardTraversalConcept >(); + function_requires< boost_concepts::ReadableIteratorConcept >(); // RG - a( CollectionArchetype) when available... a[ id ]; @@ -100,11 +104,6 @@ namespace multi_array { typedef typename Array::extent_gen extent_gen; typedef typename Array::extent_range extent_range; - BOOST_CLASS_REQUIRE(iterator, boost_concepts, ForwardTraversalConcept); - BOOST_CLASS_REQUIRE(iterator, boost_concepts, ReadableIteratorConcept); - BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ForwardTraversalConcept); - BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ReadableIteratorConcept); - Array a; size_type st; const size_type* stp; @@ -124,6 +123,12 @@ namespace multi_array { void constraints() { // function_requires< CopyConstructibleConcept >(); + function_requires< boost_concepts::ForwardTraversalConcept >(); + function_requires< boost_concepts::ReadableIteratorConcept >(); + function_requires< boost_concepts::WritableIteratorConcept >(); + function_requires< boost_concepts::ForwardTraversalConcept >(); + function_requires< boost_concepts::ReadableIteratorConcept >(); + // RG - a( CollectionArchetype) when available... value_type vt = a[ id ]; @@ -186,12 +191,6 @@ namespace multi_array { typedef typename Array::extent_gen extent_gen; typedef typename Array::extent_range extent_range; - BOOST_CLASS_REQUIRE(iterator, boost_concepts, ForwardTraversalConcept); - BOOST_CLASS_REQUIRE(iterator, boost_concepts, ReadableIteratorConcept); - BOOST_CLASS_REQUIRE(iterator, boost_concepts, WritableIteratorConcept); - BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ForwardTraversalConcept); - BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ReadableIteratorConcept); - Array a; size_type st; const size_type* stp; diff --git a/include/boost/multi_array/subarray.hpp b/include/boost/multi_array/subarray.hpp index 00e8b9c..731c06d 100644 --- a/include/boost/multi_array/subarray.hpp +++ b/include/boost/multi_array/subarray.hpp @@ -194,6 +194,45 @@ private: const_sub_array& operator=(const const_sub_array&); }; +#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_non_sub_array. +// +template +char is_sub_array_help(const_sub_array&); + +char ( &is_sub_array_help(...) )[2]; + +template +struct is_sub_array +{ + static T x; + BOOST_STATIC_CONSTANT(bool, value = sizeof((is_sub_array_help)(x)) == 1); +}; + +template +struct disable_non_sub_array_impl +{ + // forming a pointer to a reference triggers SFINAE + typedef int& type; +}; + +template <> +struct disable_non_sub_array_impl +{ + typedef int type; +}; + +template +struct disable_non_sub_array + : disable_non_sub_array_impl::value> +{ +}; +#endif + // // sub_array // multi_array's proxy class to allow multiple overloads of