[DEV] add v1.76.0
This commit is contained in:
parent
a97e9ae7d4
commit
d0115b733d
8
INSTALL
Normal file
8
INSTALL
Normal file
@ -0,0 +1,8 @@
|
||||
See ./index.html for information about this release. The "Getting Started"
|
||||
section is a useful starting place.
|
||||
|
||||
---------------------------
|
||||
Copyright Beman Dawes, 2008
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
See ./LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
|
332
Jamroot
Normal file
332
Jamroot
Normal file
@ -0,0 +1,332 @@
|
||||
# Copyright Vladimir Prus 2002-2006.
|
||||
# Copyright Dave Abrahams 2005-2006.
|
||||
# Copyright Rene Rivera 2005-2007.
|
||||
# Copyright Douglas Gregor 2005.
|
||||
#
|
||||
# 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)
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# b2 [options] [properties] [install|stage]
|
||||
#
|
||||
# Builds and installs Boost.
|
||||
#
|
||||
# Targets and Related Options:
|
||||
#
|
||||
# install Install headers and compiled library files to the
|
||||
# ======= configured locations (below).
|
||||
#
|
||||
# --prefix=<PREFIX> Install architecture independent files here.
|
||||
# Default: C:\Boost on Windows
|
||||
# Default: /usr/local on Unix, Linux, etc.
|
||||
#
|
||||
# --exec-prefix=<EPREFIX> Install architecture dependent files here.
|
||||
# Default: <PREFIX>
|
||||
#
|
||||
# --libdir=<LIBDIR> Install library files here.
|
||||
# Default: <EPREFIX>/lib
|
||||
#
|
||||
# --includedir=<HDRDIR> Install header files here.
|
||||
# Default: <PREFIX>/include
|
||||
#
|
||||
# --cmakedir=<CMAKEDIR> Install CMake configuration files here.
|
||||
# Default: <LIBDIR>/cmake
|
||||
#
|
||||
# --no-cmake-config Do not install CMake configuration files.
|
||||
#
|
||||
# stage Build and install only compiled library files to the
|
||||
# ===== stage directory.
|
||||
#
|
||||
# --stagedir=<STAGEDIR> Install library files here
|
||||
# Default: ./stage
|
||||
#
|
||||
# Other Options:
|
||||
#
|
||||
# --build-type=<type> Build the specified pre-defined set of variations of
|
||||
# the libraries. Note, that which variants get built
|
||||
# depends on what each library supports.
|
||||
#
|
||||
# -- minimal -- (default) Builds a minimal set of
|
||||
# variants. On Windows, these are static
|
||||
# multithreaded libraries in debug and release
|
||||
# modes, using shared runtime. On Linux, these are
|
||||
# static and shared multithreaded libraries in
|
||||
# release mode.
|
||||
#
|
||||
# -- complete -- Build all possible variations.
|
||||
#
|
||||
# --build-dir=DIR Build in this location instead of building within
|
||||
# the distribution tree. Recommended!
|
||||
#
|
||||
# --show-libraries Display the list of Boost libraries that require
|
||||
# build and installation steps, and then exit.
|
||||
#
|
||||
# --layout=<layout> Determine whether to choose library names and header
|
||||
# locations such that multiple versions of Boost or
|
||||
# multiple compilers can be used on the same system.
|
||||
#
|
||||
# -- versioned -- Names of boost binaries include
|
||||
# the Boost version number, name and version of
|
||||
# the compiler and encoded build properties. Boost
|
||||
# headers are installed in a subdirectory of
|
||||
# <HDRDIR> whose name contains the Boost version
|
||||
# number.
|
||||
#
|
||||
# -- tagged -- Names of boost binaries include the
|
||||
# encoded build properties such as variant and
|
||||
# threading, but do not including compiler name
|
||||
# and version, or Boost version. This option is
|
||||
# useful if you build several variants of Boost,
|
||||
# using the same compiler.
|
||||
#
|
||||
# -- system -- Binaries names do not include the
|
||||
# Boost version number or the name and version
|
||||
# number of the compiler. Boost headers are
|
||||
# installed directly into <HDRDIR>. This option is
|
||||
# intended for system integrators building
|
||||
# distribution packages.
|
||||
#
|
||||
# The default value is 'versioned' on Windows, and
|
||||
# 'system' on Unix.
|
||||
#
|
||||
# --buildid=ID Add the specified ID to the name of built libraries.
|
||||
# The default is to not add anything.
|
||||
#
|
||||
# --python-buildid=ID Add the specified ID to the name of built libraries
|
||||
# that depend on Python. The default is to not add
|
||||
# anything. This ID is added in addition to --buildid.
|
||||
#
|
||||
# --help This message.
|
||||
#
|
||||
# --with-<library> Build and install the specified <library>. If this
|
||||
# option is used, only libraries specified using this
|
||||
# option will be built.
|
||||
#
|
||||
# --without-<library> Do not build, stage, or install the specified
|
||||
# <library>. By default, all libraries are built.
|
||||
#
|
||||
# Properties:
|
||||
#
|
||||
# toolset=toolset Indicate the toolset to build with.
|
||||
#
|
||||
# variant=debug|release Select the build variant
|
||||
#
|
||||
# link=static|shared Whether to build static or shared libraries
|
||||
#
|
||||
# threading=single|multi Whether to build single or multithreaded binaries
|
||||
#
|
||||
# runtime-link=static|shared
|
||||
# Whether to link to static or shared C and C++
|
||||
# runtime.
|
||||
#
|
||||
|
||||
# TODO:
|
||||
# - handle boost version
|
||||
# - handle python options such as pydebug
|
||||
|
||||
import boostcpp ;
|
||||
import package ;
|
||||
|
||||
import sequence ;
|
||||
import xsltproc ;
|
||||
import set ;
|
||||
import path ;
|
||||
import link ;
|
||||
import notfile ;
|
||||
import virtual-target ;
|
||||
import "class" : new ;
|
||||
import property-set ;
|
||||
import threadapi-feature ;
|
||||
import option ;
|
||||
# Backslash because of `bcp --namespace`
|
||||
import tools/boost\_install/boost-install ;
|
||||
|
||||
path-constant BOOST_ROOT : . ;
|
||||
constant BOOST_VERSION : 1.76.0 ;
|
||||
constant BOOST_JAMROOT_MODULE : $(__name__) ;
|
||||
|
||||
# Allow subprojects to simply `import config : requires ;` to get access to the requires rule
|
||||
modules.poke : BOOST_BUILD_PATH : $(BOOST_ROOT)/libs/config/checks [ modules.peek : BOOST_BUILD_PATH ] ;
|
||||
|
||||
boostcpp.set-version $(BOOST_VERSION) ;
|
||||
|
||||
use-project /boost/architecture : libs/config/checks/architecture ;
|
||||
|
||||
local all-headers =
|
||||
[ MATCH .*libs/(.*)/include/boost : [ glob libs/*/include/boost libs/*/*/include/boost ] ] ;
|
||||
|
||||
for dir in $(all-headers)
|
||||
{
|
||||
link-directory $(dir)-headers : libs/$(dir)/include/boost : <location>. ;
|
||||
explicit $(dir)-headers ;
|
||||
}
|
||||
|
||||
if $(all-headers)
|
||||
{
|
||||
constant BOOST_MODULARLAYOUT : $(all-headers) ;
|
||||
}
|
||||
|
||||
project boost
|
||||
: requirements <include>.
|
||||
|
||||
[ boostcpp.architecture ]
|
||||
[ boostcpp.address-model ]
|
||||
|
||||
# Disable auto-linking for all targets here, primarily because it caused
|
||||
# troubles with V2.
|
||||
<define>BOOST_ALL_NO_LIB=1
|
||||
# Used to encode variant in target name. See the 'tag' rule below.
|
||||
<tag>@$(__name__).tag
|
||||
<conditional>@handle-static-runtime
|
||||
# Comeau does not support shared lib
|
||||
<toolset>como:<link>static
|
||||
<toolset>como-linux:<define>_GNU_SOURCE=1
|
||||
# When building docs within Boost, we want the standard Boost style
|
||||
<xsl:param>boost.defaults=Boost
|
||||
<conditional>@threadapi-feature.detect
|
||||
: usage-requirements <include>.
|
||||
: default-build
|
||||
<visibility>hidden
|
||||
<threading>multi
|
||||
: build-dir bin.v2
|
||||
;
|
||||
|
||||
# This rule is called by Boost.Build to determine the name of target. We use it
|
||||
# to encode the build variant, compiler name and boost version in the target
|
||||
# name.
|
||||
#
|
||||
rule tag ( name : type ? : property-set )
|
||||
{
|
||||
return [ boostcpp.tag $(name) : $(type) : $(property-set) ] ;
|
||||
}
|
||||
|
||||
rule python-tag ( name : type ? : property-set )
|
||||
{
|
||||
return [ boostcpp.python-tag $(name) : $(type) : $(property-set) ] ;
|
||||
}
|
||||
|
||||
rule handle-static-runtime ( properties * )
|
||||
{
|
||||
# Using static runtime with shared libraries is impossible on Linux, and
|
||||
# dangerous on Windows. Therefore, we disallow it. This might be drastic,
|
||||
# but it was disabled for a while without anybody complaining.
|
||||
|
||||
# For CW, static runtime is needed so that std::locale works.
|
||||
if <link>shared in $(properties) && <runtime-link>static in $(properties) &&
|
||||
! ( <toolset>cw in $(properties) )
|
||||
{
|
||||
if ! $(.shared-static-warning-emitted)
|
||||
{
|
||||
ECHO "warning: skipping configuration link=shared, runtime-link=static" ;
|
||||
ECHO "warning: this combination is either impossible or too dangerous" ;
|
||||
ECHO "warning: to be of any use" ;
|
||||
.shared-static-warning-emitted = 1 ;
|
||||
}
|
||||
|
||||
return <build>no ;
|
||||
}
|
||||
}
|
||||
|
||||
all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
|
||||
[ glob libs/*/build/Jamfile ] ] ;
|
||||
|
||||
all-libraries = [ sequence.unique $(all-libraries) ] ;
|
||||
# The function_types library has a Jamfile, but it's used for maintenance
|
||||
# purposes, there's no library to build and install.
|
||||
all-libraries = [ set.difference $(all-libraries) : function_types ] ;
|
||||
|
||||
# Setup convenient aliases for all libraries.
|
||||
|
||||
local rule explicit-alias ( id : targets + )
|
||||
{
|
||||
alias $(id) : $(targets) ;
|
||||
explicit $(id) ;
|
||||
}
|
||||
|
||||
# First, the complicated libraries: where the target name in Jamfile is
|
||||
# different from its directory name.
|
||||
explicit-alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
|
||||
explicit-alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
|
||||
explicit-alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
|
||||
explicit-alias bgl-vis : libs/graps/build//bgl-vis ;
|
||||
explicit-alias serialization : libs/serialization/build//boost_serialization ;
|
||||
explicit-alias wserialization : libs/serialization/build//boost_wserialization ;
|
||||
for local l in $(all-libraries)
|
||||
{
|
||||
if ! $(l) in test graph serialization headers
|
||||
{
|
||||
explicit-alias $(l) : libs/$(l)/build//boost_$(l) ;
|
||||
}
|
||||
}
|
||||
|
||||
# Log has an additional target
|
||||
explicit-alias log_setup : libs/log/build//boost_log_setup ;
|
||||
|
||||
rule do-nothing { }
|
||||
|
||||
rule generate-alias ( project name : property-set : sources * )
|
||||
{
|
||||
local action-name = [ $(property-set).get <action> ] ;
|
||||
local m = [ MATCH ^@(.*) : $(action-name) ] ;
|
||||
property-set = [ property-set.empty ] ;
|
||||
local action = [ new action $(sources) : $(m[1]) : $(property-set) ] ;
|
||||
local t = [ new notfile-target $(name) : $(project) : $(action) ] ;
|
||||
return [ virtual-target.register $(t) ] ;
|
||||
}
|
||||
|
||||
generate headers : $(all-headers)-headers : <generating-rule>@generate-alias <action>@do-nothing : : <include>. ;
|
||||
|
||||
#alias headers : $(all-headers)-headers : : : <include>. ;
|
||||
explicit headers ;
|
||||
|
||||
# Make project ids of all libraries known.
|
||||
for local l in $(all-libraries)
|
||||
{
|
||||
use-project /boost/$(l) : libs/$(l)/build ;
|
||||
}
|
||||
|
||||
if [ path.exists $(BOOST_ROOT)/tools/inspect/build ]
|
||||
{
|
||||
use-project /boost/tools/inspect : tools/inspect/build ;
|
||||
}
|
||||
|
||||
if [ path.exists $(BOOST_ROOT)/libs/wave/tool/build ]
|
||||
{
|
||||
use-project /boost/libs/wave/tool : libs/wave/tool/build ;
|
||||
}
|
||||
|
||||
# Make the boost-install rule visible in subprojects
|
||||
|
||||
# This rule should be called from libraries' Jamfiles and will create two
|
||||
# targets, "install" and "stage", that will install or stage that library. The
|
||||
# --prefix option is respected, but --with and --without options, naturally, are
|
||||
# ignored.
|
||||
#
|
||||
# - libraries -- list of library targets to install.
|
||||
|
||||
rule boost-install ( libraries * )
|
||||
{
|
||||
boost-install.boost-install $(libraries) ;
|
||||
}
|
||||
|
||||
# Creates a library target, adding autolink support and also creates
|
||||
# stage and install targets via boost-install, above.
|
||||
rule boost-lib ( name : sources * : requirements * : default-build * : usage-requirements * )
|
||||
{
|
||||
autolink = <link>shared:<define>BOOST_$(name:U)_DYN_LINK=1 ;
|
||||
name = boost_$(name) ;
|
||||
lib $(name)
|
||||
: $(sources)
|
||||
: $(requirements) $(autolink)
|
||||
: $(default-build)
|
||||
: $(usage-requirements) $(autolink)
|
||||
;
|
||||
boost-install $(name) ;
|
||||
}
|
||||
|
||||
|
||||
# Declare special top-level targets that build and install the desired variants
|
||||
# of the libraries.
|
||||
boostcpp.declare-targets $(all-libraries) ;
|
13
README.md
13
README.md
@ -1,2 +1,11 @@
|
||||
# boost
|
||||
boost source only
|
||||
# Boost C++ Libraries
|
||||
|
||||
The Boost project provides free peer-reviewed portable C++ source libraries.
|
||||
|
||||
We emphasize libraries that work well with the C++ Standard Library. Boost
|
||||
libraries are intended to be widely useful, and usable across a broad spectrum
|
||||
of applications. The Boost license encourages both commercial and non-commercial use
|
||||
and does not require attribution for binary use.
|
||||
|
||||
The project website is www.boost.org, where you can obtain more information and
|
||||
[download](https://www.boost.org/users/download/) the current release.
|
||||
|
17
boost-build.jam
Normal file
17
boost-build.jam
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2002-2003 David Abrahams.
|
||||
# Copyright (C) 2002-2003 Vladimir Prus.
|
||||
# Copyright (C) 2003,2007 Rene Rivera.
|
||||
# Use, modification and distribution are subject to 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)
|
||||
|
||||
# This is the initial file loaded by Boost Jam when run from any Boost library
|
||||
# folder. It allows us to choose which Boost Build installation to use for
|
||||
# building Boost libraries. Unless explicitly selected using a command-line
|
||||
# option, the version included with the Boost library distribution is used (as
|
||||
# opposed to any other Boost Build version installed on the user's sytem).
|
||||
|
||||
BOOST_ROOT = $(.boost-build-file:D) ;
|
||||
BOOST_BUILD = [ MATCH --boost-build=(.*) : $(ARGV) ] ;
|
||||
BOOST_BUILD ?= tools/build/src ;
|
||||
boost-build $(BOOST_BUILD) ;
|
66
boost.css
Normal file
66
boost.css
Normal file
@ -0,0 +1,66 @@
|
||||
/*=============================================================================
|
||||
Copyright 2002 William E. Kempf
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
H1
|
||||
{
|
||||
FONT-SIZE: 200%;
|
||||
COLOR: #00008B;
|
||||
}
|
||||
H2
|
||||
{
|
||||
FONT-SIZE: 150%;
|
||||
}
|
||||
H3
|
||||
{
|
||||
FONT-SIZE: 125%;
|
||||
}
|
||||
H4
|
||||
{
|
||||
FONT-SIZE: 108%;
|
||||
}
|
||||
BODY
|
||||
{
|
||||
FONT-SIZE: 100%;
|
||||
BACKGROUND-COLOR: #ffffff;
|
||||
COLOR: #000000;
|
||||
}
|
||||
PRE
|
||||
{
|
||||
MARGIN-LEFT: 2em;
|
||||
FONT-FAMILY: Courier,
|
||||
monospace;
|
||||
}
|
||||
CODE
|
||||
{
|
||||
FONT-FAMILY: Courier,
|
||||
monospace;
|
||||
}
|
||||
CODE.as_pre
|
||||
{
|
||||
white-space: pre;
|
||||
}
|
||||
.index
|
||||
{
|
||||
TEXT-ALIGN: left;
|
||||
}
|
||||
.page-index
|
||||
{
|
||||
TEXT-ALIGN: left;
|
||||
}
|
||||
.definition
|
||||
{
|
||||
TEXT-ALIGN: left;
|
||||
}
|
||||
.footnote
|
||||
{
|
||||
FONT-SIZE: 66%;
|
||||
VERTICAL-ALIGN: super;
|
||||
TEXT-DECORATION: none;
|
||||
}
|
||||
.function-semantics
|
||||
{
|
||||
CLEAR: left;
|
||||
}
|
@ -9,6 +9,8 @@
|
||||
#define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/parameter/is_argument_pack.hpp>
|
||||
#include <boost/mpl/apply_fwd.hpp> // for mpl::na
|
||||
#include <boost/mpl/limits/vector.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
@ -41,7 +43,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
|
||||
# include <boost/utility/enable_if.hpp>
|
||||
# include <boost/type_traits/is_const.hpp>
|
||||
# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\
|
||||
, typename boost::disable_if<boost::is_const<T> >::type * = 0
|
||||
@ -128,9 +129,12 @@ template<typename Feature, typename AccumulatorSet>
|
||||
typename mpl::apply<AccumulatorSet, Feature>::type::result_type
|
||||
extract_result(AccumulatorSet const &acc);
|
||||
|
||||
template<typename Feature, typename AccumulatorSet, typename A1>
|
||||
typename mpl::apply<AccumulatorSet, Feature>::type::result_type
|
||||
extract_result(AccumulatorSet const &acc, A1 const &a1);
|
||||
namespace detail
|
||||
{
|
||||
struct _enabler
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
// ... other overloads generated by Boost.Preprocessor:
|
||||
|
||||
@ -146,17 +150,37 @@ extract_result(AccumulatorSet const &acc, A1 const &a1);
|
||||
extract_result( \
|
||||
AccumulatorSet const &acc \
|
||||
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::enable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type = detail::_enabler() \
|
||||
); \
|
||||
template< \
|
||||
typename Feature \
|
||||
, typename AccumulatorSet \
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
|
||||
> \
|
||||
typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
|
||||
extract_result( \
|
||||
AccumulatorSet const &acc \
|
||||
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::disable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type = detail::_enabler() \
|
||||
);
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
2
|
||||
1
|
||||
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
|
||||
, BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD
|
||||
|
||||
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
|
||||
template<typename Feature, typename AccumulatorSet, typename A1, typename A2 ...>
|
||||
typename mpl::apply<AccumulatorSet, Feature>::type::result_type
|
||||
@ -185,6 +209,9 @@ namespace detail
|
||||
struct is_accumulator_set;
|
||||
|
||||
inline void ignore_variable(void const *) {}
|
||||
}
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
#define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \
|
||||
namespace detail \
|
||||
@ -198,33 +225,8 @@ namespace detail
|
||||
}; \
|
||||
} \
|
||||
/**/
|
||||
}
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
#include <boost/parameter/nested_keyword.hpp>
|
||||
|
||||
// For defining boost::parameter keywords that can be inherited from to
|
||||
// get a nested, class-scoped keyword with the requested alias
|
||||
#define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias) \
|
||||
namespace tag_namespace \
|
||||
{ \
|
||||
template<int Dummy = 0> \
|
||||
struct name ## _ \
|
||||
{ \
|
||||
static char const* keyword_name() \
|
||||
{ \
|
||||
return #name; \
|
||||
} \
|
||||
static ::boost::parameter::keyword<name ## _<Dummy> > &alias; \
|
||||
}; \
|
||||
template<int Dummy> \
|
||||
::boost::parameter::keyword<name ## _<Dummy> > &name ## _<Dummy>::alias = \
|
||||
::boost::parameter::keyword<name ## _<Dummy> >::get(); \
|
||||
typedef name ## _ <> name; \
|
||||
} \
|
||||
namespace \
|
||||
{ \
|
||||
::boost::parameter::keyword<tag_namespace::name> &name = \
|
||||
::boost::parameter::keyword<tag_namespace::name>::get(); \
|
||||
}
|
||||
#endif // include guard
|
||||
|
||||
#endif
|
||||
|
@ -9,16 +9,23 @@
|
||||
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/protect.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
#include <boost/parameter/parameters.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/parameter/is_argument_pack.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
#include <boost/accumulators/accumulators_fwd.hpp>
|
||||
#include <boost/accumulators/framework/depends_on.hpp>
|
||||
#include <boost/accumulators/framework/accumulator_concept.hpp>
|
||||
@ -64,14 +71,6 @@ namespace detail
|
||||
return accumulator_visitor<Args>(args);
|
||||
}
|
||||
|
||||
typedef
|
||||
parameter::parameters<
|
||||
parameter::required<tag::accumulator>
|
||||
, parameter::optional<tag::sample>
|
||||
// ... and others which are not specified here...
|
||||
>
|
||||
accumulator_params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// accumulator_set_base
|
||||
struct accumulator_set_base
|
||||
@ -82,10 +81,38 @@ namespace detail
|
||||
// is_accumulator_set
|
||||
template<typename T>
|
||||
struct is_accumulator_set
|
||||
: is_base_and_derived<accumulator_set_base, T>
|
||||
: mpl::if_<
|
||||
boost::is_base_of<
|
||||
accumulator_set_base
|
||||
, typename boost::remove_const<
|
||||
typename boost::remove_reference<T>::type
|
||||
>::type
|
||||
>
|
||||
, mpl::true_
|
||||
, mpl::false_
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
// function object that serialize an accumulator
|
||||
template<typename Archive>
|
||||
struct serialize_accumulator
|
||||
{
|
||||
serialize_accumulator(Archive & _ar, const unsigned int _file_version) :
|
||||
ar(_ar), file_version(_file_version)
|
||||
{}
|
||||
|
||||
template<typename Accumulator>
|
||||
void operator ()(Accumulator &accumulator)
|
||||
{
|
||||
accumulator.serialize(ar, file_version);
|
||||
}
|
||||
|
||||
private:
|
||||
Archive& ar;
|
||||
const unsigned int file_version;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@ -140,13 +167,13 @@ struct accumulator_set
|
||||
: accumulators(
|
||||
detail::make_acc_list(
|
||||
accumulators_mpl_vector()
|
||||
, detail::accumulator_params()(*this)
|
||||
, (boost::accumulators::accumulator = *this)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Add-ref the Features that the user has specified
|
||||
this->template visit_if<detail::contains_feature_of_<Features> >(
|
||||
detail::make_add_ref_visitor(detail::accumulator_params()(*this))
|
||||
detail::make_add_ref_visitor(boost::accumulators::accumulator = *this)
|
||||
);
|
||||
}
|
||||
|
||||
@ -154,17 +181,48 @@ struct accumulator_set
|
||||
///
|
||||
/// \param a1 Optional named parameter to be passed to all the accumulators
|
||||
template<typename A1>
|
||||
explicit accumulator_set(A1 const &a1)
|
||||
: accumulators(
|
||||
explicit accumulator_set(
|
||||
A1 const &a1
|
||||
, typename boost::enable_if<
|
||||
parameter::is_argument_pack<A1>
|
||||
, detail::_enabler
|
||||
>::type = detail::_enabler()
|
||||
) : accumulators(
|
||||
detail::make_acc_list(
|
||||
accumulators_mpl_vector()
|
||||
, detail::accumulator_params()(*this, a1)
|
||||
, (boost::accumulators::accumulator = *this, a1)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Add-ref the Features that the user has specified
|
||||
this->template visit_if<detail::contains_feature_of_<Features> >(
|
||||
detail::make_add_ref_visitor(detail::accumulator_params()(*this))
|
||||
detail::make_add_ref_visitor(boost::accumulators::accumulator = *this)
|
||||
);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
///
|
||||
/// \param a1 Optional sample parameter to be passed to all the accumulators
|
||||
template<typename A1>
|
||||
explicit accumulator_set(
|
||||
A1 const &a1
|
||||
, typename boost::disable_if<
|
||||
parameter::is_argument_pack<A1>
|
||||
, detail::_enabler
|
||||
>::type = detail::_enabler()
|
||||
) : accumulators(
|
||||
detail::make_acc_list(
|
||||
accumulators_mpl_vector()
|
||||
, (
|
||||
boost::accumulators::accumulator = *this
|
||||
, boost::accumulators::sample = a1
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Add-ref the Features that the user has specified
|
||||
this->template visit_if<detail::contains_feature_of_<Features> >(
|
||||
detail::make_add_ref_visitor(boost::accumulators::accumulator = *this)
|
||||
);
|
||||
}
|
||||
|
||||
@ -174,19 +232,47 @@ struct accumulator_set
|
||||
///
|
||||
#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR(z, n, _) \
|
||||
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
|
||||
accumulator_set(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \
|
||||
: accumulators( \
|
||||
accumulator_set( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::enable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type = detail::_enabler() \
|
||||
) : accumulators( \
|
||||
detail::make_acc_list( \
|
||||
accumulators_mpl_vector() \
|
||||
, detail::accumulator_params()( \
|
||||
*this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
|
||||
, ( \
|
||||
boost::accumulators::accumulator = *this \
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
{ \
|
||||
/* Add-ref the Features that the user has specified */ \
|
||||
this->template visit_if<detail::contains_feature_of_<Features> >( \
|
||||
detail::make_add_ref_visitor(detail::accumulator_params()(*this)) \
|
||||
detail::make_add_ref_visitor(boost::accumulators::accumulator = *this) \
|
||||
); \
|
||||
} \
|
||||
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
|
||||
accumulator_set( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::disable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type = detail::_enabler() \
|
||||
) : accumulators( \
|
||||
detail::make_acc_list( \
|
||||
accumulators_mpl_vector() \
|
||||
, ( \
|
||||
boost::accumulators::accumulator = *this \
|
||||
, boost::accumulators::sample = BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
{ \
|
||||
/* Add-ref the Features that the user has specified */ \
|
||||
this->template visit_if<detail::contains_feature_of_<Features> >( \
|
||||
detail::make_add_ref_visitor(boost::accumulators::accumulator = *this) \
|
||||
); \
|
||||
}
|
||||
|
||||
@ -239,17 +325,7 @@ struct accumulator_set
|
||||
{
|
||||
this->visit(
|
||||
detail::make_accumulator_visitor(
|
||||
detail::accumulator_params()(*this)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template<typename A1>
|
||||
void operator ()(A1 const &a1)
|
||||
{
|
||||
this->visit(
|
||||
detail::make_accumulator_visitor(
|
||||
detail::accumulator_params()(*this, a1)
|
||||
boost::accumulators::accumulator = *this
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -260,12 +336,37 @@ struct accumulator_set
|
||||
///
|
||||
#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP(z, n, _) \
|
||||
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
|
||||
void operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \
|
||||
void operator ()( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::enable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type = detail::_enabler() \
|
||||
) \
|
||||
{ \
|
||||
this->visit( \
|
||||
detail::make_accumulator_visitor( \
|
||||
detail::accumulator_params()( \
|
||||
*this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
|
||||
( \
|
||||
boost::accumulators::accumulator = *this \
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
|
||||
) \
|
||||
) \
|
||||
); \
|
||||
} \
|
||||
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
|
||||
void operator ()( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::disable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type = detail::_enabler() \
|
||||
) \
|
||||
{ \
|
||||
this->visit( \
|
||||
detail::make_accumulator_visitor( \
|
||||
( \
|
||||
boost::accumulators::accumulator = *this \
|
||||
, boost::accumulators::sample = BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
|
||||
) \
|
||||
) \
|
||||
); \
|
||||
@ -274,7 +375,7 @@ struct accumulator_set
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
2
|
||||
1
|
||||
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
|
||||
, BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP
|
||||
, _
|
||||
@ -329,15 +430,23 @@ struct accumulator_set
|
||||
the_feature;
|
||||
|
||||
(*fusion::find_if<detail::matches_feature<Feature> >(this->accumulators))
|
||||
.drop(detail::accumulator_params()(*this));
|
||||
.drop(boost::accumulators::accumulator = *this);
|
||||
|
||||
// Also drop accumulators that this feature depends on
|
||||
typedef typename the_feature::dependencies dependencies;
|
||||
this->template visit_if<detail::contains_feature_of_<dependencies> >(
|
||||
detail::make_drop_visitor(detail::accumulator_params()(*this))
|
||||
detail::make_drop_visitor(boost::accumulators::accumulator = *this)
|
||||
);
|
||||
}
|
||||
|
||||
// make the accumulator set serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
detail::serialize_accumulator<Archive> serializer(ar, file_version);
|
||||
fusion::for_each(this->accumulators, serializer);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
accumulators_type accumulators;
|
||||
@ -365,6 +474,15 @@ find_accumulator(AccumulatorSet const &acc)
|
||||
return acc.template extract<Feature>();
|
||||
}
|
||||
|
||||
template<typename Feature, typename AccumulatorSet>
|
||||
typename mpl::apply<AccumulatorSet, Feature>::type::result_type
|
||||
extract_result(AccumulatorSet const &acc)
|
||||
{
|
||||
return find_accumulator<Feature>(acc).result(
|
||||
boost::accumulators::accumulator = acc
|
||||
);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// extract_result
|
||||
// extract a result from an accumulator set
|
||||
@ -380,18 +498,43 @@ find_accumulator(AccumulatorSet const &acc)
|
||||
extract_result( \
|
||||
AccumulatorSet const &acc \
|
||||
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::enable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type \
|
||||
) \
|
||||
{ \
|
||||
return find_accumulator<Feature>(acc).result( \
|
||||
detail::accumulator_params()( \
|
||||
acc \
|
||||
( \
|
||||
boost::accumulators::accumulator = acc \
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
|
||||
) \
|
||||
); \
|
||||
} \
|
||||
template< \
|
||||
typename Feature \
|
||||
, typename AccumulatorSet \
|
||||
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
|
||||
> \
|
||||
typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
|
||||
extract_result( \
|
||||
AccumulatorSet const &acc \
|
||||
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
|
||||
, typename boost::disable_if< \
|
||||
parameter::is_argument_pack<A0> \
|
||||
, detail::_enabler \
|
||||
>::type \
|
||||
) \
|
||||
{ \
|
||||
return find_accumulator<Feature>(acc).result(( \
|
||||
boost::accumulators::accumulator = acc \
|
||||
, boost::accumulators::sample = BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
|
||||
)); \
|
||||
}
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1
|
||||
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
|
||||
, BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN
|
||||
, _
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ namespace boost { namespace accumulators { namespace impl
|
||||
template<typename Args>
|
||||
result_type result(Args const &args) const
|
||||
{
|
||||
return this->extract_(args, args[parameter::keyword<Tag>::get() | 0]);
|
||||
return this->extract_(args, args[parameter::keyword<Tag>::instance | 0]);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -31,7 +31,7 @@ namespace impl
|
||||
|
||||
template<typename Args>
|
||||
reference_accumulator_impl(Args const &args)
|
||||
: ref(args[parameter::keyword<Tag>::get()])
|
||||
: ref(args[parameter::keyword<Tag>::instance])
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace impl
|
||||
|
||||
template<typename Args>
|
||||
value_accumulator_impl(Args const &args)
|
||||
: val(args[parameter::keyword<Tag>::get()])
|
||||
: val(args[parameter::keyword<Tag>::instance])
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -266,11 +266,18 @@ namespace boost { namespace accumulators
|
||||
|
||||
template<typename Sequence, typename Args>
|
||||
typename meta::make_acc_list<Sequence>::type
|
||||
make_acc_list(Sequence const &seq, Args const &args)
|
||||
make_acc_list(Sequence &seq, Args const &args)
|
||||
{
|
||||
return meta::make_acc_list<Sequence>::call(args, fusion::begin(seq), fusion::end(seq));
|
||||
}
|
||||
|
||||
template<typename Sequence, typename Args>
|
||||
typename meta::make_acc_list<Sequence>::type
|
||||
make_acc_list(Sequence const &seq, Args const &args)
|
||||
{
|
||||
return meta::make_acc_list<Sequence const>::call(args, fusion::begin(seq), fusion::end(seq));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// checked_as_weighted_feature
|
||||
template<typename Feature>
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005
|
||||
#define BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/tuple/rem.hpp>
|
||||
#include <boost/preprocessor/array/size.hpp>
|
||||
#include <boost/preprocessor/array/data.hpp>
|
||||
@ -15,11 +16,17 @@
|
||||
#include <boost/preprocessor/seq/to_array.hpp>
|
||||
#include <boost/preprocessor/seq/transform.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/parameter/binding.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/accumulators/accumulators_fwd.hpp>
|
||||
#include <boost/accumulators/framework/parameters/accumulator.hpp>
|
||||
@ -33,14 +40,24 @@ namespace detail
|
||||
struct accumulator_set_result
|
||||
{
|
||||
typedef typename as_feature<Feature>::type feature_type;
|
||||
typedef typename mpl::apply<AccumulatorSet, feature_type>::type::result_type type;
|
||||
typedef typename mpl::apply<
|
||||
typename boost::remove_const<
|
||||
typename boost::remove_reference<AccumulatorSet>::type
|
||||
>::type
|
||||
, feature_type
|
||||
>::type::result_type type;
|
||||
};
|
||||
|
||||
template<typename Args, typename Feature>
|
||||
struct argument_pack_result
|
||||
: accumulator_set_result<
|
||||
typename remove_reference<
|
||||
typename parameter::binding<Args, tag::accumulator>::type
|
||||
typename boost::remove_reference<
|
||||
typename parameter::binding<
|
||||
typename boost::remove_const<
|
||||
typename boost::remove_reference<Args>::type
|
||||
>::type
|
||||
, tag::accumulator
|
||||
>::type
|
||||
>::type
|
||||
, Feature
|
||||
>
|
||||
@ -147,6 +164,8 @@ struct extractor
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP
|
||||
|
||||
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
|
||||
/// \overload
|
||||
///
|
||||
@ -156,6 +175,8 @@ struct extractor
|
||||
#endif
|
||||
};
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
#define BOOST_ACCUMULATORS_ARRAY_REM(Array) \
|
||||
@ -224,6 +245,4 @@ struct extractor
|
||||
, (3, (Tag, Feature, ParamSeq)) \
|
||||
)
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
#endif
|
||||
|
@ -8,13 +8,13 @@
|
||||
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
|
||||
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/name.hpp>
|
||||
#include <boost/accumulators/accumulators_fwd.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, accumulator)
|
||||
BOOST_PARAMETER_NAME((accumulator, tag) accumulator)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(accumulator)
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
@ -8,13 +8,13 @@
|
||||
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
|
||||
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/name.hpp>
|
||||
#include <boost/accumulators/accumulators_fwd.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
BOOST_PARAMETER_KEYWORD(tag, sample)
|
||||
BOOST_PARAMETER_NAME((sample, tag) sample)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(sample)
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
@ -8,14 +8,14 @@
|
||||
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
|
||||
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/name.hpp>
|
||||
#include <boost/accumulators/accumulators_fwd.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
// The weight of a single sample
|
||||
BOOST_PARAMETER_KEYWORD(tag, weight)
|
||||
BOOST_PARAMETER_NAME((weight, tag) weight)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weight)
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
@ -8,14 +8,14 @@
|
||||
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
|
||||
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
|
||||
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/name.hpp>
|
||||
#include <boost/accumulators/accumulators_fwd.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
// The weight accumulator
|
||||
BOOST_PARAMETER_KEYWORD(tag, weights)
|
||||
BOOST_PARAMETER_NAME((weights, tag) weights)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weights)
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
@ -43,6 +43,13 @@ namespace impl
|
||||
return this->cnt;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & cnt;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t cnt;
|
||||
};
|
||||
|
@ -152,6 +152,13 @@ namespace impl
|
||||
return this->cov_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & cov_;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type cov_;
|
||||
};
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <boost/accumulators/statistics/count.hpp>
|
||||
#include <boost/accumulators/statistics/max.hpp>
|
||||
#include <boost/accumulators/statistics/min.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -184,6 +186,20 @@ namespace impl
|
||||
return make_iterator_range(this->histogram);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO split to save/load and check on parameters provided in ctor
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & cache_size;
|
||||
ar & cache;
|
||||
ar & num_bins;
|
||||
ar & samples_in_bin;
|
||||
ar & bin_positions;
|
||||
ar & histogram;
|
||||
ar & is_dirty;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t cache_size; // number of cached samples
|
||||
array_type cache; // cache to store the first cache_size samples
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/accumulators/statistics/count.hpp>
|
||||
#include <boost/accumulators/statistics/times2_iterator.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -236,6 +237,19 @@ namespace impl
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that the parameters did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & probabilities;
|
||||
ar & heights;
|
||||
ar & actual_positions;
|
||||
ar & desired_positions;
|
||||
ar & positions_increments;
|
||||
}
|
||||
|
||||
private:
|
||||
array_type probabilities; // the quantile probabilities
|
||||
array_type heights; // q_i
|
||||
|
@ -185,6 +185,17 @@ namespace impl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that the parameters did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & probabilities;
|
||||
ar & probability;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
array_type probabilities;
|
||||
|
@ -63,6 +63,10 @@ namespace impl
|
||||
* ( accumulators::moment<2>(args) - mean(args) * mean(args) )
|
||||
) - 3.;
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
@ -48,6 +48,13 @@ namespace impl
|
||||
return this->max_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & max_;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample max_;
|
||||
};
|
||||
|
@ -41,6 +41,10 @@ namespace impl
|
||||
extractor<SumFeature> sum;
|
||||
return numeric::fdiv(sum(args), count(args));
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
template<typename Sample, typename Tag>
|
||||
@ -71,6 +75,12 @@ namespace impl
|
||||
return this->mean;
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & mean;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type mean;
|
||||
};
|
||||
|
@ -48,6 +48,10 @@ namespace impl
|
||||
{
|
||||
return p_square_quantile_for_median(args);
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// with_density_median_impl
|
||||
@ -105,6 +109,16 @@ namespace impl
|
||||
return this->median;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum;
|
||||
ar & is_dirty;
|
||||
ar & median;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
mutable float_type sum;
|
||||
mutable bool is_dirty;
|
||||
@ -160,6 +174,15 @@ namespace impl
|
||||
|
||||
return this->median;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & is_dirty;
|
||||
ar & median;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
mutable bool is_dirty;
|
||||
|
@ -48,6 +48,13 @@ namespace impl
|
||||
return this->min_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & min_;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample min_;
|
||||
};
|
||||
|
@ -75,6 +75,13 @@ namespace impl
|
||||
return numeric::fdiv(this->sum, count(args));
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample sum;
|
||||
};
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <boost/accumulators/framework/parameters/sample.hpp>
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/accumulators/statistics/count.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -204,6 +206,20 @@ namespace impl
|
||||
//return histogram;
|
||||
return make_iterator_range(this->histogram);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO split to save/load and check on parameters provided in ctor
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & num_cells;
|
||||
ar & heights;
|
||||
ar & actual_positions;
|
||||
ar & desired_positions;
|
||||
ar & positions_increments;
|
||||
ar & histogram;
|
||||
ar & is_dirty;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t num_cells; // number of cells b
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/accumulators/statistics/count.hpp>
|
||||
#include <boost/accumulators/statistics/parameters/quantile_probability.hpp>
|
||||
#include <boost/serialization/boost_array.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -61,7 +62,7 @@ namespace impl
|
||||
|
||||
template<typename Args>
|
||||
p_square_quantile_impl(Args const &args)
|
||||
: p(is_same<Impl, for_median>::value ? 0.5 : args[quantile_probability | 0.5])
|
||||
: p(is_same<Impl, for_median>::value ? float_type(0.5) : args[quantile_probability | float_type(0.5)])
|
||||
, heights()
|
||||
, actual_positions()
|
||||
, desired_positions()
|
||||
@ -69,20 +70,21 @@ namespace impl
|
||||
{
|
||||
for(std::size_t i = 0; i < 5; ++i)
|
||||
{
|
||||
this->actual_positions[i] = i + 1.;
|
||||
this->actual_positions[i] = i + float_type(1.);
|
||||
}
|
||||
|
||||
this->desired_positions[0] = 1.;
|
||||
this->desired_positions[1] = 1. + 2. * this->p;
|
||||
this->desired_positions[2] = 1. + 4. * this->p;
|
||||
this->desired_positions[3] = 3. + 2. * this->p;
|
||||
this->desired_positions[4] = 5.;
|
||||
this->desired_positions[0] = float_type(1.);
|
||||
this->desired_positions[1] = float_type(1.) + float_type(2.) * this->p;
|
||||
this->desired_positions[2] = float_type(1.) + float_type(4.) * this->p;
|
||||
this->desired_positions[3] = float_type(3.) + float_type(2.) * this->p;
|
||||
this->desired_positions[4] = float_type(5.);
|
||||
|
||||
this->positions_increments[0] = 0.;
|
||||
this->positions_increments[1] = this->p / 2.;
|
||||
|
||||
this->positions_increments[0] = float_type(0.);
|
||||
this->positions_increments[1] = this->p / float_type(2.);
|
||||
this->positions_increments[2] = this->p;
|
||||
this->positions_increments[3] = (1. + this->p) / 2.;
|
||||
this->positions_increments[4] = 1.;
|
||||
this->positions_increments[3] = (float_type(1.) + this->p) / float_type(2.);
|
||||
this->positions_increments[4] = float_type(1.);
|
||||
}
|
||||
|
||||
template<typename Args>
|
||||
@ -156,7 +158,7 @@ namespace impl
|
||||
float_type hp = (this->heights[i + 1] - this->heights[i]) / dp;
|
||||
float_type hm = (this->heights[i - 1] - this->heights[i]) / dm;
|
||||
|
||||
if((d >= 1. && dp > 1.) || (d <= -1. && dm < -1.))
|
||||
if((d >= float_type(1.) && dp > float_type(1.)) || (d <= float_type(-1.) && dm < float_type(-1.)))
|
||||
{
|
||||
short sign_d = static_cast<short>(d / std::abs(d));
|
||||
|
||||
@ -171,11 +173,11 @@ namespace impl
|
||||
else
|
||||
{
|
||||
// use linear formula
|
||||
if(d > 0)
|
||||
if(d > float_type(0))
|
||||
{
|
||||
this->heights[i] += hp;
|
||||
}
|
||||
if(d < 0)
|
||||
if(d < float_type(0))
|
||||
{
|
||||
this->heights[i] -= hm;
|
||||
}
|
||||
@ -191,6 +193,18 @@ namespace impl
|
||||
return this->heights[2];
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that P did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & p;
|
||||
ar & heights;
|
||||
ar & actual_positions;
|
||||
ar & desired_positions;
|
||||
ar & positions_increments;
|
||||
}
|
||||
|
||||
private:
|
||||
float_type p; // the quantile probability p
|
||||
array_type heights; // q_i
|
||||
|
@ -181,6 +181,21 @@ namespace impl
|
||||
return this->fit_parameters_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that threshold did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & Nu_;
|
||||
ar & mu_;
|
||||
ar & sigma2_;
|
||||
ar & threshold_;
|
||||
ar & get<0>(fit_parameters_);
|
||||
ar & get<1>(fit_parameters_);
|
||||
ar & get<2>(fit_parameters_);
|
||||
ar & is_dirty_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t Nu_; // number of samples larger than threshold
|
||||
mutable float_type mu_; // mean of Nu_ largest samples
|
||||
@ -291,6 +306,20 @@ namespace impl
|
||||
return this->fit_parameters_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that threshold did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & mu_;
|
||||
ar & sigma2_;
|
||||
ar & threshold_probability_;
|
||||
ar & get<0>(fit_parameters_);
|
||||
ar & get<1>(fit_parameters_);
|
||||
ar & get<2>(fit_parameters_);
|
||||
ar & is_dirty_;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable float_type mu_; // mean of samples above threshold u
|
||||
mutable float_type sigma2_; // variance of samples above threshold u
|
||||
|
@ -80,6 +80,13 @@ namespace impl
|
||||
, -xi_hat
|
||||
) - 1.));
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sign_;
|
||||
}
|
||||
|
||||
private:
|
||||
short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result
|
||||
|
@ -90,6 +90,14 @@ namespace impl
|
||||
is_same<LeftRight, left>::value ? args[quantile_probability] : 1. - args[quantile_probability]
|
||||
, -xi_hat);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sign_;
|
||||
}
|
||||
|
||||
private:
|
||||
short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result
|
||||
};
|
||||
|
@ -40,6 +40,10 @@ namespace impl
|
||||
{
|
||||
return static_cast<std::size_t>(rolling_window_plus1(args).size()) - is_rolling_window_plus1_full(args);
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
@ -43,6 +43,10 @@ namespace boost { namespace accumulators
|
||||
{
|
||||
return numeric::fdiv(rolling_sum(args), rolling_count(args));
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -67,12 +71,18 @@ namespace boost { namespace accumulators
|
||||
{
|
||||
if(is_rolling_window_plus1_full(args))
|
||||
{
|
||||
mean_ += numeric::fdiv(args[sample]-rolling_window_plus1(args).front(),rolling_count(args));
|
||||
if (rolling_window_plus1(args).front() > args[sample])
|
||||
mean_ -= numeric::fdiv(rolling_window_plus1(args).front()-args[sample],rolling_count(args));
|
||||
else if (rolling_window_plus1(args).front() < args[sample])
|
||||
mean_ += numeric::fdiv(args[sample]-rolling_window_plus1(args).front(),rolling_count(args));
|
||||
}
|
||||
else
|
||||
{
|
||||
result_type prev_mean = mean_;
|
||||
mean_ += numeric::fdiv(args[sample]-prev_mean,rolling_count(args));
|
||||
if (prev_mean > args[sample])
|
||||
mean_ -= numeric::fdiv(prev_mean-args[sample],rolling_count(args));
|
||||
else if (prev_mean < args[sample])
|
||||
mean_ += numeric::fdiv(args[sample]-prev_mean,rolling_count(args));
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +91,13 @@ namespace boost { namespace accumulators
|
||||
{
|
||||
return mean_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & mean_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -176,4 +193,4 @@ namespace boost { namespace accumulators
|
||||
};
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -58,6 +58,13 @@ namespace impl
|
||||
return numeric::fdiv(this->sum_, rolling_count(args));
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum_;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type sum_;
|
||||
};
|
||||
|
@ -51,6 +51,13 @@ namespace impl
|
||||
return this->sum_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum_;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample sum_;
|
||||
};
|
||||
|
@ -62,6 +62,10 @@ namespace impl
|
||||
if (nr_samples < 2) return result_type();
|
||||
return nr_samples*(rolling_moment<2>(args) - mean*mean)/(nr_samples-1);
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
//! Iterative calculation of the rolling variance.
|
||||
@ -138,6 +142,14 @@ namespace impl
|
||||
if (nr_samples < 2) return result_type();
|
||||
return numeric::fdiv(sum_of_squares_,(nr_samples-1));
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & previous_mean_;
|
||||
ar & sum_of_squares_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
@ -21,6 +21,45 @@
|
||||
#include <boost/accumulators/framework/parameters/accumulator.hpp>
|
||||
#include <boost/accumulators/numeric/functional.hpp>
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
|
||||
// implement serialization for boost::circular_buffer
|
||||
template <class Archive, class T>
|
||||
void save(Archive& ar, const circular_buffer<T>& b, const unsigned int /* version */)
|
||||
{
|
||||
typename circular_buffer<T>::size_type size = b.size();
|
||||
ar << b.capacity();
|
||||
ar << size;
|
||||
const typename circular_buffer<T>::const_array_range one = b.array_one();
|
||||
const typename circular_buffer<T>::const_array_range two = b.array_two();
|
||||
ar.save_binary(one.first, one.second*sizeof(T));
|
||||
ar.save_binary(two.first, two.second*sizeof(T));
|
||||
}
|
||||
|
||||
template <class Archive, class T>
|
||||
void load(Archive& ar, circular_buffer<T>& b, const unsigned int /* version */)
|
||||
{
|
||||
typename circular_buffer<T>::capacity_type capacity;
|
||||
typename circular_buffer<T>::size_type size;
|
||||
ar >> capacity;
|
||||
b.set_capacity(capacity);
|
||||
ar >> size;
|
||||
b.clear();
|
||||
const typename circular_buffer<T>::pointer buff = new T[size*sizeof(T)];
|
||||
ar.load_binary(buff, size*sizeof(T));
|
||||
b.insert(b.begin(), buff, buff+size);
|
||||
delete[] buff;
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
inline void serialize(Archive & ar, circular_buffer<T>& b, const unsigned int version)
|
||||
{
|
||||
split_free(ar, b, version);
|
||||
}
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -83,6 +122,12 @@ namespace impl
|
||||
return result_type(this->buffer_.begin(), this->buffer_.end());
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & buffer_;
|
||||
}
|
||||
|
||||
private:
|
||||
circular_buffer<Sample> buffer_;
|
||||
};
|
||||
@ -112,6 +157,10 @@ namespace impl
|
||||
{
|
||||
return rolling_window_plus1(args).advance_begin(is_rolling_window_plus1_full(args));
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
@ -65,6 +65,10 @@ namespace impl
|
||||
* std::sqrt( accumulators::moment<2>(args) - mean(args) * mean(args) )
|
||||
);
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
@ -51,8 +51,13 @@ namespace impl
|
||||
return this->sum;
|
||||
}
|
||||
|
||||
private:
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample sum;
|
||||
};
|
||||
|
||||
|
@ -66,6 +66,14 @@ struct sum_kahan_impl
|
||||
return this->sum;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum;
|
||||
ar & compensation;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample sum;
|
||||
Sample compensation;
|
||||
|
@ -268,6 +268,17 @@ namespace impl
|
||||
std::vector<Sample> const &samples;
|
||||
};
|
||||
|
||||
public:
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & is_sorted;
|
||||
ar & indices;
|
||||
ar & samples;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable bool is_sorted;
|
||||
mutable std::vector<std::size_t> indices;
|
||||
std::vector<Sample> samples;
|
||||
|
@ -88,6 +88,10 @@ namespace impl
|
||||
- numeric::fdiv(n, count(args))
|
||||
);
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -159,6 +163,10 @@ namespace impl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
@ -98,6 +98,10 @@ namespace impl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
} // namespace impl
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <boost/accumulators/framework/depends_on.hpp>
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/accumulators/statistics/tail.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -69,6 +70,14 @@ namespace impl
|
||||
);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & variates;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<VariateType> variates;
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <boost/accumulators/statistics/tail_variate.hpp>
|
||||
#include <boost/accumulators/statistics/tail_mean.hpp>
|
||||
#include <boost/accumulators/statistics/parameters/quantile_probability.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
@ -145,6 +146,13 @@ namespace impl
|
||||
return make_iterator_range(this->tail_means_);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & tail_means_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
mutable array_type tail_means_;
|
||||
|
@ -53,6 +53,10 @@ namespace impl
|
||||
result_type tmp = mean(args);
|
||||
return accumulators::moment<2>(args) - tmp * tmp;
|
||||
}
|
||||
|
||||
// serialization is done by accumulators it depends on
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version) {}
|
||||
};
|
||||
|
||||
//! Iterative calculation of variance.
|
||||
@ -113,6 +117,13 @@ namespace impl
|
||||
return this->variance;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & variance;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type variance;
|
||||
};
|
||||
|
@ -97,6 +97,13 @@ namespace impl
|
||||
return this->cov_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & cov_;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type cov_;
|
||||
};
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <boost/accumulators/statistics/max.hpp>
|
||||
#include <boost/accumulators/statistics/min.hpp>
|
||||
#include <boost/accumulators/statistics/density.hpp> // for named parameters density_cache_size and density_num_bins
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -171,6 +173,20 @@ namespace impl
|
||||
return make_iterator_range(this->histogram);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO split to save/load and check on parameters provided in ctor
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & cache_size;
|
||||
ar & cache;
|
||||
ar & num_bins;
|
||||
ar & samples_in_bin;
|
||||
ar & bin_positions;
|
||||
ar & histogram;
|
||||
ar & is_dirty;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t cache_size; // number of cached samples
|
||||
histogram_type cache; // cache to store the first cache_size samples with their weights as std::pair
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <boost/accumulators/statistics/sum.hpp>
|
||||
#include <boost/accumulators/statistics/times2_iterator.hpp>
|
||||
#include <boost/accumulators/statistics/extended_p_square.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
@ -251,6 +252,17 @@ namespace impl
|
||||
);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that the parameters did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & probabilities;
|
||||
ar & heights;
|
||||
ar & actual_positions;
|
||||
ar & desired_positions;
|
||||
}
|
||||
|
||||
private:
|
||||
array_type probabilities; // the quantile probabilities
|
||||
array_type heights; // q_i
|
||||
|
@ -97,6 +97,13 @@ namespace impl
|
||||
return this->mean;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & mean;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type mean;
|
||||
};
|
||||
|
@ -106,6 +106,15 @@ namespace impl
|
||||
return this->median;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum;
|
||||
ar & is_dirty;
|
||||
ar & median;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable float_type sum;
|
||||
mutable bool is_dirty;
|
||||
@ -162,6 +171,15 @@ namespace impl
|
||||
|
||||
return this->median;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & is_dirty;
|
||||
ar & median;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable bool is_dirty;
|
||||
mutable float_type median;
|
||||
|
@ -60,6 +60,13 @@ namespace impl
|
||||
return numeric::fdiv(this->sum, sum_of_weights(args));
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sum;
|
||||
}
|
||||
|
||||
private:
|
||||
weighted_sample sum;
|
||||
};
|
||||
|
@ -221,6 +221,19 @@ namespace impl
|
||||
return make_iterator_range(this->histogram);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO split to save/load and check on parameters provided in ctor
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & num_cells;
|
||||
ar & heights;
|
||||
ar & actual_positions;
|
||||
ar & desired_positions;
|
||||
ar & histogram;
|
||||
ar & is_dirty;
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t num_cells; // number of cells b
|
||||
array_type heights; // q_i
|
||||
|
@ -208,6 +208,17 @@ namespace impl {
|
||||
return this->heights[2];
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO split to save/load and check on parameters provided in ctor
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & p;
|
||||
ar & heights;
|
||||
ar & actual_positions;
|
||||
ar & desired_positions;
|
||||
}
|
||||
|
||||
private:
|
||||
float_type p; // the quantile probability p
|
||||
array_type heights; // q_i
|
||||
|
@ -109,6 +109,19 @@ namespace impl
|
||||
return this->fit_parameters_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
// TODO: do we need to split to load/save and verify that threshold did not change?
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & sign_;
|
||||
ar & mu_;
|
||||
ar & sigma2_;
|
||||
ar & threshold_;
|
||||
ar & fit_parameters_;
|
||||
ar & is_dirty_;
|
||||
}
|
||||
|
||||
private:
|
||||
short sign_; // for left tail fitting, mirror the extreme values
|
||||
mutable float_type mu_; // mean of samples above threshold
|
||||
|
@ -55,6 +55,13 @@ namespace impl
|
||||
return this->weighted_sum_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & weighted_sum_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
weighted_sample weighted_sum_;
|
||||
|
@ -68,6 +68,14 @@ namespace impl
|
||||
return this->weighted_sum_;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & weighted_sum_;
|
||||
ar & compensation;
|
||||
}
|
||||
|
||||
private:
|
||||
weighted_sample weighted_sum_;
|
||||
weighted_sample compensation;
|
||||
|
@ -179,6 +179,13 @@ namespace impl
|
||||
return make_iterator_range(this->tail_means_);
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & tail_means_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
mutable array_type tail_means_;
|
||||
|
@ -103,6 +103,13 @@ namespace impl
|
||||
return this->weighted_variance;
|
||||
}
|
||||
|
||||
// make this accumulator serializeable
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int file_version)
|
||||
{
|
||||
ar & weighted_variance;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type weighted_variance;
|
||||
};
|
||||
|
@ -19,16 +19,17 @@
|
||||
|
||||
#include <functional> // for plus and multiplies
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility/enable_if.hpp> // for boost::disable_if
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
template <typename T>
|
||||
T identity_operation ( std::multiplies<T> ) { return T(1); }
|
||||
BOOST_CXX14_CONSTEXPR T identity_operation ( std::multiplies<T> ) { return T(1); }
|
||||
|
||||
template <typename T>
|
||||
T identity_operation ( std::plus<T> ) { return T(0); }
|
||||
BOOST_CXX14_CONSTEXPR T identity_operation ( std::plus<T> ) { return T(0); }
|
||||
|
||||
|
||||
/// \fn power ( T x, Integer n )
|
||||
@ -40,7 +41,7 @@ T identity_operation ( std::plus<T> ) { return T(0); }
|
||||
// \remark Taken from Knuth, The Art of Computer Programming, Volume 2:
|
||||
// Seminumerical Algorithms, Section 4.6.3
|
||||
template <typename T, typename Integer>
|
||||
typename boost::enable_if<boost::is_integral<Integer>, T>::type
|
||||
BOOST_CXX14_CONSTEXPR typename boost::enable_if<boost::is_integral<Integer>, T>::type
|
||||
power (T x, Integer n) {
|
||||
T y = 1; // Should be "T y{1};"
|
||||
if (n == 0) return y;
|
||||
@ -67,7 +68,7 @@ power (T x, Integer n) {
|
||||
// \remark Taken from Knuth, The Art of Computer Programming, Volume 2:
|
||||
// Seminumerical Algorithms, Section 4.6.3
|
||||
template <typename T, typename Integer, typename Operation>
|
||||
typename boost::enable_if<boost::is_integral<Integer>, T>::type
|
||||
BOOST_CXX14_CONSTEXPR typename boost::enable_if<boost::is_integral<Integer>, T>::type
|
||||
power (T x, Integer n, Operation op) {
|
||||
T y = identity_operation(op);
|
||||
if (n == 0) return y;
|
||||
|
126
boost/algorithm/apply_permutation.hpp
Normal file
126
boost/algorithm/apply_permutation.hpp
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.com>, 2017
|
||||
|
||||
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/ for latest version.
|
||||
|
||||
|
||||
Based on https://blogs.msdn.microsoft.com/oldnewthing/20170104-00/?p=95115
|
||||
*/
|
||||
|
||||
/// \file apply_permutation.hpp
|
||||
/// \brief Apply permutation to a sequence.
|
||||
/// \author Alexander Zaitsev
|
||||
|
||||
#ifndef BOOST_ALGORITHM_APPLY_PERMUTATION_HPP
|
||||
#define BOOST_ALGORITHM_APPLY_PERMUTATION_HPP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost { namespace algorithm
|
||||
{
|
||||
|
||||
/// \fn apply_permutation ( RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end, RandomAccessIterator2 ind_begin )
|
||||
/// \brief Reorder item sequence with index sequence order
|
||||
///
|
||||
/// \param item_begin The start of the item sequence
|
||||
/// \param item_end One past the end of the item sequence
|
||||
/// \param ind_begin The start of the index sequence.
|
||||
///
|
||||
/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined.
|
||||
/// Complexity: O(N).
|
||||
template<typename RandomAccessIterator1, typename RandomAccessIterator2>
|
||||
void
|
||||
apply_permutation(RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end,
|
||||
RandomAccessIterator2 ind_begin, RandomAccessIterator2 ind_end)
|
||||
{
|
||||
typedef typename std::iterator_traits<RandomAccessIterator1>::difference_type Diff;
|
||||
typedef typename std::iterator_traits<RandomAccessIterator2>::difference_type Index;
|
||||
using std::swap;
|
||||
Diff size = std::distance(item_begin, item_end);
|
||||
for (Diff i = 0; i < size; i++)
|
||||
{
|
||||
Diff current = i;
|
||||
while (i != ind_begin[current])
|
||||
{
|
||||
Index next = ind_begin[current];
|
||||
swap(item_begin[current], item_begin[next]);
|
||||
ind_begin[current] = current;
|
||||
current = next;
|
||||
}
|
||||
ind_begin[current] = current;
|
||||
}
|
||||
}
|
||||
|
||||
/// \fn apply_reverse_permutation ( RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end, RandomAccessIterator2 ind_begin )
|
||||
/// \brief Reorder item sequence with index sequence order
|
||||
///
|
||||
/// \param item_begin The start of the item sequence
|
||||
/// \param item_end One past the end of the item sequence
|
||||
/// \param ind_begin The start of the index sequence.
|
||||
///
|
||||
/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined.
|
||||
/// Complexity: O(N).
|
||||
template<typename RandomAccessIterator1, typename RandomAccessIterator2>
|
||||
void
|
||||
apply_reverse_permutation(
|
||||
RandomAccessIterator1 item_begin,
|
||||
RandomAccessIterator1 item_end,
|
||||
RandomAccessIterator2 ind_begin,
|
||||
RandomAccessIterator2 ind_end)
|
||||
{
|
||||
typedef typename std::iterator_traits<RandomAccessIterator2>::difference_type Diff;
|
||||
using std::swap;
|
||||
Diff length = std::distance(item_begin, item_end);
|
||||
for (Diff i = 0; i < length; i++)
|
||||
{
|
||||
while (i != ind_begin[i])
|
||||
{
|
||||
Diff next = ind_begin[i];
|
||||
swap(item_begin[i], item_begin[next]);
|
||||
swap(ind_begin[i], ind_begin[next]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// \fn apply_permutation ( Range1 item_range, Range2 ind_range )
|
||||
/// \brief Reorder item sequence with index sequence order
|
||||
///
|
||||
/// \param item_range The item sequence
|
||||
/// \param ind_range The index sequence
|
||||
///
|
||||
/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined.
|
||||
/// Complexity: O(N).
|
||||
template<typename Range1, typename Range2>
|
||||
void
|
||||
apply_permutation(Range1& item_range, Range2& ind_range)
|
||||
{
|
||||
apply_permutation(boost::begin(item_range), boost::end(item_range),
|
||||
boost::begin(ind_range), boost::end(ind_range));
|
||||
}
|
||||
|
||||
/// \fn apply_reverse_permutation ( Range1 item_range, Range2 ind_range )
|
||||
/// \brief Reorder item sequence with index sequence order
|
||||
///
|
||||
/// \param item_range The item sequence
|
||||
/// \param ind_range The index sequence
|
||||
///
|
||||
/// \note Item sequence size should be equal to index size. Otherwise behavior is undefined.
|
||||
/// Complexity: O(N).
|
||||
template<typename Range1, typename Range2>
|
||||
void
|
||||
apply_reverse_permutation(Range1& item_range, Range2& ind_range)
|
||||
{
|
||||
apply_reverse_permutation(boost::begin(item_range), boost::end(item_range),
|
||||
boost::begin(ind_range), boost::end(ind_range));
|
||||
}
|
||||
|
||||
}}
|
||||
#endif //BOOST_ALGORITHM_APPLY_PERMUTATION_HPP
|
@ -23,6 +23,7 @@
|
||||
#include <iterator> // For std::iterator_traits
|
||||
#include <cassert>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/mpl/identity.hpp> // for identity
|
||||
@ -46,7 +47,7 @@ namespace boost { namespace algorithm {
|
||||
/// p ( a, b ) returns a boolean.
|
||||
///
|
||||
template<typename T, typename Pred>
|
||||
T const & clamp ( T const& val,
|
||||
BOOST_CXX14_CONSTEXPR T const & clamp ( T const& val,
|
||||
typename boost::mpl::identity<T>::type const & lo,
|
||||
typename boost::mpl::identity<T>::type const & hi, Pred p )
|
||||
{
|
||||
@ -68,11 +69,11 @@ namespace boost { namespace algorithm {
|
||||
/// \param hi The upper bound of the range to be clamped to
|
||||
///
|
||||
template<typename T>
|
||||
T const& clamp ( const T& val,
|
||||
BOOST_CXX14_CONSTEXPR T const& clamp ( const T& val,
|
||||
typename boost::mpl::identity<T>::type const & lo,
|
||||
typename boost::mpl::identity<T>::type const & hi )
|
||||
{
|
||||
return (clamp) ( val, lo, hi, std::less<T>());
|
||||
return boost::algorithm::clamp ( val, lo, hi, std::less<T>());
|
||||
}
|
||||
|
||||
/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
|
||||
@ -87,13 +88,13 @@ namespace boost { namespace algorithm {
|
||||
/// \param hi The upper bound of the range to be clamped to
|
||||
///
|
||||
template<typename InputIterator, typename OutputIterator>
|
||||
OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
|
||||
BOOST_CXX14_CONSTEXPR OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
|
||||
typename std::iterator_traits<InputIterator>::value_type const & lo,
|
||||
typename std::iterator_traits<InputIterator>::value_type const & hi )
|
||||
{
|
||||
// this could also be written with bind and std::transform
|
||||
while ( first != last )
|
||||
*out++ = clamp ( *first++, lo, hi );
|
||||
*out++ = boost::algorithm::clamp ( *first++, lo, hi );
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -108,12 +109,12 @@ namespace boost { namespace algorithm {
|
||||
/// \param hi The upper bound of the range to be clamped to
|
||||
///
|
||||
template<typename Range, typename OutputIterator>
|
||||
typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type
|
||||
BOOST_CXX14_CONSTEXPR typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type
|
||||
clamp_range ( const Range &r, OutputIterator out,
|
||||
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
|
||||
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi )
|
||||
{
|
||||
return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi );
|
||||
return boost::algorithm::clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi );
|
||||
}
|
||||
|
||||
|
||||
@ -133,13 +134,13 @@ namespace boost { namespace algorithm {
|
||||
|
||||
///
|
||||
template<typename InputIterator, typename OutputIterator, typename Pred>
|
||||
OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
|
||||
BOOST_CXX14_CONSTEXPR OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
|
||||
typename std::iterator_traits<InputIterator>::value_type const & lo,
|
||||
typename std::iterator_traits<InputIterator>::value_type const & hi, Pred p )
|
||||
{
|
||||
// this could also be written with bind and std::transform
|
||||
while ( first != last )
|
||||
*out++ = clamp ( *first++, lo, hi, p );
|
||||
*out++ = boost::algorithm::clamp ( *first++, lo, hi, p );
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -160,13 +161,13 @@ namespace boost { namespace algorithm {
|
||||
// Disable this template if the first two parameters are the same type;
|
||||
// In that case, the user will get the two iterator version.
|
||||
template<typename Range, typename OutputIterator, typename Pred>
|
||||
typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type
|
||||
BOOST_CXX14_CONSTEXPR typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type
|
||||
clamp_range ( const Range &r, OutputIterator out,
|
||||
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
|
||||
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi,
|
||||
Pred p )
|
||||
{
|
||||
return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p );
|
||||
return boost::algorithm::clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p );
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BOOST_ALGORITHM_ALL_OF_HPP
|
||||
#define BOOST_ALGORITHM_ALL_OF_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -27,7 +28,7 @@ namespace boost { namespace algorithm {
|
||||
///
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template<typename InputIterator, typename Predicate>
|
||||
bool all_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( !p(*first))
|
||||
@ -43,7 +44,7 @@ bool all_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename Predicate>
|
||||
bool all_of ( const Range &r, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of ( const Range &r, Predicate p )
|
||||
{
|
||||
return boost::algorithm::all_of ( boost::begin (r), boost::end (r), p );
|
||||
}
|
||||
@ -57,7 +58,7 @@ bool all_of ( const Range &r, Predicate p )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename InputIterator, typename T>
|
||||
bool all_of_equal ( InputIterator first, InputIterator last, const T &val )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of_equal ( InputIterator first, InputIterator last, const T &val )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( val != *first )
|
||||
@ -73,7 +74,7 @@ bool all_of_equal ( InputIterator first, InputIterator last, const T &val )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename Range, typename T>
|
||||
bool all_of_equal ( const Range &r, const T &val )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of_equal ( const Range &r, const T &val )
|
||||
{
|
||||
return boost::algorithm::all_of_equal ( boost::begin (r), boost::end (r), val );
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef BOOST_ALGORITHM_ANY_OF_HPP
|
||||
#define BOOST_ALGORITHM_ANY_OF_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -28,7 +29,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A predicate for testing the elements of the sequence
|
||||
///
|
||||
template<typename InputIterator, typename Predicate>
|
||||
bool any_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool any_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( p(*first))
|
||||
@ -44,7 +45,7 @@ bool any_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename Predicate>
|
||||
bool any_of ( const Range &r, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool any_of ( const Range &r, Predicate p )
|
||||
{
|
||||
return boost::algorithm::any_of (boost::begin (r), boost::end (r), p);
|
||||
}
|
||||
@ -58,7 +59,7 @@ bool any_of ( const Range &r, Predicate p )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename InputIterator, typename V>
|
||||
bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
BOOST_CXX14_CONSTEXPR bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( val == *first )
|
||||
@ -74,7 +75,7 @@ bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename Range, typename V>
|
||||
bool any_of_equal ( const Range &r, const V &val )
|
||||
BOOST_CXX14_CONSTEXPR bool any_of_equal ( const Range &r, const V &val )
|
||||
{
|
||||
return boost::algorithm::any_of_equal (boost::begin (r), boost::end (r), val);
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
#define BOOST_ALGORITHM_COPY_IF_HPP
|
||||
|
||||
#include <utility> // for std::pair, std::make_pair
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -29,7 +31,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template<typename InputIterator, typename OutputIterator, typename Predicate>
|
||||
OutputIterator copy_if ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR OutputIterator copy_if ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if (p(*first))
|
||||
@ -47,7 +49,7 @@ OutputIterator copy_if ( InputIterator first, InputIterator last, OutputIterator
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename OutputIterator, typename Predicate>
|
||||
OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p )
|
||||
{
|
||||
return boost::algorithm::copy_if (boost::begin (r), boost::end(r), result, p);
|
||||
}
|
||||
@ -64,7 +66,7 @@ OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename InputIterator, typename OutputIterator, typename Predicate>
|
||||
std::pair<InputIterator, OutputIterator>
|
||||
BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator>
|
||||
copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
|
||||
{
|
||||
for ( ; first != last && p(*first); ++first )
|
||||
@ -82,7 +84,7 @@ copy_while ( InputIterator first, InputIterator last, OutputIterator result, Pre
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename OutputIterator, typename Predicate>
|
||||
std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
|
||||
BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
|
||||
copy_while ( const Range &r, OutputIterator result, Predicate p )
|
||||
{
|
||||
return boost::algorithm::copy_while (boost::begin (r), boost::end(r), result, p);
|
||||
@ -100,7 +102,7 @@ copy_while ( const Range &r, OutputIterator result, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename InputIterator, typename OutputIterator, typename Predicate>
|
||||
std::pair<InputIterator, OutputIterator>
|
||||
BOOST_CXX14_CONSTEXPR std::pair<InputIterator, OutputIterator>
|
||||
copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
|
||||
{
|
||||
for ( ; first != last && !p(*first); ++first )
|
||||
@ -118,7 +120,7 @@ copy_until ( InputIterator first, InputIterator last, OutputIterator result, Pre
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename OutputIterator, typename Predicate>
|
||||
std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
|
||||
BOOST_CXX14_CONSTEXPR std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
|
||||
copy_until ( const Range &r, OutputIterator result, Predicate p )
|
||||
{
|
||||
return boost::algorithm::copy_until (boost::begin (r), boost::end(r), result, p);
|
||||
|
@ -12,6 +12,8 @@
|
||||
#ifndef BOOST_ALGORITHM_COPY_N_HPP
|
||||
#define BOOST_ALGORITHM_COPY_N_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
/// \fn copy_n ( InputIterator first, Size n, OutputIterator result )
|
||||
@ -24,7 +26,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param result An output iterator to write the results into
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template <typename InputIterator, typename Size, typename OutputIterator>
|
||||
OutputIterator copy_n ( InputIterator first, Size n, OutputIterator result )
|
||||
BOOST_CXX14_CONSTEXPR OutputIterator copy_n ( InputIterator first, Size n, OutputIterator result )
|
||||
{
|
||||
for ( ; n > 0; --n, ++first, ++result )
|
||||
*result = *first;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BOOST_ALGORITHM_FIND_IF_NOT_HPP
|
||||
#define BOOST_ALGORITHM_FIND_IF_NOT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -26,7 +27,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template<typename InputIterator, typename Predicate>
|
||||
InputIterator find_if_not ( InputIterator first, InputIterator last, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR InputIterator find_if_not ( InputIterator first, InputIterator last, Predicate p )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( !p(*first))
|
||||
@ -42,7 +43,7 @@ InputIterator find_if_not ( InputIterator first, InputIterator last, Predicate p
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename Predicate>
|
||||
typename boost::range_iterator<const Range>::type find_if_not ( const Range &r, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR typename boost::range_iterator<const Range>::type find_if_not ( const Range &r, Predicate p )
|
||||
{
|
||||
return boost::algorithm::find_if_not (boost::begin (r), boost::end(r), p);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BOOST_ALGORITHM_IOTA_HPP
|
||||
#define BOOST_ALGORITHM_IOTA_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -25,7 +26,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param value The initial value of the sequence to be generated
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template <typename ForwardIterator, typename T>
|
||||
void iota ( ForwardIterator first, ForwardIterator last, T value )
|
||||
BOOST_CXX14_CONSTEXPR void iota ( ForwardIterator first, ForwardIterator last, T value )
|
||||
{
|
||||
for ( ; first != last; ++first, ++value )
|
||||
*first = value;
|
||||
@ -38,7 +39,7 @@ void iota ( ForwardIterator first, ForwardIterator last, T value )
|
||||
/// \param value The initial value of the sequence to be generated
|
||||
///
|
||||
template <typename Range, typename T>
|
||||
void iota ( Range &r, T value )
|
||||
BOOST_CXX14_CONSTEXPR void iota ( Range &r, T value )
|
||||
{
|
||||
boost::algorithm::iota (boost::begin(r), boost::end(r), value);
|
||||
}
|
||||
@ -52,7 +53,7 @@ void iota ( Range &r, T value )
|
||||
/// \param n The number of items to write
|
||||
///
|
||||
template <typename OutputIterator, typename T>
|
||||
OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
|
||||
BOOST_CXX14_CONSTEXPR OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
|
||||
{
|
||||
for ( ; n > 0; --n, ++value )
|
||||
*out++ = value;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BOOST_ALGORITHM_IS_PARTITIONED_HPP
|
||||
#define BOOST_ALGORITHM_IS_PARTITIONED_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -26,7 +27,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p The predicate to test the values with
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template <typename InputIterator, typename UnaryPredicate>
|
||||
bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p )
|
||||
{
|
||||
// Run through the part that satisfy the predicate
|
||||
for ( ; first != last; ++first )
|
||||
@ -47,7 +48,7 @@ bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p
|
||||
/// \param p The predicate to test the values with
|
||||
///
|
||||
template <typename Range, typename UnaryPredicate>
|
||||
bool is_partitioned ( const Range &r, UnaryPredicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool is_partitioned ( const Range &r, UnaryPredicate p )
|
||||
{
|
||||
return boost::algorithm::is_partitioned (boost::begin(r), boost::end(r), p);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <functional> // for std::equal_to
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -34,7 +35,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A binary predicate that returns true if two elements are ordered.
|
||||
///
|
||||
template <typename ForwardIterator, typename Pred>
|
||||
ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p )
|
||||
BOOST_CXX14_CONSTEXPR ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last, Pred p )
|
||||
{
|
||||
if ( first == last ) return last; // the empty sequence is ordered
|
||||
ForwardIterator next = first;
|
||||
@ -54,7 +55,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param last One past the end of the sequence
|
||||
///
|
||||
template <typename ForwardIterator>
|
||||
ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last )
|
||||
BOOST_CXX14_CONSTEXPR ForwardIterator is_sorted_until ( ForwardIterator first, ForwardIterator last )
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
|
||||
return boost::algorithm::is_sorted_until ( first, last, std::less<value_type>());
|
||||
@ -69,7 +70,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A binary predicate that returns true if two elements are ordered.
|
||||
///
|
||||
template <typename ForwardIterator, typename Pred>
|
||||
bool is_sorted ( ForwardIterator first, ForwardIterator last, Pred p )
|
||||
BOOST_CXX14_CONSTEXPR bool is_sorted ( ForwardIterator first, ForwardIterator last, Pred p )
|
||||
{
|
||||
return boost::algorithm::is_sorted_until (first, last, p) == last;
|
||||
}
|
||||
@ -81,7 +82,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param last One past the end of the sequence
|
||||
///
|
||||
template <typename ForwardIterator>
|
||||
bool is_sorted ( ForwardIterator first, ForwardIterator last )
|
||||
BOOST_CXX14_CONSTEXPR bool is_sorted ( ForwardIterator first, ForwardIterator last )
|
||||
{
|
||||
return boost::algorithm::is_sorted_until (first, last) == last;
|
||||
}
|
||||
@ -98,7 +99,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A binary predicate that returns true if two elements are ordered.
|
||||
///
|
||||
template <typename R, typename Pred>
|
||||
typename boost::lazy_disable_if_c<
|
||||
BOOST_CXX14_CONSTEXPR typename boost::lazy_disable_if_c<
|
||||
boost::is_same<R, Pred>::value,
|
||||
typename boost::range_iterator<const R>
|
||||
>::type is_sorted_until ( const R &range, Pred p )
|
||||
@ -113,7 +114,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param range The range to be tested.
|
||||
///
|
||||
template <typename R>
|
||||
typename boost::range_iterator<const R>::type is_sorted_until ( const R &range )
|
||||
BOOST_CXX14_CONSTEXPR typename boost::range_iterator<const R>::type is_sorted_until ( const R &range )
|
||||
{
|
||||
return boost::algorithm::is_sorted_until ( boost::begin ( range ), boost::end ( range ));
|
||||
}
|
||||
@ -126,7 +127,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A binary predicate that returns true if two elements are ordered.
|
||||
///
|
||||
template <typename R, typename Pred>
|
||||
typename boost::lazy_disable_if_c< boost::is_same<R, Pred>::value, boost::mpl::identity<bool> >::type
|
||||
BOOST_CXX14_CONSTEXPR typename boost::lazy_disable_if_c< boost::is_same<R, Pred>::value, boost::mpl::identity<bool> >::type
|
||||
is_sorted ( const R &range, Pred p )
|
||||
{
|
||||
return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range ), p );
|
||||
@ -139,7 +140,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param range The range to be tested.
|
||||
///
|
||||
template <typename R>
|
||||
bool is_sorted ( const R &range )
|
||||
BOOST_CXX14_CONSTEXPR bool is_sorted ( const R &range )
|
||||
{
|
||||
return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range ));
|
||||
}
|
||||
@ -159,7 +160,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return true for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_strictly_increasing instead.
|
||||
template <typename ForwardIterator>
|
||||
bool is_increasing ( ForwardIterator first, ForwardIterator last )
|
||||
BOOST_CXX14_CONSTEXPR bool is_increasing ( ForwardIterator first, ForwardIterator last )
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
|
||||
return boost::algorithm::is_sorted (first, last, std::less<value_type>());
|
||||
@ -175,7 +176,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return true for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_strictly_increasing instead.
|
||||
template <typename R>
|
||||
bool is_increasing ( const R &range )
|
||||
BOOST_CXX14_CONSTEXPR bool is_increasing ( const R &range )
|
||||
{
|
||||
return is_increasing ( boost::begin ( range ), boost::end ( range ));
|
||||
}
|
||||
@ -192,7 +193,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return true for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_strictly_decreasing instead.
|
||||
template <typename ForwardIterator>
|
||||
bool is_decreasing ( ForwardIterator first, ForwardIterator last )
|
||||
BOOST_CXX14_CONSTEXPR bool is_decreasing ( ForwardIterator first, ForwardIterator last )
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
|
||||
return boost::algorithm::is_sorted (first, last, std::greater<value_type>());
|
||||
@ -207,7 +208,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return true for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_strictly_decreasing instead.
|
||||
template <typename R>
|
||||
bool is_decreasing ( const R &range )
|
||||
BOOST_CXX14_CONSTEXPR bool is_decreasing ( const R &range )
|
||||
{
|
||||
return is_decreasing ( boost::begin ( range ), boost::end ( range ));
|
||||
}
|
||||
@ -224,7 +225,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return false for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_increasing instead.
|
||||
template <typename ForwardIterator>
|
||||
bool is_strictly_increasing ( ForwardIterator first, ForwardIterator last )
|
||||
BOOST_CXX14_CONSTEXPR bool is_strictly_increasing ( ForwardIterator first, ForwardIterator last )
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
|
||||
return boost::algorithm::is_sorted (first, last, std::less_equal<value_type>());
|
||||
@ -239,7 +240,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return false for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_increasing instead.
|
||||
template <typename R>
|
||||
bool is_strictly_increasing ( const R &range )
|
||||
BOOST_CXX14_CONSTEXPR bool is_strictly_increasing ( const R &range )
|
||||
{
|
||||
return is_strictly_increasing ( boost::begin ( range ), boost::end ( range ));
|
||||
}
|
||||
@ -255,7 +256,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return false for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_decreasing instead.
|
||||
template <typename ForwardIterator>
|
||||
bool is_strictly_decreasing ( ForwardIterator first, ForwardIterator last )
|
||||
BOOST_CXX14_CONSTEXPR bool is_strictly_decreasing ( ForwardIterator first, ForwardIterator last )
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
|
||||
return boost::algorithm::is_sorted (first, last, std::greater_equal<value_type>());
|
||||
@ -270,7 +271,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function will return false for sequences that contain items that compare
|
||||
/// equal. If that is not what you intended, you should use is_decreasing instead.
|
||||
template <typename R>
|
||||
bool is_strictly_decreasing ( const R &range )
|
||||
BOOST_CXX14_CONSTEXPR bool is_strictly_decreasing ( const R &range )
|
||||
{
|
||||
return is_strictly_decreasing ( boost::begin ( range ), boost::end ( range ));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BOOST_ALGORITHM_NONE_OF_HPP
|
||||
#define BOOST_ALGORITHM_NONE_OF_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -26,7 +27,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A predicate for testing the elements of the sequence
|
||||
///
|
||||
template<typename InputIterator, typename Predicate>
|
||||
bool none_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool none_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( p(*first))
|
||||
@ -42,7 +43,7 @@ bool none_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename Predicate>
|
||||
bool none_of ( const Range &r, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool none_of ( const Range &r, Predicate p )
|
||||
{
|
||||
return boost::algorithm::none_of (boost::begin (r), boost::end (r), p );
|
||||
}
|
||||
@ -56,7 +57,7 @@ bool none_of ( const Range &r, Predicate p )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename InputIterator, typename V>
|
||||
bool none_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
BOOST_CXX14_CONSTEXPR bool none_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( val == *first )
|
||||
@ -72,7 +73,7 @@ bool none_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename Range, typename V>
|
||||
bool none_of_equal ( const Range &r, const V & val )
|
||||
BOOST_CXX14_CONSTEXPR bool none_of_equal ( const Range &r, const V & val )
|
||||
{
|
||||
return boost::algorithm::none_of_equal (boost::begin (r), boost::end (r), val);
|
||||
}
|
||||
|
@ -12,12 +12,13 @@
|
||||
#ifndef BOOST_ALGORITHM_ONE_OF_HPP
|
||||
#define BOOST_ALGORITHM_ONE_OF_HPP
|
||||
|
||||
#include <algorithm> // for std::find and std::find_if
|
||||
#include <boost/algorithm/cxx11/none_of.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/algorithm/cxx11/none_of.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
/// \fn one_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
@ -28,12 +29,16 @@ namespace boost { namespace algorithm {
|
||||
/// \param p A predicate for testing the elements of the sequence
|
||||
///
|
||||
template<typename InputIterator, typename Predicate>
|
||||
bool one_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool one_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
{
|
||||
InputIterator i = std::find_if (first, last, p);
|
||||
if (i == last)
|
||||
// find_if
|
||||
for (; first != last; ++first)
|
||||
if (p(*first))
|
||||
break;
|
||||
|
||||
if (first == last)
|
||||
return false; // Didn't occur at all
|
||||
return boost::algorithm::none_of (++i, last, p);
|
||||
return boost::algorithm::none_of (++first, last, p);
|
||||
}
|
||||
|
||||
/// \fn one_of ( const Range &r, Predicate p )
|
||||
@ -43,7 +48,7 @@ bool one_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename Predicate>
|
||||
bool one_of ( const Range &r, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool one_of ( const Range &r, Predicate p )
|
||||
{
|
||||
return boost::algorithm::one_of ( boost::begin (r), boost::end (r), p );
|
||||
}
|
||||
@ -57,12 +62,16 @@ bool one_of ( const Range &r, Predicate p )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename InputIterator, typename V>
|
||||
bool one_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
BOOST_CXX14_CONSTEXPR bool one_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
{
|
||||
InputIterator i = std::find (first, last, val); // find first occurrence of 'val'
|
||||
if (i == last)
|
||||
// find
|
||||
for (; first != last; ++first)
|
||||
if (*first == val)
|
||||
break;
|
||||
|
||||
if (first == last)
|
||||
return false; // Didn't occur at all
|
||||
return boost::algorithm::none_of_equal (++i, last, val);
|
||||
return boost::algorithm::none_of_equal (++first, last, val);
|
||||
}
|
||||
|
||||
/// \fn one_of_equal ( const Range &r, const V &val )
|
||||
@ -72,7 +81,7 @@ bool one_of_equal ( InputIterator first, InputIterator last, const V &val )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename Range, typename V>
|
||||
bool one_of_equal ( const Range &r, const V &val )
|
||||
BOOST_CXX14_CONSTEXPR bool one_of_equal ( const Range &r, const V &val )
|
||||
{
|
||||
return boost::algorithm::one_of_equal ( boost::begin (r), boost::end (r), val );
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <utility> // for std::pair
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
@ -35,7 +36,7 @@ namespace boost { namespace algorithm {
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template <typename InputIterator,
|
||||
typename OutputIterator1, typename OutputIterator2, typename UnaryPredicate>
|
||||
std::pair<OutputIterator1, OutputIterator2>
|
||||
BOOST_CXX14_CONSTEXPR std::pair<OutputIterator1, OutputIterator2>
|
||||
partition_copy ( InputIterator first, InputIterator last,
|
||||
OutputIterator1 out_true, OutputIterator2 out_false, UnaryPredicate p )
|
||||
{
|
||||
@ -57,7 +58,7 @@ partition_copy ( InputIterator first, InputIterator last,
|
||||
///
|
||||
template <typename Range, typename OutputIterator1, typename OutputIterator2,
|
||||
typename UnaryPredicate>
|
||||
std::pair<OutputIterator1, OutputIterator2>
|
||||
BOOST_CXX14_CONSTEXPR std::pair<OutputIterator1, OutputIterator2>
|
||||
partition_copy ( const Range &r, OutputIterator1 out_true, OutputIterator2 out_false,
|
||||
UnaryPredicate p )
|
||||
{
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <iterator> // for std::distance, advance
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
|
@ -12,19 +12,21 @@
|
||||
#ifndef BOOST_ALGORITHM_EQUAL_HPP
|
||||
#define BOOST_ALGORITHM_EQUAL_HPP
|
||||
|
||||
#include <algorithm> // for std::equal
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class T1, class T2>
|
||||
struct eq {
|
||||
bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
|
||||
BOOST_CONSTEXPR bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
|
||||
};
|
||||
|
||||
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
||||
RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
|
||||
std::random_access_iterator_tag, std::random_access_iterator_tag )
|
||||
@ -32,11 +34,16 @@ namespace detail {
|
||||
// Random-access iterators let is check the sizes in constant time
|
||||
if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 ))
|
||||
return false;
|
||||
// If we know that the sequences are the same size, the original version is fine
|
||||
return std::equal ( first1, last1, first2, pred );
|
||||
|
||||
// std::equal
|
||||
for (; first1 != last1; ++first1, ++first2)
|
||||
if (!pred(*first1, *first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred,
|
||||
std::input_iterator_tag, std::input_iterator_tag )
|
||||
@ -60,6 +67,7 @@ namespace detail {
|
||||
/// \param last2 One past the end of the second range.
|
||||
/// \param pred A predicate for comparing the elements of the ranges
|
||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred )
|
||||
{
|
||||
@ -78,6 +86,7 @@ bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||
/// \param first2 The start of the second range.
|
||||
/// \param last2 One past the end of the second range.
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
bool equal ( InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2 )
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <functional> // for std::equal_to
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/algorithm/cxx11/is_permutation.hpp>
|
||||
#include <boost/algorithm/cxx14/mismatch.hpp>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2008-2012.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file mismatch.hpp
|
||||
@ -14,6 +14,8 @@
|
||||
|
||||
#include <utility> // for std::pair
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
|
||||
@ -27,7 +29,7 @@ namespace boost { namespace algorithm {
|
||||
/// \param last2 One past the end of the second range.
|
||||
/// \param pred A predicate for comparing the elements of the ranges
|
||||
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
|
||||
std::pair<InputIterator1, InputIterator2> mismatch (
|
||||
BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch (
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
BinaryPredicate pred )
|
||||
@ -47,7 +49,7 @@ std::pair<InputIterator1, InputIterator2> mismatch (
|
||||
/// \param first2 The start of the second range.
|
||||
/// \param last2 One past the end of the second range.
|
||||
template <class InputIterator1, class InputIterator2>
|
||||
std::pair<InputIterator1, InputIterator2> mismatch (
|
||||
BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch (
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2 )
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file exclusive_scan.hpp
|
||||
@ -15,6 +15,7 @@
|
||||
#include <functional> // for std::plus
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@ -44,7 +45,7 @@ OutputIterator exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type VT;
|
||||
return exclusive_scan(first, last, result, init, std::plus<VT>());
|
||||
return boost::algorithm::exclusive_scan(first, last, result, init, std::plus<VT>());
|
||||
}
|
||||
|
||||
}} // namespace boost and algorithm
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file for_each_n.hpp
|
||||
@ -14,6 +14,8 @@
|
||||
|
||||
#include <utility> // for std::pair
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
/// \fn for_each_n(InputIterator first, Size n, Function f);
|
||||
|
@ -2,19 +2,20 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file transform_reduce.hpp
|
||||
/// \brief Combine the (transformed) elements of a sequence (or two) into a single value.
|
||||
/// \author Marshall Clow
|
||||
|
||||
#ifndef BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP
|
||||
#define BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP
|
||||
#ifndef BOOST_ALGORITHM_INCLUSIVE_SCAN_HPP
|
||||
#define BOOST_ALGORITHM_INCLUSIVE_SCAN_HPP
|
||||
|
||||
#include <functional> // for std::plus
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@ -41,7 +42,7 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last,
|
||||
typename std::iterator_traits<InputIterator>::value_type init = *first;
|
||||
*result++ = init;
|
||||
if (++first != last)
|
||||
return inclusive_scan(first, last, result, bOp, init);
|
||||
return boost::algorithm::inclusive_scan(first, last, result, bOp, init);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -52,9 +53,9 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type VT;
|
||||
return inclusive_scan(first, last, result, std::plus<VT>());
|
||||
return boost::algorithm::inclusive_scan(first, last, result, std::plus<VT>());
|
||||
}
|
||||
|
||||
}} // namespace boost and algorithm
|
||||
|
||||
#endif // BOOST_ALGORITHM_TRANSFORM_REDUCE_HPP
|
||||
#endif // BOOST_ALGORITHM_INCLUSIVE_SCAN_HPP
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file reduce.hpp
|
||||
@ -15,6 +15,7 @@
|
||||
#include <functional> // for std::plus
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@ -34,14 +35,14 @@ template<class InputIterator, class T>
|
||||
T reduce(InputIterator first, InputIterator last, T init)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type VT;
|
||||
return reduce(first, last, init, std::plus<VT>());
|
||||
return boost::algorithm::reduce(first, last, init, std::plus<VT>());
|
||||
}
|
||||
|
||||
template<class InputIterator>
|
||||
typename std::iterator_traits<InputIterator>::value_type
|
||||
reduce(InputIterator first, InputIterator last)
|
||||
{
|
||||
return reduce(first, last,
|
||||
return boost::algorithm::reduce(first, last,
|
||||
typename std::iterator_traits<InputIterator>::value_type());
|
||||
}
|
||||
|
||||
@ -49,14 +50,14 @@ template<class Range>
|
||||
typename boost::range_value<Range>::type
|
||||
reduce(const Range &r)
|
||||
{
|
||||
return reduce(boost::begin(r), boost::end(r));
|
||||
return boost::algorithm::reduce(boost::begin(r), boost::end(r));
|
||||
}
|
||||
|
||||
// Not sure that this won't be ambiguous (1)
|
||||
template<class Range, class T>
|
||||
T reduce(const Range &r, T init)
|
||||
{
|
||||
return reduce(boost::begin (r), boost::end (r), init);
|
||||
return boost::algorithm::reduce(boost::begin (r), boost::end (r), init);
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +65,7 @@ T reduce(const Range &r, T init)
|
||||
template<class Range, class T, class BinaryOperation>
|
||||
T reduce(const Range &r, T init, BinaryOperation bOp)
|
||||
{
|
||||
return reduce(boost::begin(r), boost::end(r), init, bOp);
|
||||
return boost::algorithm::reduce(boost::begin(r), boost::end(r), init, bOp);
|
||||
}
|
||||
|
||||
}} // namespace boost and algorithm
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file transform_exclusive_scan.hpp
|
||||
@ -15,6 +15,7 @@
|
||||
#include <functional> // for std::plus
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file transform_reduce.hpp
|
||||
@ -15,6 +15,7 @@
|
||||
#include <functional> // for std::plus
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@ -46,7 +47,8 @@ OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
typename std::iterator_traits<InputIterator>::value_type init = uOp(*first);
|
||||
*result++ = init;
|
||||
if (++first != last)
|
||||
return transform_inclusive_scan(first, last, result, bOp, uOp, init);
|
||||
return boost::algorithm::transform_inclusive_scan
|
||||
(first, last, result, bOp, uOp, init);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -2,7 +2,7 @@
|
||||
Copyright (c) Marshall Clow 2017.
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/// \file transform_reduce.hpp
|
||||
@ -15,6 +15,7 @@
|
||||
#include <functional> // for std::plus
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@ -46,7 +47,7 @@ template<class InputIterator1, class InputIterator2, class T>
|
||||
T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init)
|
||||
{
|
||||
return transform_reduce(first1, last1, first2, init,
|
||||
return boost::algorithm::transform_reduce(first1, last1, first2, init,
|
||||
std::plus<T>(), std::multiplies<T>());
|
||||
}
|
||||
|
||||
|
96
boost/algorithm/find_backward.hpp
Normal file
96
boost/algorithm/find_backward.hpp
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (c) T. Zachary Laine 2018.
|
||||
|
||||
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)
|
||||
*/
|
||||
#ifndef BOOST_ALGORITHM_FIND_BACKWARD_HPP
|
||||
#define BOOST_ALGORITHM_FIND_BACKWARD_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
template<typename BidiIter, typename T>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
BidiIter find_backward(BidiIter first, BidiIter last, const T & x)
|
||||
{
|
||||
BidiIter it = last;
|
||||
while (it != first) {
|
||||
if (*--it == x)
|
||||
return it;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
template<typename Range, typename T>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
typename boost::range_iterator<Range>::type find_backward(Range & range, const T & x)
|
||||
{
|
||||
return ::boost::algorithm::find_backward(boost::begin(range), boost::end(range), x);
|
||||
}
|
||||
|
||||
template<typename BidiIter, typename T>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
BidiIter find_not_backward(BidiIter first, BidiIter last, const T & x)
|
||||
{
|
||||
BidiIter it = last;
|
||||
while (it != first) {
|
||||
if (*--it != x)
|
||||
return it;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
template<typename Range, typename T>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
typename boost::range_iterator<Range>::type find_not_backward(Range & range, const T & x)
|
||||
{
|
||||
return ::boost::algorithm::find_not_backward(boost::begin(range), boost::end(range), x);
|
||||
}
|
||||
|
||||
template<typename BidiIter, typename Pred>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p)
|
||||
{
|
||||
BidiIter it = last;
|
||||
while (it != first) {
|
||||
if (p(*--it))
|
||||
return it;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
template<typename Range, typename Pred>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
typename boost::range_iterator<Range>::type find_if_backward(Range & range, Pred p)
|
||||
{
|
||||
return ::boost::algorithm::find_if_backward(boost::begin(range), boost::end(range), p);
|
||||
}
|
||||
|
||||
template<typename BidiIter, typename Pred>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p)
|
||||
{
|
||||
BidiIter it = last;
|
||||
while (it != first) {
|
||||
if (!p(*--it))
|
||||
return it;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
template<typename Range, typename Pred>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
typename boost::range_iterator<Range>::type find_if_not_backward(Range & range, Pred p)
|
||||
{
|
||||
return ::boost::algorithm::find_if_not_backward(boost::begin(range), boost::end(range), p);
|
||||
}
|
||||
|
||||
}} // namespace boost and algorithm
|
||||
|
||||
#endif // BOOST_ALGORITHM_FIND_BACKWARD_HPP
|
38
boost/algorithm/find_not.hpp
Normal file
38
boost/algorithm/find_not.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) T. Zachary Laine 2018.
|
||||
|
||||
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)
|
||||
*/
|
||||
#ifndef BOOST_ALGORITHM_FIND_NOT_HPP
|
||||
#define BOOST_ALGORITHM_FIND_NOT_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost { namespace algorithm {
|
||||
|
||||
template<typename InputIter, typename Sentinel, typename T>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
InputIter find_not(InputIter first, Sentinel last, const T & x)
|
||||
{
|
||||
for (; first != last; ++first) {
|
||||
if (*first != x)
|
||||
break;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
template<typename Range, typename T>
|
||||
BOOST_CXX14_CONSTEXPR
|
||||
typename boost::range_iterator<Range>::type find_not(Range & r, const T & x)
|
||||
{
|
||||
return ::boost::algorithm::find_not(boost::begin(r), boost::end(r), x);
|
||||
}
|
||||
|
||||
}} // namespace boost and algorithm
|
||||
|
||||
#endif // BOOST_ALGORITHM_FIND_NOT_HPP
|
@ -22,8 +22,10 @@
|
||||
|
||||
#include <algorithm> // for std::stable_partition
|
||||
#include <functional>
|
||||
#include <utility> // for std::make_pair
|
||||
|
||||
#include <boost/bind.hpp> // for boost::bind
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/bind/bind.hpp> // for boost::bind
|
||||
#include <boost/range/begin.hpp> // for boost::begin(range)
|
||||
#include <boost/range/end.hpp> // for boost::end(range)
|
||||
|
||||
@ -80,13 +82,14 @@ namespace boost { namespace algorithm {
|
||||
*/
|
||||
|
||||
template <
|
||||
typename BidirectionalIterator, // Iter models BidirectionalIterator
|
||||
typename Pred> // Pred models UnaryPredicate
|
||||
typename BidirectionalIterator, // models BidirectionalIterator
|
||||
typename Pred> // models UnaryPredicate
|
||||
std::pair<BidirectionalIterator, BidirectionalIterator> gather
|
||||
( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred )
|
||||
{
|
||||
// The first call partitions everything up to (but not including) the pivot element,
|
||||
// while the second call partitions the rest of the sequence.
|
||||
using namespace boost::placeholders;
|
||||
return std::make_pair (
|
||||
std::stable_partition ( first, pivot, !boost::bind<bool> ( pred, _1 )),
|
||||
std::stable_partition ( pivot, last, boost::bind<bool> ( pred, _1 )));
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <iterator> // for std::iterator_traits
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/exception/exception.hpp>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <functional>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP
|
||||
#define BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <utility> // for std::pair and std::make_pair
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { // for obtaining a uniform version of minmax_element
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <vector>
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <iterator> // For std::iterator_traits
|
||||
#include <algorithm> // For nth_element and partial_sort
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace boost {
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
#if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)==std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper<T1>(Arg1,m_Loc)==std::toupper<T2>(Arg2,m_Loc);
|
||||
@ -118,7 +118,7 @@ namespace boost {
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
#if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)<std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper<T1>(Arg1,m_Loc)<std::toupper<T2>(Arg2,m_Loc);
|
||||
@ -171,7 +171,7 @@ namespace boost {
|
||||
template< typename T1, typename T2 >
|
||||
bool operator()( const T1& Arg1, const T2& Arg2 ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
#if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper(Arg1)<=std::toupper(Arg2);
|
||||
#else
|
||||
return std::toupper<T1>(Arg1,m_Loc)<=std::toupper<T2>(Arg2,m_Loc);
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include <locale>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -40,7 +43,7 @@ namespace boost {
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
#if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
|
||||
#else
|
||||
return std::tolower<CharT>( Ch, *m_Loc );
|
||||
@ -62,7 +65,7 @@ namespace boost {
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
#if defined(BOOST_BORLANDC) && (BOOST_BORLANDC >= 0x560) && (BOOST_BORLANDC <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
|
||||
#else
|
||||
return std::toupper<CharT>( Ch, *m_Loc );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user