mirror of
https://github.com/boostorg/intrusive.git
synced 2025-08-03 14:34:44 +02:00
Another try to fix git issues
This commit is contained in:
370
include/boost/intrusive/pack_options.hpp
Normal file
370
include/boost/intrusive/pack_options.hpp
Normal file
@@ -0,0 +1,370 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2013-2013
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/intrusive for documentation.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef BOOST_INTRUSIVE_PACK_OPTIONS_HPP
|
||||||
|
#define BOOST_INTRUSIVE_PACK_OPTIONS_HPP
|
||||||
|
|
||||||
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace intrusive {
|
||||||
|
|
||||||
|
#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||||
|
|
||||||
|
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
|
template<class Prev, class Next>
|
||||||
|
struct do_pack
|
||||||
|
{
|
||||||
|
//Use "pack" member template to pack options
|
||||||
|
typedef typename Next::template pack<Prev> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Prev>
|
||||||
|
struct do_pack<Prev, void>
|
||||||
|
{
|
||||||
|
//Avoid packing "void" to shorten template names
|
||||||
|
typedef Prev type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template
|
||||||
|
< class DefaultOptions
|
||||||
|
, class O1 = void
|
||||||
|
, class O2 = void
|
||||||
|
, class O3 = void
|
||||||
|
, class O4 = void
|
||||||
|
, class O5 = void
|
||||||
|
, class O6 = void
|
||||||
|
, class O7 = void
|
||||||
|
, class O8 = void
|
||||||
|
, class O9 = void
|
||||||
|
, class O10 = void
|
||||||
|
, class O11 = void
|
||||||
|
>
|
||||||
|
struct pack_options
|
||||||
|
{
|
||||||
|
// join options
|
||||||
|
typedef
|
||||||
|
typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< typename do_pack
|
||||||
|
< DefaultOptions
|
||||||
|
, O1
|
||||||
|
>::type
|
||||||
|
, O2
|
||||||
|
>::type
|
||||||
|
, O3
|
||||||
|
>::type
|
||||||
|
, O4
|
||||||
|
>::type
|
||||||
|
, O5
|
||||||
|
>::type
|
||||||
|
, O6
|
||||||
|
>::type
|
||||||
|
, O7
|
||||||
|
>::type
|
||||||
|
, O8
|
||||||
|
>::type
|
||||||
|
, O9
|
||||||
|
>::type
|
||||||
|
, O10
|
||||||
|
>::type
|
||||||
|
, O11
|
||||||
|
>::type
|
||||||
|
type;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
|
||||||
|
//index_tuple
|
||||||
|
template<int... Indexes>
|
||||||
|
struct index_tuple{};
|
||||||
|
|
||||||
|
//build_number_seq
|
||||||
|
template<std::size_t Num, typename Tuple = index_tuple<> >
|
||||||
|
struct build_number_seq;
|
||||||
|
|
||||||
|
template<std::size_t Num, int... Indexes>
|
||||||
|
struct build_number_seq<Num, index_tuple<Indexes...> >
|
||||||
|
: build_number_seq<Num - 1, index_tuple<Indexes..., sizeof...(Indexes)> >
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<int... Indexes>
|
||||||
|
struct build_number_seq<0, index_tuple<Indexes...> >
|
||||||
|
{ typedef index_tuple<Indexes...> type; };
|
||||||
|
|
||||||
|
template<class ...Types>
|
||||||
|
struct typelist
|
||||||
|
{};
|
||||||
|
|
||||||
|
//invert_typelist
|
||||||
|
template<class T>
|
||||||
|
struct invert_typelist;
|
||||||
|
|
||||||
|
template<int I, typename Tuple>
|
||||||
|
struct typelist_element;
|
||||||
|
|
||||||
|
template<int I, typename Head, typename... Tail>
|
||||||
|
struct typelist_element<I, typelist<Head, Tail...> >
|
||||||
|
{
|
||||||
|
typedef typename typelist_element<I-1, typelist<Tail...> >::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Head, typename... Tail>
|
||||||
|
struct typelist_element<0, typelist<Head, Tail...> >
|
||||||
|
{
|
||||||
|
typedef Head type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<int ...Ints, class ...Types>
|
||||||
|
typelist<typename typelist_element<(sizeof...(Types) - 1) - Ints, typelist<Types...> >::type...>
|
||||||
|
inverted_typelist(index_tuple<Ints...>, typelist<Types...>)
|
||||||
|
{
|
||||||
|
return typelist<typename typelist_element<(sizeof...(Types) - 1) - Ints, typelist<Types...> >::type...>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//sizeof_typelist
|
||||||
|
template<class Typelist>
|
||||||
|
struct sizeof_typelist;
|
||||||
|
|
||||||
|
template<class ...Types>
|
||||||
|
struct sizeof_typelist< typelist<Types...> >
|
||||||
|
{
|
||||||
|
static const std::size_t value = sizeof...(Types);
|
||||||
|
};
|
||||||
|
|
||||||
|
//invert_typelist_impl
|
||||||
|
template<class Typelist, class Indexes>
|
||||||
|
struct invert_typelist_impl;
|
||||||
|
|
||||||
|
|
||||||
|
template<class Typelist, int ...Ints>
|
||||||
|
struct invert_typelist_impl< Typelist, index_tuple<Ints...> >
|
||||||
|
{
|
||||||
|
static const std::size_t last_idx = sizeof_typelist<Typelist>::value - 1;
|
||||||
|
typedef typelist
|
||||||
|
<typename typelist_element<last_idx - Ints, Typelist>::type...> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Typelist, int Int>
|
||||||
|
struct invert_typelist_impl< Typelist, index_tuple<Int> >
|
||||||
|
{
|
||||||
|
typedef Typelist type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Typelist>
|
||||||
|
struct invert_typelist_impl< Typelist, index_tuple<> >
|
||||||
|
{
|
||||||
|
typedef Typelist type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//invert_typelist
|
||||||
|
template<class Typelist>
|
||||||
|
struct invert_typelist;
|
||||||
|
|
||||||
|
template<class ...Types>
|
||||||
|
struct invert_typelist< typelist<Types...> >
|
||||||
|
{
|
||||||
|
typedef typelist<Types...> typelist_t;
|
||||||
|
typedef typename build_number_seq<sizeof...(Types)>::type indexes_t;
|
||||||
|
typedef typename invert_typelist_impl<typelist_t, indexes_t>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//Do pack
|
||||||
|
template<class Typelist>
|
||||||
|
struct do_pack;
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct do_pack<typelist<> >;
|
||||||
|
|
||||||
|
template<class Prev>
|
||||||
|
struct do_pack<typelist<Prev> >
|
||||||
|
{
|
||||||
|
typedef Prev type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Prev, class Last>
|
||||||
|
struct do_pack<typelist<Prev, Last> >
|
||||||
|
{
|
||||||
|
typedef typename Prev::template pack<Last> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Prev, class ...Others>
|
||||||
|
struct do_pack<typelist<Prev, Others...> >
|
||||||
|
{
|
||||||
|
typedef typename Prev::template pack
|
||||||
|
<typename do_pack<typelist<Others...> >::type> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class DefaultOptions, class ...Options>
|
||||||
|
struct pack_options
|
||||||
|
{
|
||||||
|
typedef typelist<DefaultOptions, Options...> typelist_t;
|
||||||
|
typedef typename invert_typelist<typelist_t>::type inverted_typelist;
|
||||||
|
typedef typename do_pack<inverted_typelist>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //!defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
|
#define BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME) \
|
||||||
|
template< class TYPE> \
|
||||||
|
struct OPTION_NAME \
|
||||||
|
{ \
|
||||||
|
template<class Base> \
|
||||||
|
struct pack : Base \
|
||||||
|
{ \
|
||||||
|
typedef TYPEDEF_EXPR TYPEDEF_NAME; \
|
||||||
|
}; \
|
||||||
|
}; \
|
||||||
|
//
|
||||||
|
|
||||||
|
#define BOOST_INTRUSIVE_OPTION_CONSTANT(OPTION_NAME, TYPE, VALUE, CONSTANT_NAME) \
|
||||||
|
template< TYPE VALUE> \
|
||||||
|
struct OPTION_NAME \
|
||||||
|
{ \
|
||||||
|
template<class Base> \
|
||||||
|
struct pack : Base \
|
||||||
|
{ \
|
||||||
|
static const TYPE CONSTANT_NAME = VALUE; \
|
||||||
|
}; \
|
||||||
|
}; \
|
||||||
|
//
|
||||||
|
|
||||||
|
#else //#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||||
|
|
||||||
|
//! This class is a utility that takes:
|
||||||
|
//! - a default options class defining initial static constant
|
||||||
|
//! and typedefs
|
||||||
|
//! - several options defined with BOOST_INTRUSIVE_OPTION_CONSTANT and
|
||||||
|
//! BOOST_INTRUSIVE_OPTION_TYPE
|
||||||
|
//!
|
||||||
|
//! and packs them together in a new type that defines all options as
|
||||||
|
//! member typedefs or static constant values. Given options of form:
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//! BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, VoidPointer, my_pointer_type)
|
||||||
|
//! BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental)
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! the following expression
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//!
|
||||||
|
//! struct default_options
|
||||||
|
//! {
|
||||||
|
//! typedef long int_type;
|
||||||
|
//! static const int int_constant = -1;
|
||||||
|
//! };
|
||||||
|
//!
|
||||||
|
//! pack_options< default_options, my_pointer<void*>, incremental<true> >::type
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! will create a type that will contain the following typedefs/constants
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//! struct unspecified_type
|
||||||
|
//! {
|
||||||
|
//! //Default options
|
||||||
|
//! typedef long int_type;
|
||||||
|
//! static const int int_constant = -1;
|
||||||
|
//!
|
||||||
|
//! //Packed options (will ovewrite any default option)
|
||||||
|
//! typedef void* my_pointer_type;
|
||||||
|
//! static const bool is_incremental = true;
|
||||||
|
//! };
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! If an option is specified in the default options argument and later
|
||||||
|
//! redefined as an option, the last definition will prevail.
|
||||||
|
template<class DefaultOptions, class ...Options>
|
||||||
|
struct pack_options
|
||||||
|
{
|
||||||
|
typedef unspecified_type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Defines an option class of name OPTION_NAME that can be used to specify a type
|
||||||
|
//! of type TYPE...
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//! struct OPTION_NAME<class TYPE>
|
||||||
|
//! { /*unspecified_content*/ };
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! ...that after being combined with
|
||||||
|
//! <code>boost::intrusive::pack_options</code>,
|
||||||
|
//! will typedef TYPE as a typedef of name TYPEDEF_NAME. Example:
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//! //[includes and namespaces omitted for brevity]
|
||||||
|
//!
|
||||||
|
//! //This macro will create the following class:
|
||||||
|
//! // template<class VoidPointer>
|
||||||
|
//! // struct my_pointer
|
||||||
|
//! // { unspecified_content };
|
||||||
|
//! BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, boost::remove_pointer<VoidPointer>::type, my_pointer_type)
|
||||||
|
//!
|
||||||
|
//! struct empty_default{};
|
||||||
|
//!
|
||||||
|
//! typedef pack_options< empty_default, typename my_pointer<void*> >::type::my_pointer_type type;
|
||||||
|
//!
|
||||||
|
//! BOOST_STATIC_ASSERT(( boost::is_same<type, void>::value ));
|
||||||
|
//!
|
||||||
|
//! \endcode
|
||||||
|
#define BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME)
|
||||||
|
|
||||||
|
//! Defines an option class of name OPTION_NAME that can be used to specify a constant
|
||||||
|
//! of type TYPE with value VALUE...
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//! struct OPTION_NAME<TYPE VALUE>
|
||||||
|
//! { /*unspecified_content*/ };
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! ...that after being combined with
|
||||||
|
//! <code>boost::intrusive::pack_options</code>,
|
||||||
|
//! will contain a CONSTANT_NAME static constant of value VALUE. Example:
|
||||||
|
//!
|
||||||
|
//! \code
|
||||||
|
//! //[includes and namespaces omitted for brevity]
|
||||||
|
//!
|
||||||
|
//! //This macro will create the following class:
|
||||||
|
//! // template<bool Enabled>
|
||||||
|
//! // struct incremental
|
||||||
|
//! // { unspecified_content };
|
||||||
|
//! BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental)
|
||||||
|
//!
|
||||||
|
//! struct empty_default{};
|
||||||
|
//!
|
||||||
|
//! const bool is_incremental = pack_options< empty_default, incremental<true> >::type::is_incremental;
|
||||||
|
//!
|
||||||
|
//! BOOST_STATIC_ASSERT(( is_incremental == true ));
|
||||||
|
//!
|
||||||
|
//! \endcode
|
||||||
|
#define BOOST_INTRUSIVE_OPTION_CONSTANT(OPTION_NAME, TYPE, VALUE, CONSTANT_NAME)
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
} //namespace intrusive {
|
||||||
|
} //namespace boost {
|
||||||
|
|
||||||
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_INTRUSIVE_PACK_OPTIONS_HPP
|
BIN
proj/vc7ide/Intrusive.ncb
Normal file
BIN
proj/vc7ide/Intrusive.ncb
Normal file
Binary file not shown.
BIN
proj/vc7ide/Intrusive.suo
Normal file
BIN
proj/vc7ide/Intrusive.suo
Normal file
Binary file not shown.
128
proj/vc7ide/container_size_test/container_size_test.vcproj
Normal file
128
proj/vc7ide/container_size_test/container_size_test.vcproj
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="container_size_test"
|
||||||
|
ProjectGUID="{9E721E26-45AF-192C-AD67-A4CC7D096497}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="Debug"
|
||||||
|
IntermediateDirectory="Debug"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../../../"
|
||||||
|
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="5"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/container_size_test.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/container_size_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="Release"
|
||||||
|
IntermediateDirectory="Release"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../../../"
|
||||||
|
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB,NDEBUG"
|
||||||
|
RuntimeLibrary="4"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/container_size_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4F0C713E-750E-B78A-4373-52D2204C1ACA}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\test\container_size_test.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
133
proj/vc7ide/pack_options/pack_options.vcproj
Normal file
133
proj/vc7ide/pack_options/pack_options.vcproj
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="pack_options"
|
||||||
|
ProjectGUID="{77F4139B-281B-F694-7CB1-3495467B4D35}"
|
||||||
|
RootNamespace="pack_options"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="Debug"
|
||||||
|
IntermediateDirectory="Debug"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../../../"
|
||||||
|
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
|
||||||
|
GeneratePreprocessedFile="0"
|
||||||
|
KeepComments="FALSE"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="5"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/pack_options.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/pack_options.pdb"
|
||||||
|
GenerateMapFile="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="Release"
|
||||||
|
IntermediateDirectory="Release"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../../../"
|
||||||
|
PreprocessorDefinitions="BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="4"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/pack_options.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{47FFA531-6474-B5A5-A661-272FA537F35F}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\test\pack_options_test.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
187
test/container_size_test.cpp
Normal file
187
test/container_size_test.cpp
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/intrusive for documentation.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include <boost/intrusive/list.hpp>
|
||||||
|
#include <boost/intrusive/slist.hpp>
|
||||||
|
#include <boost/intrusive/set.hpp>
|
||||||
|
#include <boost/intrusive/avl_set.hpp>
|
||||||
|
#include <boost/intrusive/bs_set.hpp>
|
||||||
|
#include <boost/intrusive/sg_set.hpp>
|
||||||
|
#include <boost/intrusive/splay_set.hpp>
|
||||||
|
#include <boost/intrusive/treap_set.hpp>
|
||||||
|
#include <boost/intrusive/unordered_set.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
using namespace boost::intrusive;
|
||||||
|
|
||||||
|
template<bool Value>
|
||||||
|
struct boolean
|
||||||
|
{
|
||||||
|
static const bool value = Value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class A, class B>
|
||||||
|
struct pow2_and_equal_sizes
|
||||||
|
{
|
||||||
|
static const std::size_t a_size = sizeof(A);
|
||||||
|
static const std::size_t b_size = sizeof(B);
|
||||||
|
static const bool a_b_sizes_equal = a_size == b_size;
|
||||||
|
static const bool value = !(a_size & (a_size - 1u));
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Hook>
|
||||||
|
struct node : Hook
|
||||||
|
{};
|
||||||
|
|
||||||
|
//Avoid testing for uncommon architectures
|
||||||
|
void test_sizes(boolean<false>, std::size_t)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class C>
|
||||||
|
void test_iterator_sizes(C &, std::size_t size)
|
||||||
|
{
|
||||||
|
typedef typename C::iterator iterator;
|
||||||
|
typedef typename C::const_iterator const_iterator;
|
||||||
|
BOOST_TEST_EQ(sizeof(iterator), size);
|
||||||
|
BOOST_TEST_EQ(sizeof(const_iterator), size);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Test sizes for common 32 and 64 bit architectures
|
||||||
|
void test_sizes(boolean<true>, std::size_t wordsize)
|
||||||
|
{
|
||||||
|
{ //list
|
||||||
|
list<node< node<list_base_hook<> > > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
list<node< node<list_base_hook<> > >, constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //slist
|
||||||
|
slist<node< node< slist_base_hook<> > > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
slist<node< node< slist_base_hook<> > > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*1);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
slist<node< node< slist_base_hook<> > > , cache_last<true> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //set
|
||||||
|
set<node< node< set_base_hook<> > > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*5);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
set<node< node< set_base_hook<> > > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*4);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
set<node< node< set_base_hook<optimize_size<true> > > > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //avl
|
||||||
|
avl_set<node< node< avl_set_base_hook<> > > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*5);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
avl_set<node< node< avl_set_base_hook<> > > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*4);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
avl_set<node< node< avl_set_base_hook<optimize_size<true> > > > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //splay
|
||||||
|
splay_set<node< node< bs_set_base_hook<> > > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*4);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
splay_set<node< node< bs_set_base_hook<> > > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //scapegoat
|
||||||
|
sg_set<node< bs_set_base_hook<> > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), (wordsize*5+sizeof(float)*2));
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //treap
|
||||||
|
treap_set<node< bs_set_base_hook<> > > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*4);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
treap_set<node< bs_set_base_hook<> > , constant_time_size<false> > c;
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize);
|
||||||
|
}
|
||||||
|
{ //unordered
|
||||||
|
typedef unordered_set<node< unordered_set_base_hook<> > > cont_type;
|
||||||
|
cont_type::bucket_type buckets[1];
|
||||||
|
cont_type c(cont_type::bucket_traits(buckets, 1));
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize*2);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef unordered_set<node< unordered_set_base_hook<> > , power_2_buckets<true> > cont_type;
|
||||||
|
cont_type::bucket_type buckets[1];
|
||||||
|
cont_type c(cont_type::bucket_traits(buckets, 1));
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*3);
|
||||||
|
test_iterator_sizes(c, wordsize*2);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef unordered_set<node< unordered_set_base_hook<> >, constant_time_size<false> > cont_type;
|
||||||
|
cont_type::bucket_type buckets[1];
|
||||||
|
cont_type c(cont_type::bucket_traits(buckets, 1));
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||||
|
test_iterator_sizes(c, wordsize*2);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef unordered_set<node< unordered_set_base_hook< optimize_multikey<true> > >, constant_time_size<false> > cont_type;
|
||||||
|
cont_type::bucket_type buckets[1];
|
||||||
|
cont_type c(cont_type::bucket_traits(buckets, 1));
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*2);
|
||||||
|
test_iterator_sizes(c, wordsize*2);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef unordered_set<node< unordered_set_base_hook< optimize_multikey<true> > >, incremental<true> > cont_type;
|
||||||
|
cont_type::bucket_type buckets[1];
|
||||||
|
cont_type c(cont_type::bucket_traits(buckets, 1));
|
||||||
|
BOOST_TEST_EQ(sizeof(c), wordsize*4);
|
||||||
|
test_iterator_sizes(c, wordsize*2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_sizes(boolean< pow2_and_equal_sizes<std::size_t, void*>::value >(), sizeof(std::size_t));
|
||||||
|
return ::boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/intrusive/detail/config_end.hpp>
|
60
test/pack_options_test.cpp
Normal file
60
test/pack_options_test.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2013-2013. Distributed under the Boost
|
||||||
|
// Software License, Version 1.0. (See accompanying file
|
||||||
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/intrusive for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
#include <boost/type_traits/remove_pointer.hpp>
|
||||||
|
#include <boost/type_traits/add_pointer.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/intrusive/pack_options.hpp>
|
||||||
|
|
||||||
|
struct empty_default{};
|
||||||
|
|
||||||
|
using namespace boost::intrusive;
|
||||||
|
|
||||||
|
//Test BOOST_INTRUSIVE_OPTION_CONSTANT
|
||||||
|
BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental)
|
||||||
|
const bool is_incremental_value = pack_options< empty_default, incremental<true> >::type::is_incremental;
|
||||||
|
BOOST_STATIC_ASSERT(( is_incremental_value == true ));
|
||||||
|
|
||||||
|
//Test BOOST_INTRUSIVE_OPTION_TYPE
|
||||||
|
BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, typename boost::remove_pointer<VoidPointer>::type, my_pointer_type)
|
||||||
|
typedef pack_options< empty_default, my_pointer<void*> >::type::my_pointer_type my_pointer_type;
|
||||||
|
BOOST_STATIC_ASSERT(( boost::is_same<my_pointer_type, void>::value ));
|
||||||
|
|
||||||
|
//test combination of BOOST_INTRUSIVE_OPTION_CONSTANT and BOOST_INTRUSIVE_OPTION_TYPE
|
||||||
|
// First add new options
|
||||||
|
struct default_options
|
||||||
|
{
|
||||||
|
static const long long_constant = -3;
|
||||||
|
typedef double * double_typedef;
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_INTRUSIVE_OPTION_CONSTANT(incremental2, bool, Enabled, is_incremental2)
|
||||||
|
BOOST_INTRUSIVE_OPTION_TYPE(my_pointer2, VoidPointer, typename boost::add_pointer<VoidPointer>::type, my_pointer_type2)
|
||||||
|
typedef pack_options < default_options
|
||||||
|
, incremental<false>
|
||||||
|
, my_pointer<float*>
|
||||||
|
, incremental2<true>
|
||||||
|
, my_pointer2<const char*>
|
||||||
|
>::type combined_type;
|
||||||
|
BOOST_STATIC_ASSERT(( combined_type::is_incremental == false ));
|
||||||
|
BOOST_STATIC_ASSERT(( combined_type::is_incremental2 == true ));
|
||||||
|
BOOST_STATIC_ASSERT(( boost::is_same<combined_type::my_pointer_type, float >::value ));
|
||||||
|
BOOST_STATIC_ASSERT(( boost::is_same<combined_type::my_pointer_type2, const char**>::value ));
|
||||||
|
|
||||||
|
//test packing the default options leads to a default options type
|
||||||
|
BOOST_STATIC_ASSERT(( boost::is_same<pack_options<default_options>::type, default_options>::value ));
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/intrusive/detail/config_end.hpp>
|
Reference in New Issue
Block a user