From 3787fc302191fecd876bfc192219617ad35d0bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 12 Jan 2022 01:38:05 +0100 Subject: [PATCH] Fixes #207 ("boost.vector doesn't work with common_iterator") --- doc/container.qbk | 2 +- .../boost/container/detail/copy_move_algo.hpp | 20 +- include/boost/container/detail/iterator.hpp | 4 + include/boost/container/detail/workaround.hpp | 8 +- include/boost/container/vector.hpp | 8 +- proj/vs/common_iterator_test.vcxproj | 191 ++++++++++++++++++ proj/vs/container.sln | 10 + proj/vs/vector_test.vcxproj | 8 +- 8 files changed, 225 insertions(+), 26 deletions(-) create mode 100644 proj/vs/common_iterator_test.vcxproj diff --git a/doc/container.qbk b/doc/container.qbk index 09c28af..6c958c5 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1346,7 +1346,7 @@ use [*Boost.Container]? There are several reasons for that: * [@https://github.com/boostorg/container/issues/199 GitHub #199: ['"Apply LWG issue 3471 to memory_resource"]]. * [@https://github.com/boostorg/container/issues/204 GitHub #204: ['"Inconsistent noexcept-ness of static_vector::reserve"]]. * [@https://github.com/boostorg/container/issues/206 GitHub #206: ['"operator-> on static_vector::iterator causes cast alignment warning"]]. - + * [@https://github.com/boostorg/container/issues/207 GitHub #207: ['"boost.vector doesn't work with common_iterator"]]. [endsect] diff --git a/include/boost/container/detail/copy_move_algo.hpp b/include/boost/container/detail/copy_move_algo.hpp index 6a65229..9c76f8d 100644 --- a/include/boost/container/detail/copy_move_algo.hpp +++ b/include/boost/container/detail/copy_move_algo.hpp @@ -127,7 +127,7 @@ struct are_contiguous_and_same : boost::move_detail::and_ < are_elements_contiguous , are_elements_contiguous - , is_same< typename remove_const< typename ::boost::container::iterator_traits::value_type >::type + , is_same< typename remove_const< typename ::boost::container::iter_value::type >::type , typename ::boost::container::iterator_traits::value_type > > @@ -137,7 +137,7 @@ template struct is_memtransfer_copy_assignable : boost::move_detail::and_ < are_contiguous_and_same - , dtl::is_trivially_copy_assignable< typename ::boost::container::iterator_traits::value_type > + , dtl::is_trivially_copy_assignable< typename ::boost::container::iter_value::type > > {}; @@ -145,7 +145,7 @@ template struct is_memtransfer_copy_constructible : boost::move_detail::and_ < are_contiguous_and_same - , dtl::is_trivially_copy_constructible< typename ::boost::container::iterator_traits::value_type > + , dtl::is_trivially_copy_constructible< typename ::boost::container::iter_value::type > > {}; @@ -174,7 +174,7 @@ template typename F> // F models ForwardIterator BOOST_CONTAINER_FORCEINLINE F memmove(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename boost::container::iterator_traits::value_type value_type; + typedef typename boost::container::iter_value::type value_type; typedef typename boost::container::iterator_traits::difference_type r_difference_type; value_type *const dest_raw = boost::movelib::iterator_to_raw_pointer(r); const value_type *const beg_raw = boost::movelib::iterator_to_raw_pointer(f); @@ -192,7 +192,7 @@ template typename F> // F models ForwardIterator BOOST_CONTAINER_FORCEINLINE F memmove_n(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename boost::container::iterator_traits::value_type value_type; + typedef typename boost::container::iter_value::type value_type; typedef typename boost::container::iterator_traits::difference_type r_difference_type; if(BOOST_LIKELY(n != 0)){ void *dst = boost::movelib::iterator_to_raw_pointer(r); @@ -211,7 +211,7 @@ template BOOST_CONTAINER_FORCEINLINE I memmove_n_source(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW { if(BOOST_LIKELY(n != 0)){ - typedef typename boost::container::iterator_traits::value_type value_type; + typedef typename boost::container::iter_value::type value_type; typedef typename boost::container::iterator_traits::difference_type i_difference_type; void *dst = boost::movelib::iterator_to_raw_pointer(r); const void *src = boost::movelib::iterator_to_raw_pointer(f); @@ -227,7 +227,7 @@ template typename F> // F models ForwardIterator BOOST_CONTAINER_FORCEINLINE I memmove_n_source_dest(I f, std::size_t n, F &r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename boost::container::iterator_traits::value_type value_type; + typedef typename boost::container::iter_value::type value_type; typedef typename boost::container::iterator_traits::difference_type i_difference_type; typedef typename boost::container::iterator_traits::difference_type f_difference_type; @@ -273,14 +273,14 @@ struct disable_if_memzero_initializable template struct enable_if_trivially_destructible : enable_if_c < dtl::is_trivially_destructible - ::value_type>::value + ::type>::value , R> {}; template struct disable_if_trivially_destructible : enable_if_c ::value_type>::value + ::type>::value , R> {}; @@ -913,7 +913,7 @@ typename F> // F models ForwardIterator BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable::type move_backward(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename boost::container::iterator_traits::value_type value_type; + typedef typename boost::container::iter_value::type value_type; const std::size_t n = boost::container::iterator_udistance(f, l); if (BOOST_LIKELY(n != 0)){ r -= n; diff --git a/include/boost/container/detail/iterator.hpp b/include/boost/container/detail/iterator.hpp index 84ccfb5..ce37adc 100644 --- a/include/boost/container/detail/iterator.hpp +++ b/include/boost/container/detail/iterator.hpp @@ -29,6 +29,10 @@ namespace boost { namespace container { using ::boost::intrusive::iterator_traits; +using ::boost::intrusive::iter_difference; +using ::boost::intrusive::iter_category; +using ::boost::intrusive::iter_value; +using ::boost::intrusive::iter_size; using ::boost::intrusive::iterator_distance; using ::boost::intrusive::iterator_udistance; using ::boost::intrusive::iterator_advance; diff --git a/include/boost/container/detail/workaround.hpp b/include/boost/container/detail/workaround.hpp index 96395e2..3cb731f 100644 --- a/include/boost/container/detail/workaround.hpp +++ b/include/boost/container/detail/workaround.hpp @@ -130,13 +130,7 @@ #endif -#if (__cplusplus >= 201703L) - //CTAD supported - #ifdef __INTEL_COMPILER - //Intel compilers do not offer this feature yet - #define BOOST_CONTAINER_NO_CXX17_CTAD - #endif -#else +#if (BOOST_CXX_VERSION < 201703L) || !defined(__cpp_deduction_guides) #define BOOST_CONTAINER_NO_CXX17_CTAD #endif diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index a9821cb..f38de63 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -1292,7 +1292,7 @@ private: >::type * = 0) ) { - typedef typename iterator_traits::size_type it_size_type; + typedef typename iter_size::type it_size_type; //For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first //so we can't do any backwards allocation const it_size_type sz = boost::container::iterator_udistance(first, last); @@ -2012,7 +2012,7 @@ private: >::type * = 0 ) { - typedef typename iterator_traits::size_type it_size_type; + typedef typename iter_size::type it_size_type; BOOST_ASSERT(this->priv_in_range_or_end(pos)); const it_size_type sz = boost::container::iterator_udistance(first, last); if (sz > size_type(-1)){ @@ -3375,11 +3375,11 @@ private: template vector(InputIterator, InputIterator) -> - vector::value_type>; + vector::type>; template vector(InputIterator, InputIterator, Allocator const&) -> - vector::value_type, Allocator>; + vector::type, Allocator>; #endif diff --git a/proj/vs/common_iterator_test.vcxproj b/proj/vs/common_iterator_test.vcxproj new file mode 100644 index 0000000..56b9a3e --- /dev/null +++ b/proj/vs/common_iterator_test.vcxproj @@ -0,0 +1,191 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392} + Win32Proj + 10.0 + + + + Application + v143 + MultiByte + + + Application + v143 + MultiByte + + + Application + v143 + MultiByte + + + Application + v143 + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27625.0 + + + $(Platform)\$(Configuration)\$(TargetName)\ + $(Platform)\$(Configuration)\$(TargetName)\Int\ + false + $(ProjectName) + + + false + $(ProjectName) + $(Platform)\$(Configuration)\$(TargetName)\ + $(Platform)\$(Configuration)\$(TargetName)\Int\ + + + $(Platform)\$(Configuration)\$(TargetName)\ + $(Platform)\$(Configuration)\$(TargetName)\Int\ + false + + + false + $(Platform)\$(Configuration)\$(TargetName)\ + $(Platform)\$(Configuration)\$(TargetName)\Int\ + + + + Disabled + ../../../..;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + Sync + EnableFastChecks + MultiThreadedDebugDLL + true + + Level4 + ProgramDatabase + stdcpplatest + false + + + winmm.lib;%(AdditionalDependencies) + ../../../../stage/lib;%(AdditionalLibraryDirectories) + true + $(OutDir)common_iterator_test.pdb + Console + MachineX86 + false + + + + + Disabled + ../../../..;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + Sync + EnableFastChecks + MultiThreadedDebugDLL + true + + + Level4 + ProgramDatabase + stdcpplatest + false + + + winmm.lib;%(AdditionalDependencies) + ../../../../stage/lib;%(AdditionalLibraryDirectories) + true + $(OutDir)common_iterator_test.pdb + Console + false + + + + + ../../../..;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + Level4 + + stdcpplatest + false + + + winmm.lib;%(AdditionalDependencies) + ../../../../stage/lib;%(AdditionalLibraryDirectories) + true + Console + true + true + MachineX86 + false + + + + + ../../../..;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + + Level4 + + + stdcpplatest + false + + + winmm.lib;%(AdditionalDependencies) + ../../../../stage/lib;%(AdditionalLibraryDirectories) + true + Console + true + true + false + + + + + + + + + \ No newline at end of file diff --git a/proj/vs/container.sln b/proj/vs/container.sln index 4215a5a..fcba163 100644 --- a/proj/vs/container.sln +++ b/proj/vs/container.sln @@ -196,6 +196,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bench_vectors", "bench_vect EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_iterator_comp_test", "boost_iterator_comp_test.vcxproj", "{E219493F-B846-4A38-87A6-948905A38CBF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_iterator_test", "common_iterator_test.vcxproj", "{3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -936,6 +938,14 @@ Global {E219493F-B846-4A38-87A6-948905A38CBF}.Release|x64.Build.0 = Release|x64 {E219493F-B846-4A38-87A6-948905A38CBF}.Release|x86.ActiveCfg = Release|Win32 {E219493F-B846-4A38-87A6-948905A38CBF}.Release|x86.Build.0 = Release|Win32 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Debug|x64.ActiveCfg = Debug|x64 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Debug|x64.Build.0 = Debug|x64 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Debug|x86.ActiveCfg = Debug|Win32 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Debug|x86.Build.0 = Debug|Win32 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Release|x64.ActiveCfg = Release|x64 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Release|x64.Build.0 = Release|x64 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Release|x86.ActiveCfg = Release|Win32 + {3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/proj/vs/vector_test.vcxproj b/proj/vs/vector_test.vcxproj index 506e8b6..b0ba387 100644 --- a/proj/vs/vector_test.vcxproj +++ b/proj/vs/vector_test.vcxproj @@ -101,7 +101,7 @@ Level4 ProgramDatabase - Default + stdcpp20 /Zc:__cplusplus %(AdditionalOptions) false false @@ -129,7 +129,7 @@ Level4 ProgramDatabase - Default + stdcpp20 /Zc:__cplusplus %(AdditionalOptions) false false @@ -152,7 +152,7 @@ Level4 - Default + stdcpp20 /Zc:__cplusplus %(AdditionalOptions) false false @@ -180,7 +180,7 @@ Level4 - Default + stdcpp20 /Zc:__cplusplus %(AdditionalOptions) false false