Fixes #207 ("boost.vector doesn't work with common_iterator")

This commit is contained in:
Ion Gaztañaga
2022-01-12 01:38:05 +01:00
parent 06e8ebd255
commit 3787fc3021
8 changed files with 225 additions and 26 deletions

View File

@ -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]

View File

@ -127,7 +127,7 @@ struct are_contiguous_and_same
: boost::move_detail::and_
< are_elements_contiguous<I>
, are_elements_contiguous<O>
, is_same< typename remove_const< typename ::boost::container::iterator_traits<I>::value_type >::type
, is_same< typename remove_const< typename ::boost::container::iter_value<I>::type >::type
, typename ::boost::container::iterator_traits<O>::value_type
>
>
@ -137,7 +137,7 @@ template <typename I, typename O>
struct is_memtransfer_copy_assignable
: boost::move_detail::and_
< are_contiguous_and_same<I, O>
, dtl::is_trivially_copy_assignable< typename ::boost::container::iterator_traits<I>::value_type >
, dtl::is_trivially_copy_assignable< typename ::boost::container::iter_value<I>::type >
>
{};
@ -145,7 +145,7 @@ template <typename I, typename O>
struct is_memtransfer_copy_constructible
: boost::move_detail::and_
< are_contiguous_and_same<I, O>
, dtl::is_trivially_copy_constructible< typename ::boost::container::iterator_traits<I>::value_type >
, dtl::is_trivially_copy_constructible< typename ::boost::container::iter_value<I>::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<I>::value_type value_type;
typedef typename boost::container::iter_value<I>::type value_type;
typedef typename boost::container::iterator_traits<F>::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<I>::value_type value_type;
typedef typename boost::container::iter_value<I>::type value_type;
typedef typename boost::container::iterator_traits<F>::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<I>::value_type value_type;
typedef typename boost::container::iter_value<I>::type value_type;
typedef typename boost::container::iterator_traits<I>::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<I>::value_type value_type;
typedef typename boost::container::iter_value<I>::type value_type;
typedef typename boost::container::iterator_traits<F>::difference_type i_difference_type;
typedef typename boost::container::iterator_traits<F>::difference_type f_difference_type;
@ -273,14 +273,14 @@ struct disable_if_memzero_initializable
template <typename I, typename R>
struct enable_if_trivially_destructible
: enable_if_c < dtl::is_trivially_destructible
<typename boost::container::iterator_traits<I>::value_type>::value
<typename boost::container::iter_value<I>::type>::value
, R>
{};
template <typename I, typename R>
struct disable_if_trivially_destructible
: enable_if_c <!dtl::is_trivially_destructible
<typename boost::container::iterator_traits<I>::value_type>::value
<typename boost::container::iter_value<I>::type>::value
, R>
{};
@ -913,7 +913,7 @@ typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
move_backward(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iter_value<I>::type value_type;
const std::size_t n = boost::container::iterator_udistance(f, l);
if (BOOST_LIKELY(n != 0)){
r -= n;

View File

@ -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;

View File

@ -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

View File

@ -1292,7 +1292,7 @@ private:
>::type * = 0)
)
{
typedef typename iterator_traits<FwdIt>::size_type it_size_type;
typedef typename iter_size<FwdIt>::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<FwdIt>::size_type it_size_type;
typedef typename iter_size<FwdIt>::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 <typename InputIterator>
vector(InputIterator, InputIterator) ->
vector<typename iterator_traits<InputIterator>::value_type>;
vector<typename iter_value<InputIterator>::type>;
template <typename InputIterator, typename Allocator>
vector(InputIterator, InputIterator, Allocator const&) ->
vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
vector<typename iter_value<InputIterator>::type, Allocator>;
#endif

View File

@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3E10C8C3-4F8E-96A0-4FA2-32BA7AE46392}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>15.0.27625.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\Int\</IntDir>
<LinkIncremental>false</LinkIncremental>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(ProjectName)</TargetName>
<OutDir>$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\Int\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\Int\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(Platform)\$(Configuration)\$(TargetName)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\$(TargetName)\Int\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpplatest</LanguageStandard>
<PreprocessToFile>false</PreprocessToFile>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../../../../stage/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)common_iterator_test.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<FixedBaseAddress>false</FixedBaseAddress>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpplatest</LanguageStandard>
<PreprocessToFile>false</PreprocessToFile>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../../../../stage/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)common_iterator_test.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<FixedBaseAddress>false</FixedBaseAddress>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat />
<LanguageStandard>stdcpplatest</LanguageStandard>
<PreprocessToFile>false</PreprocessToFile>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../../../../stage/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<FixedBaseAddress>false</FixedBaseAddress>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<LanguageStandard>stdcpplatest</LanguageStandard>
<PreprocessToFile>false</PreprocessToFile>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../../../../stage/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<FixedBaseAddress>false</FixedBaseAddress>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\test\common_iterator_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -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

View File

@ -101,7 +101,7 @@
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@ -129,7 +129,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@ -152,7 +152,7 @@
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat />
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@ -180,7 +180,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<LanguageStandard>Default</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>