[boost] Updated headers to 1.56

This commit is contained in:
Alex Zolotarev 2014-09-06 23:24:20 -07:00 committed by Alex Zolotarev
parent 3e05e9dc86
commit 216e231fc9
5766 changed files with 200088 additions and 116702 deletions

View file

@ -11,6 +11,7 @@
#include <boost/config.hpp>
#include <boost/mpl/apply_fwd.hpp> // for mpl::na
#include <boost/mpl/limits/vector.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>

View file

@ -245,14 +245,14 @@ namespace boost { namespace numeric
};
template<typename Left, typename Right, typename EnableIf>
struct average_base
struct fdiv_base
: functional::divides<Left, Right>
{};
// partial specialization that promotes the arguments to double for
// integral division.
template<typename Left, typename Right>
struct average_base<Left, Right, typename enable_if<are_integral<Left, Right> >::type>
struct fdiv_base<Left, Right, typename enable_if<are_integral<Left, Right> >::type>
: functional::divides<double const, double const>
{};
@ -347,9 +347,16 @@ namespace boost { namespace numeric
: max_assign_base<Left, Right, void>
{};
template<typename Left, typename Right, typename LeftTag, typename RightTag>
struct fdiv
: fdiv_base<Left, Right, void>
{};
/// INTERNAL ONLY
/// For back-compat only. Use fdiv.
template<typename Left, typename Right, typename LeftTag, typename RightTag>
struct average
: average_base<Left, Right, void>
: fdiv<Left, Right, LeftTag, RightTag>
{};
template<typename Arg, typename Tag>
@ -388,8 +395,13 @@ namespace boost { namespace numeric
: boost::detail::function2<functional::max_assign<_1, _2, functional::tag<_1>, functional::tag<_2> > >
{};
struct fdiv
: boost::detail::function2<functional::fdiv<_1, _2, functional::tag<_1>, functional::tag<_2> > >
{};
/// INTERNAL ONLY
struct average
: boost::detail::function2<functional::average<_1, _2, functional::tag<_1>, functional::tag<_2> > >
: boost::detail::function2<functional::fdiv<_1, _2, functional::tag<_1>, functional::tag<_2> > >
{};
struct as_min
@ -413,7 +425,8 @@ namespace boost { namespace numeric
{
op::min_assign const &min_assign = boost::detail::pod_singleton<op::min_assign>::instance;
op::max_assign const &max_assign = boost::detail::pod_singleton<op::max_assign>::instance;
op::average const &average = boost::detail::pod_singleton<op::average>::instance;
op::fdiv const &fdiv = boost::detail::pod_singleton<op::fdiv>::instance;
op::fdiv const &average = boost::detail::pod_singleton<op::fdiv>::instance; ///< INTERNAL ONLY
op::as_min const &as_min = boost::detail::pod_singleton<op::as_min>::instance;
op::as_max const &as_max = boost::detail::pod_singleton<op::as_max>::instance;
op::as_zero const &as_zero = boost::detail::pod_singleton<op::as_zero>::instance;
@ -421,6 +434,7 @@ namespace boost { namespace numeric
BOOST_ACCUMULATORS_IGNORE_GLOBAL(min_assign)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(max_assign)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(fdiv)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(average)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_min)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_max)

View file

@ -234,9 +234,9 @@ namespace boost { namespace numeric
}
};
// partial specialization of numeric::average<> for std::valarray.
// partial specialization of numeric::fdiv<> for std::valarray.
template<typename Left, typename Right, typename RightTag>
struct average<Left, Right, std_valarray_tag, RightTag>
struct fdiv<Left, Right, std_valarray_tag, RightTag>
: mpl::if_<
are_integral<typename Left::value_type, Right>
, divides<Left, double const>

View file

@ -231,7 +231,7 @@ namespace boost { namespace numeric
// partial specialization for std::vector.
template<typename Left, typename Right>
struct average<Left, Right, std_vector_tag, void>
struct fdiv<Left, Right, std_vector_tag, void>
: mpl::if_<
are_integral<typename Left::value_type, Right>
, divides<Left, double const>

View file

@ -141,7 +141,7 @@ namespace boost { namespace numeric
template<typename Left, typename Right, typename EnableIf = void>
struct max_assign_base;
template<typename Left, typename Right, typename EnableIf = void>
struct average_base;
struct fdiv_base;
template<typename Arg, typename EnableIf = void>
struct as_min_base;
template<typename Arg, typename EnableIf = void>
@ -158,7 +158,7 @@ namespace boost { namespace numeric
template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
struct max_assign;
template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type>
struct average;
struct fdiv;
template<typename Arg, typename Tag = typename tag<Arg>::type>
struct as_min;
template<typename Arg, typename Tag = typename tag<Arg>::type>
@ -175,7 +175,7 @@ namespace boost { namespace numeric
struct promote;
struct min_assign;
struct max_assign;
struct average;
struct fdiv;
struct as_min;
struct as_max;
struct as_zero;
@ -186,7 +186,7 @@ namespace boost { namespace numeric
{
extern op::min_assign const &min_assign;
extern op::max_assign const &max_assign;
extern op::average const &average;
extern op::fdiv const &fdiv;
extern op::as_min const &as_min;
extern op::as_max const &as_max;
extern op::as_zero const &as_zero;

View file

@ -122,8 +122,8 @@ namespace impl
struct covariance_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type sample_type;
typedef typename numeric::functional::average<VariateType, std::size_t>::result_type variate_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type sample_type;
typedef typename numeric::functional::fdiv<VariateType, std::size_t>::result_type variate_type;
// for boost::result_of
typedef typename numeric::functional::outer_product<sample_type, variate_type>::result_type result_type;
@ -131,8 +131,8 @@ namespace impl
covariance_impl(Args const &args)
: cov_(
numeric::outer_product(
numeric::average(args[sample | Sample()], (std::size_t)1)
, numeric::average(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1)
numeric::fdiv(args[sample | Sample()], (std::size_t)1)
, numeric::fdiv(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1)
)
)
{

View file

@ -61,7 +61,7 @@ namespace impl
struct density_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef std::vector<float_type> array_type;
// for boost::result_of
@ -77,8 +77,8 @@ namespace impl
, histogram(
num_bins + 2
, std::make_pair(
numeric::average(args[sample | Sample()],(std::size_t)1)
, numeric::average(args[sample | Sample()],(std::size_t)1)
numeric::fdiv(args[sample | Sample()],(std::size_t)1)
, numeric::fdiv(args[sample | Sample()],(std::size_t)1)
)
)
, is_dirty(true)
@ -103,9 +103,9 @@ namespace impl
// Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin).
if (cnt == this->cache_size)
{
float_type minimum = numeric::average((min)(args), (std::size_t)1);
float_type maximum = numeric::average((max)(args), (std::size_t)1);
float_type bin_size = numeric::average(maximum - minimum, this->num_bins );
float_type minimum = numeric::fdiv((min)(args), (std::size_t)1);
float_type maximum = numeric::fdiv((max)(args), (std::size_t)1);
float_type bin_size = numeric::fdiv(maximum - minimum, this->num_bins );
// determine bin positions (their lower bounds)
for (std::size_t i = 0; i < this->num_bins + 2; ++i)
@ -177,7 +177,7 @@ namespace impl
for (std::size_t i = 0; i < this->num_bins + 2; ++i)
{
this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::average(this->samples_in_bin[i], count(args)));
this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::fdiv(this->samples_in_bin[i], count(args)));
}
}
// returns a range of pairs

View file

@ -29,7 +29,7 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
error_of_mean_impl(dont_care) {}
@ -38,7 +38,7 @@ namespace impl
{
using namespace std;
extractor<Variance> const variance = {};
return sqrt(numeric::average(variance(args), count(args) - 1));
return sqrt(numeric::fdiv(variance(args), count(args) - 1));
}
};

View file

@ -69,7 +69,7 @@ namespace impl
struct extended_p_square_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<float_type> array_type;
// for boost::result_of
typedef iterator_range<

View file

@ -57,7 +57,7 @@ namespace impl
struct extended_p_square_quantile_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<float_type> array_type;
typedef iterator_range<
detail::lvalue_index_iterator<
@ -137,7 +137,7 @@ namespace impl
float_type h1 = *iter_heights;
float_type h0 = *(iter_heights - 1);
float_type a = numeric::average(h1 - h0, p1 - p0);
float_type a = numeric::fdiv(h1 - h0, p1 - p0);
float_type b = h1 - p1 * a;
res = a * this->probability + b;
@ -169,12 +169,12 @@ namespace impl
h2 = *iter_heights;
}
float_type hp21 = numeric::average(h2 - h1, p2 - p1);
float_type hp10 = numeric::average(h1 - h0, p1 - p0);
float_type p21 = numeric::average(p2 * p2 - p1 * p1, p2 - p1);
float_type p10 = numeric::average(p1 * p1 - p0 * p0, p1 - p0);
float_type hp21 = numeric::fdiv(h2 - h1, p2 - p1);
float_type hp10 = numeric::fdiv(h1 - h0, p1 - p0);
float_type p21 = numeric::fdiv(p2 * p2 - p1 * p1, p2 - p1);
float_type p10 = numeric::fdiv(p1 * p1 - p0 * p0, p1 - p0);
float_type a = numeric::average(hp21 - hp10, p21 - p10);
float_type a = numeric::fdiv(hp21 - hp10, p21 - p10);
float_type b = hp21 - a * p21;
float_type c = h2 - a * p2 * p2 - b * p2;

View file

@ -47,14 +47,14 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, Sample>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, Sample>::result_type result_type;
kurtosis_impl(dont_care) {}
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(
return numeric::fdiv(
accumulators::moment<4>(args)
- 4. * accumulators::moment<3>(args) * mean(args)
+ 6. * accumulators::moment<2>(args) * mean(args) * mean(args)

View file

@ -31,7 +31,7 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
mean_impl(dont_care) {}
@ -39,7 +39,7 @@ namespace impl
result_type result(Args const &args) const
{
extractor<SumFeature> sum;
return numeric::average(sum(args), count(args));
return numeric::fdiv(sum(args), count(args));
}
};
@ -48,11 +48,11 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
template<typename Args>
immediate_mean_impl(Args const &args)
: mean(numeric::average(args[sample | Sample()], numeric::one<std::size_t>::value))
: mean(numeric::fdiv(args[sample | Sample()], numeric::one<std::size_t>::value))
{
}
@ -60,7 +60,7 @@ namespace impl
void operator ()(Args const &args)
{
std::size_t cnt = count(args);
this->mean = numeric::average(
this->mean = numeric::fdiv(
(this->mean * (cnt - 1)) + args[parameter::keyword<Tag>::get()]
, cnt
);

View file

@ -39,7 +39,7 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
median_impl(dont_care) {}
@ -63,7 +63,7 @@ namespace impl
struct with_density_median_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef iterator_range<typename histogram_type::iterator> range_type;
// for boost::result_of
@ -71,7 +71,7 @@ namespace impl
template<typename Args>
with_density_median_impl(Args const &args)
: sum(numeric::average(args[sample | Sample()], (std::size_t)1))
: sum(numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, is_dirty(true)
{
}
@ -98,7 +98,7 @@ namespace impl
++it;
}
--it;
float_type over = numeric::average(this->sum - 0.5 * cnt, it->second * cnt);
float_type over = numeric::fdiv(this->sum - 0.5 * cnt, it->second * cnt);
this->median = it->first * over + (it + 1)->first * (1. - over);
}
@ -125,7 +125,7 @@ namespace impl
struct with_p_square_cumulative_distribution_median_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef iterator_range<typename histogram_type::iterator> range_type;
// for boost::result_of
@ -154,7 +154,7 @@ namespace impl
{
++it;
}
float_type over = numeric::average(it->second - 0.5, it->second - (it - 1)->second);
float_type over = numeric::fdiv(it->second - 0.5, it->second - (it - 1)->second);
this->median = it->first * over + (it + 1)->first * ( 1. - over );
}

View file

@ -55,7 +55,7 @@ namespace impl
{
BOOST_MPL_ASSERT_RELATION(N::value, >, 0);
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
template<typename Args>
moment_impl(Args const &args)
@ -72,7 +72,7 @@ namespace impl
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(this->sum, count(args));
return numeric::fdiv(this->sum, count(args));
}
private:

View file

@ -54,7 +54,7 @@ namespace impl
struct p_square_cumulative_distribution_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<float_type> array_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
// for boost::result_of
@ -76,7 +76,7 @@ namespace impl
{
this->actual_positions[i] = i + 1.;
this->desired_positions[i] = i + 1.;
this->positions_increments[i] = numeric::average(i, b);
this->positions_increments[i] = numeric::fdiv(i, b);
}
}
@ -198,7 +198,7 @@ namespace impl
for (std::size_t i = 0; i < this->histogram.size(); ++i)
{
this->histogram[i] = std::make_pair(this->heights[i], numeric::average(this->actual_positions[i], cnt));
this->histogram[i] = std::make_pair(this->heights[i], numeric::fdiv(this->actual_positions[i], cnt));
}
}
//return histogram;

View file

@ -54,7 +54,7 @@ namespace impl
struct p_square_quantile_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef array<float_type, 5> array_type;
// for boost::result_of
typedef float_type result_type;
@ -69,7 +69,7 @@ namespace impl
{
for(std::size_t i = 0; i < 5; ++i)
{
this->actual_positions[i] = i + 1;
this->actual_positions[i] = i + 1.;
}
this->desired_positions[0] = 1.;

View file

@ -125,7 +125,7 @@ namespace impl
struct peaks_over_threshold_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef boost::tuple<float_type, float_type, float_type> result_type;
// for left tail fitting, mirror the extreme values
@ -134,8 +134,8 @@ namespace impl
template<typename Args>
peaks_over_threshold_impl(Args const &args)
: Nu_(0)
, mu_(sign::value * numeric::average(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1))
, mu_(sign::value * numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, threshold_(sign::value * args[pot_threshold_value])
, fit_parameters_(boost::make_tuple(0., 0., 0.))
, is_dirty_(true)
@ -164,13 +164,13 @@ namespace impl
std::size_t cnt = count(args);
this->mu_ = sign::value * numeric::average(this->mu_, this->Nu_);
this->sigma2_ = numeric::average(this->sigma2_, this->Nu_);
this->mu_ = sign::value * numeric::fdiv(this->mu_, this->Nu_);
this->sigma2_ = numeric::fdiv(this->sigma2_, this->Nu_);
this->sigma2_ -= this->mu_ * this->mu_;
float_type threshold_probability = numeric::average(cnt - this->Nu_, cnt);
float_type threshold_probability = numeric::fdiv(cnt - this->Nu_, cnt);
float_type tmp = numeric::average(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_);
float_type tmp = numeric::fdiv(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_);
float_type xi_hat = 0.5 * ( 1. - tmp );
float_type beta_hat = 0.5 * ( this->mu_ - this->threshold_ ) * ( 1. + tmp );
float_type beta_bar = beta_hat * std::pow(1. - threshold_probability, xi_hat);
@ -205,7 +205,7 @@ namespace impl
struct peaks_over_threshold_prob_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef boost::tuple<float_type, float_type, float_type> result_type;
// for left tail fitting, mirror the extreme values
@ -213,8 +213,8 @@ namespace impl
template<typename Args>
peaks_over_threshold_prob_impl(Args const &args)
: mu_(sign::value * numeric::average(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1))
: mu_(sign::value * numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, threshold_probability_(args[pot_threshold_probability])
, fit_parameters_(boost::make_tuple(0., 0., 0.))
, is_dirty_(true)
@ -272,14 +272,14 @@ namespace impl
sigma2_ += *(tail(args).begin() + i) * (*(tail(args).begin() + i));
}
this->mu_ = sign::value * numeric::average(this->mu_, n);
this->sigma2_ = numeric::average(this->sigma2_, n);
this->mu_ = sign::value * numeric::fdiv(this->mu_, n);
this->sigma2_ = numeric::fdiv(this->sigma2_, n);
this->sigma2_ -= this->mu_ * this->mu_;
if (is_same<LeftRight, left>::value)
this->threshold_probability_ = 1. - this->threshold_probability_;
float_type tmp = numeric::average(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_);
float_type tmp = numeric::fdiv(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_);
float_type xi_hat = 0.5 * ( 1. - tmp );
float_type beta_hat = 0.5 * ( this->mu_ - u ) * ( 1. + tmp );
float_type beta_bar = beta_hat * std::pow(1. - threshold_probability_, xi_hat);

View file

@ -49,7 +49,7 @@ namespace impl
struct pot_quantile_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef float_type result_type;

View file

@ -52,7 +52,7 @@ namespace impl
struct pot_tail_mean_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef float_type result_type;

View file

@ -1,9 +1,10 @@
///////////////////////////////////////////////////////////////////////////////
// rolling_mean.hpp
//
// Copyright 2008 Eric Niebler. 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)
// Copyright (C) 2008 Eric Niebler.
// Copyright (C) 2012 Pieter Bastiaan Ober (Integricom).
// 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_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008
#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008
@ -20,62 +21,159 @@
namespace boost { namespace accumulators
{
namespace impl
{
///////////////////////////////////////////////////////////////////////////////
// lazy_rolling_mean_impl
// returns the mean over the rolling window and is calculated only
// when the result is requested
template<typename Sample>
struct lazy_rolling_mean_impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::fdiv<Sample, std::size_t, void, void>::result_type result_type;
namespace impl
{
lazy_rolling_mean_impl(dont_care)
{
}
///////////////////////////////////////////////////////////////////////////////
// rolling_mean_impl
// returns the unshifted results from the shifted rolling window
template<typename Sample>
struct rolling_mean_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
template<typename Args>
result_type result(Args const &args) const
{
return numeric::fdiv(rolling_sum(args), rolling_count(args));
}
};
rolling_mean_impl(dont_care)
{}
///////////////////////////////////////////////////////////////////////////////
// immediate_rolling_mean_impl
// The non-lazy version computes the rolling mean recursively when a new
// sample is added
template<typename Sample>
struct immediate_rolling_mean_impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(rolling_sum(args), rolling_count(args));
}
};
template<typename Args>
immediate_rolling_mean_impl(Args const &args)
: mean_(numeric::fdiv(args[sample | Sample()],numeric::one<std::size_t>::value))
{
}
} // namespace impl
template<typename Args>
void operator()(Args const &args)
{
if(is_rolling_window_plus1_full(args))
{
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));
}
}
///////////////////////////////////////////////////////////////////////////////
// tag::rolling_mean
//
namespace tag
{
struct rolling_mean
: depends_on< rolling_sum, rolling_count >
{
/// INTERNAL ONLY
///
typedef accumulators::impl::rolling_mean_impl< mpl::_1 > impl;
template<typename Args>
result_type result(Args const &) const
{
return mean_;
}
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::rolling_window::window_size named parameter
static boost::parameter::keyword<tag::rolling_window_size> const window_size;
#endif
};
} // namespace tag
private:
///////////////////////////////////////////////////////////////////////////////
// extract::rolling_mean
//
namespace extract
{
extractor<tag::rolling_mean> const rolling_mean = {};
result_type mean_;
};
} // namespace impl
BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_mean)
}
///////////////////////////////////////////////////////////////////////////////
// tag::lazy_rolling_mean
// tag::immediate_rolling_mean
// tag::rolling_mean
//
namespace tag
{
struct lazy_rolling_mean
: depends_on< rolling_sum, rolling_count >
{
/// INTERNAL ONLY
///
typedef accumulators::impl::lazy_rolling_mean_impl< mpl::_1 > impl;
using extract::rolling_mean;
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::rolling_window::window_size named parameter
static boost::parameter::keyword<tag::rolling_window_size> const window_size;
#endif
};
struct immediate_rolling_mean
: depends_on< rolling_window_plus1, rolling_count>
{
/// INTERNAL ONLY
///
typedef accumulators::impl::immediate_rolling_mean_impl< mpl::_1> impl;
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::rolling_window::window_size named parameter
static boost::parameter::keyword<tag::rolling_window_size> const window_size;
#endif
};
// make immediate_rolling_mean the default implementation
struct rolling_mean : immediate_rolling_mean {};
} // namespace tag
///////////////////////////////////////////////////////////////////////////////
// extract::lazy_rolling_mean
// extract::immediate_rolling_mean
// extract::rolling_mean
//
namespace extract
{
extractor<tag::lazy_rolling_mean> const lazy_rolling_mean = {};
extractor<tag::immediate_rolling_mean> const immediate_rolling_mean = {};
extractor<tag::rolling_mean> const rolling_mean = {};
BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_rolling_mean)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(immediate_rolling_mean)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_mean)
}
using extract::lazy_rolling_mean;
using extract::immediate_rolling_mean;
using extract::rolling_mean;
// rolling_mean(lazy) -> lazy_rolling_mean
template<>
struct as_feature<tag::rolling_mean(lazy)>
{
typedef tag::lazy_rolling_mean type;
};
// rolling_mean(immediate) -> immediate_rolling_mean
template<>
struct as_feature<tag::rolling_mean(immediate)>
{
typedef tag::immediate_rolling_mean type;
};
// for the purposes of feature-based dependency resolution,
// immediate_rolling_mean provides the same feature as rolling_mean
template<>
struct feature_of<tag::immediate_rolling_mean>
: feature_of<tag::rolling_mean>
{
};
// for the purposes of feature-based dependency resolution,
// lazy_rolling_mean provides the same feature as rolling_mean
template<>
struct feature_of<tag::lazy_rolling_mean>
: feature_of<tag::rolling_mean>
{
};
}} // namespace boost::accumulators
#endif
#endif

View file

@ -0,0 +1,113 @@
///////////////////////////////////////////////////////////////////////////////
// rolling_moment.hpp
// Copyright 2005 Eric Niebler.
// Copyright (C) 2014 Pieter Bastiaan Ober (Integricom).
// 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_ACCUMULATORS_STATISTICS_ROLLING_MOMENT_HPP_EAN_27_11_2005
#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_MOMENT_HPP_EAN_27_11_2005
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
#include <boost/accumulators/framework/parameters/sample.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/accumulators/statistics/moment.hpp>
#include <boost/accumulators/statistics/rolling_count.hpp>
namespace boost { namespace accumulators
{
namespace impl
{
///////////////////////////////////////////////////////////////////////////////
// rolling_moment_impl
template<typename N, typename Sample>
struct rolling_moment_impl
: accumulator_base
{
BOOST_MPL_ASSERT_RELATION(N::value, >, 0);
// for boost::result_of
typedef typename numeric::functional::fdiv<Sample, std::size_t,void,void>::result_type result_type;
template<typename Args>
rolling_moment_impl(Args const &args)
: sum_(args[sample | Sample()])
{
}
template<typename Args>
void operator ()(Args const &args)
{
if(is_rolling_window_plus1_full(args))
{
this->sum_ -= numeric::pow(rolling_window_plus1(args).front(), N());
}
this->sum_ += numeric::pow(args[sample], N());
}
template<typename Args>
result_type result(Args const &args) const
{
return numeric::fdiv(this->sum_, rolling_count(args));
}
private:
result_type sum_;
};
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
// tag::rolling_moment
//
namespace tag
{
template<int N>
struct rolling_moment
: depends_on< rolling_window_plus1, rolling_count>
{
/// INTERNAL ONLY
///
typedef accumulators::impl::rolling_moment_impl<mpl::int_<N>, mpl::_1> impl;
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::rolling_window::window_size named parameter
static boost::parameter::keyword<tag::rolling_window_size> const window_size;
#endif
};
}
///////////////////////////////////////////////////////////////////////////////
// extract::rolling_moment
//
namespace extract
{
BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, rolling_moment, (int))
}
using extract::rolling_moment;
// There is no weighted_rolling_moment (yet)...
//
//// So that rolling_moment<N> can be automatically substituted with
//// weighted_rolling_moment<N> when the weight parameter is non-void
//template<int N>
//struct as_weighted_feature<tag::rolling_moment<N> >
//{
// typedef tag::weighted_rolling_moment<N> type;
//};
//
//template<int N>
//struct feature_of<tag::weighted_rolling_moment<N> >
// : feature_of<tag::rolling_moment<N> >
//{
//};
}} // namespace boost::accumulators
#endif

View file

@ -19,7 +19,6 @@
namespace boost { namespace accumulators
{
namespace impl
{
///////////////////////////////////////////////////////////////////////////////
@ -47,7 +46,7 @@ namespace impl
}
template<typename Args>
result_type result(Args const &args) const
result_type result(Args const & /*args*/) const
{
return this->sum_;
}
@ -87,7 +86,6 @@ namespace extract
}
using extract::rolling_sum;
}} // namespace boost::accumulators
#endif

View file

@ -0,0 +1,247 @@
///////////////////////////////////////////////////////////////////////////////
// rolling_variance.hpp
// Copyright (C) 2005 Eric Niebler
// Copyright (C) 2014 Pieter Bastiaan Ober (Integricom).
// 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_ACCUMULATORS_STATISTICS_ROLLING_VARIANCE_HPP_EAN_15_11_2011
#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_VARIANCE_HPP_EAN_15_11_2011
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
#include <boost/accumulators/framework/parameters/sample.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/accumulators/statistics/rolling_mean.hpp>
#include <boost/accumulators/statistics/rolling_moment.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace accumulators
{
namespace impl
{
//! Immediate (lazy) calculation of the rolling variance.
/*!
Calculation of sample variance \f$\sigma_n^2\f$ is done as follows, see also
http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance.
For a rolling window of size \f$N\f$, when \f$n <= N\f$, the variance is computed according to the formula
\f[
\sigma_n^2 = \frac{1}{n-1} \sum_{i = 1}^n (x_i - \mu_n)^2.
\f]
When \f$n > N\f$, the sample variance over the window becomes:
\f[
\sigma_n^2 = \frac{1}{N-1} \sum_{i = n-N+1}^n (x_i - \mu_n)^2.
\f]
*/
///////////////////////////////////////////////////////////////////////////////
// lazy_rolling_variance_impl
//
template<typename Sample>
struct lazy_rolling_variance_impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::fdiv<Sample, std::size_t,void,void>::result_type result_type;
lazy_rolling_variance_impl(dont_care) {}
template<typename Args>
result_type result(Args const &args) const
{
result_type mean = rolling_mean(args);
size_t nr_samples = rolling_count(args);
if (nr_samples < 2) return result_type();
return nr_samples*(rolling_moment<2>(args) - mean*mean)/(nr_samples-1);
}
};
//! Iterative calculation of the rolling variance.
/*!
Iterative calculation of sample variance \f$\sigma_n^2\f$ is done as follows, see also
http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance.
For a rolling window of size \f$N\f$, for the first \f$N\f$ samples, the variance is computed according to the formula
\f[
\sigma_n^2 = \frac{1}{n-1} \sum_{i = 1}^n (x_i - \mu_n)^2 = \frac{1}{n-1}M_{2,n},
\f]
where the sum of squares \f$M_{2,n}\f$ can be recursively computed as:
\f[
M_{2,n} = \sum_{i = 1}^n (x_i - \mu_n)^2 = M_{2,n-1} + (x_n - \mu_n)(x_n - \mu_{n-1}),
\f]
and the estimate of the sample mean as:
\f[
\mu_n = \frac{1}{n} \sum_{i = 1}^n x_i = \mu_{n-1} + \frac{1}{n}(x_n - \mu_{n-1}).
\f]
For further samples, when the rolling window is fully filled with data, one has to take into account that the oldest
sample \f$x_{n-N}\f$ is dropped from the window. The sample variance over the window now becomes:
\f[
\sigma_n^2 = \frac{1}{N-1} \sum_{i = n-N+1}^n (x_i - \mu_n)^2 = \frac{1}{n-1}M_{2,n},
\f]
where the sum of squares \f$M_{2,n}\f$ now equals:
\f[
M_{2,n} = \sum_{i = n-N+1}^n (x_i - \mu_n)^2 = M_{2,n-1} + (x_n - \mu_n)(x_n - \mu_{n-1}) - (x_{n-N} - \mu_n)(x_{n-N} - \mu_{n-1}),
\f]
and the estimated mean is:
\f[
\mu_n = \frac{1}{N} \sum_{i = n-N+1}^n x_i = \mu_{n-1} + \frac{1}{n}(x_n - x_{n-N}).
\f]
Note that the sample variance is not defined for \f$n <= 1\f$.
*/
///////////////////////////////////////////////////////////////////////////////
// immediate_rolling_variance_impl
//
template<typename Sample>
struct immediate_rolling_variance_impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
template<typename Args>
immediate_rolling_variance_impl(Args const &args)
: previous_mean_(numeric::fdiv(args[sample | Sample()], numeric::one<std::size_t>::value))
, sum_of_squares_(numeric::fdiv(args[sample | Sample()], numeric::one<std::size_t>::value))
{
}
template<typename Args>
void operator()(Args const &args)
{
Sample added_sample = args[sample];
result_type mean = immediate_rolling_mean(args);
sum_of_squares_ += (added_sample-mean)*(added_sample-previous_mean_);
if(is_rolling_window_plus1_full(args))
{
Sample removed_sample = rolling_window_plus1(args).front();
sum_of_squares_ -= (removed_sample-mean)*(removed_sample-previous_mean_);
prevent_underflow(sum_of_squares_);
}
previous_mean_ = mean;
}
template<typename Args>
result_type result(Args const &args) const
{
size_t nr_samples = rolling_count(args);
if (nr_samples < 2) return result_type();
return numeric::fdiv(sum_of_squares_,(nr_samples-1));
}
private:
result_type previous_mean_;
result_type sum_of_squares_;
template<typename T>
void prevent_underflow(T &non_negative_number,typename boost::enable_if<boost::is_arithmetic<T>,T>::type* = 0)
{
if (non_negative_number < T(0)) non_negative_number = T(0);
}
template<typename T>
void prevent_underflow(T &non_arithmetic_quantity,typename boost::disable_if<boost::is_arithmetic<T>,T>::type* = 0)
{
}
};
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
// tag:: lazy_rolling_variance
// tag:: immediate_rolling_variance
// tag:: rolling_variance
//
namespace tag
{
struct lazy_rolling_variance
: depends_on< rolling_count, rolling_mean, rolling_moment<2> >
{
/// INTERNAL ONLY
///
typedef accumulators::impl::lazy_rolling_variance_impl< mpl::_1 > impl;
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::rolling_window::window_size named parameter
static boost::parameter::keyword<tag::rolling_window_size> const window_size;
#endif
};
struct immediate_rolling_variance
: depends_on< rolling_window_plus1, rolling_count, immediate_rolling_mean>
{
/// INTERNAL ONLY
///
typedef accumulators::impl::immediate_rolling_variance_impl< mpl::_1> impl;
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::rolling_window::window_size named parameter
static boost::parameter::keyword<tag::rolling_window_size> const window_size;
#endif
};
// make immediate_rolling_variance the default implementation
struct rolling_variance : immediate_rolling_variance {};
} // namespace tag
///////////////////////////////////////////////////////////////////////////////
// extract::lazy_rolling_variance
// extract::immediate_rolling_variance
// extract::rolling_variance
//
namespace extract
{
extractor<tag::lazy_rolling_variance> const lazy_rolling_variance = {};
extractor<tag::immediate_rolling_variance> const immediate_rolling_variance = {};
extractor<tag::rolling_variance> const rolling_variance = {};
BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_rolling_variance)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(immediate_rolling_variance)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_variance)
}
using extract::lazy_rolling_variance;
using extract::immediate_rolling_variance;
using extract::rolling_variance;
// rolling_variance(lazy) -> lazy_rolling_variance
template<>
struct as_feature<tag::rolling_variance(lazy)>
{
typedef tag::lazy_rolling_variance type;
};
// rolling_variance(immediate) -> immediate_rolling_variance
template<>
struct as_feature<tag::rolling_variance(immediate)>
{
typedef tag::immediate_rolling_variance type;
};
// for the purposes of feature-based dependency resolution,
// lazy_rolling_variance provides the same feature as rolling_variance
template<>
struct feature_of<tag::lazy_rolling_variance>
: feature_of<tag::rolling_variance>
{
};
// for the purposes of feature-based dependency resolution,
// immediate_rolling_variance provides the same feature as rolling_variance
template<>
struct feature_of<tag::immediate_rolling_variance>
: feature_of<tag::rolling_variance>
{
};
}} // namespace boost::accumulators
#endif

View file

@ -48,7 +48,7 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, Sample>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, Sample>::result_type result_type;
skewness_impl(dont_care)
{
@ -57,7 +57,7 @@ namespace impl
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(
return numeric::fdiv(
accumulators::moment<3>(args)
- 3. * accumulators::moment<2>(args) * mean(args)
+ 2. * mean(args) * mean(args) * mean(args)

View file

@ -62,7 +62,7 @@ namespace impl
struct coherent_tail_mean_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef float_type result_type;
@ -82,10 +82,10 @@ namespace impl
extractor<tag::non_coherent_tail_mean<LeftRight> > const some_non_coherent_tail_mean = {};
return some_non_coherent_tail_mean(args)
+ numeric::average(quantile(args), n)
+ numeric::fdiv(quantile(args), n)
* (
( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability]
- numeric::average(n, count(args))
- numeric::fdiv(n, count(args))
);
}
};
@ -117,7 +117,7 @@ namespace impl
struct non_coherent_tail_mean_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef float_type result_type;
@ -136,7 +136,7 @@ namespace impl
// If n is in a valid range, return result, otherwise return NaN or throw exception
if (n <= static_cast<std::size_t>(tail(args).size()))
return numeric::average(
return numeric::fdiv(
std::accumulate(
tail(args).begin()
, tail(args).begin() + n

View file

@ -79,7 +79,7 @@ namespace impl
struct tail_variate_means_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<float_type> array_type;
// for boost::result_of
typedef iterator_range<typename array_type::iterator> result_type;

View file

@ -42,7 +42,7 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
lazy_variance_impl(dont_care) {}
@ -85,11 +85,11 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
template<typename Args>
variance_impl(Args const &args)
: variance(numeric::average(args[sample | Sample()], numeric::one<std::size_t>::value))
: variance(numeric::fdiv(args[sample | Sample()], numeric::one<std::size_t>::value))
{
}
@ -103,8 +103,8 @@ namespace impl
extractor<MeanFeature> mean;
result_type tmp = args[parameter::keyword<Tag>::get()] - mean(args);
this->variance =
numeric::average(this->variance * (cnt - 1), cnt)
+ numeric::average(tmp * tmp, cnt - 1);
numeric::fdiv(this->variance * (cnt - 1), cnt)
+ numeric::fdiv(tmp * tmp, cnt - 1);
}
}

View file

@ -57,8 +57,8 @@ namespace impl
struct weighted_covariance_impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Weight, typename numeric::functional::average<Sample, std::size_t>::result_type>::result_type weighted_sample_type;
typedef typename numeric::functional::multiplies<Weight, typename numeric::functional::average<VariateType, std::size_t>::result_type>::result_type weighted_variate_type;
typedef typename numeric::functional::multiplies<Weight, typename numeric::functional::fdiv<Sample, std::size_t>::result_type>::result_type weighted_sample_type;
typedef typename numeric::functional::multiplies<Weight, typename numeric::functional::fdiv<VariateType, std::size_t>::result_type>::result_type weighted_variate_type;
// for boost::result_of
typedef typename numeric::functional::outer_product<weighted_sample_type, weighted_variate_type>::result_type result_type;
@ -66,9 +66,9 @@ namespace impl
weighted_covariance_impl(Args const &args)
: cov_(
numeric::outer_product(
numeric::average(args[sample | Sample()], (std::size_t)1)
numeric::fdiv(args[sample | Sample()], (std::size_t)1)
* numeric::one<Weight>::value
, numeric::average(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1)
, numeric::fdiv(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1)
* numeric::one<Weight>::value
)
)

View file

@ -50,7 +50,7 @@ namespace impl
struct weighted_density_impl
: accumulator_base
{
typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Weight, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef std::vector<float_type> array_type;
// for boost::result_of
@ -66,8 +66,8 @@ namespace impl
, histogram(
num_bins + 2
, std::make_pair(
numeric::average(args[sample | Sample()],(std::size_t)1)
, numeric::average(args[sample | Sample()],(std::size_t)1)
numeric::fdiv(args[sample | Sample()],(std::size_t)1)
, numeric::fdiv(args[sample | Sample()],(std::size_t)1)
)
)
, is_dirty(true)
@ -92,9 +92,9 @@ namespace impl
// Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin).
if (cnt == this->cache_size)
{
float_type minimum = numeric::average((min)(args),(std::size_t)1);
float_type maximum = numeric::average((max)(args),(std::size_t)1);
float_type bin_size = numeric::average(maximum - minimum, this->num_bins);
float_type minimum = numeric::fdiv((min)(args),(std::size_t)1);
float_type maximum = numeric::fdiv((max)(args),(std::size_t)1);
float_type bin_size = numeric::fdiv(maximum - minimum, this->num_bins);
// determine bin positions (their lower bounds)
for (std::size_t i = 0; i < this->num_bins + 2; ++i)
@ -163,7 +163,7 @@ namespace impl
for (std::size_t i = 0; i < this->num_bins + 2; ++i)
{
this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::average(this->samples_in_bin[i], sum_of_weights(args)));
this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::fdiv(this->samples_in_bin[i], sum_of_weights(args)));
}
}

View file

@ -67,7 +67,7 @@ namespace impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type float_type;
typedef std::vector<float_type> array_type;
// for boost::result_of
typedef iterator_range<

View file

@ -52,7 +52,7 @@ namespace impl
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, weighted_sample>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, weighted_sample>::result_type result_type;
weighted_kurtosis_impl(dont_care)
{
@ -61,7 +61,7 @@ namespace impl
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(
return numeric::fdiv(
accumulators::weighted_moment<4>(args)
- 4. * accumulators::weighted_moment<3>(args) * weighted_mean(args)
+ 6. * accumulators::weighted_moment<2>(args) * weighted_mean(args) * weighted_mean(args)

View file

@ -36,7 +36,7 @@ namespace impl
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, Weight>::result_type result_type;
weighted_mean_impl(dont_care) {}
@ -53,7 +53,7 @@ namespace impl
extractor<weighted_sum_tag> const some_weighted_sum = {};
return numeric::average(some_weighted_sum(args), sum_of_weights(args));
return numeric::fdiv(some_weighted_sum(args), sum_of_weights(args));
}
};
@ -66,12 +66,12 @@ namespace impl
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, Weight>::result_type result_type;
template<typename Args>
immediate_weighted_mean_impl(Args const &args)
: mean(
numeric::average(
numeric::fdiv(
args[parameter::keyword<Tag>::get() | Sample()]
* numeric::one<Weight>::value
, numeric::one<Weight>::value
@ -89,7 +89,7 @@ namespace impl
Weight w_sum = sum_of_weights(args);
Weight w = args[weight];
weighted_sample const &s = args[parameter::keyword<Tag>::get()] * w;
this->mean = numeric::average(this->mean * (w_sum - w) + s, w_sum);
this->mean = numeric::fdiv(this->mean * (w_sum - w) + s, w_sum);
}
result_type result(dont_care) const

View file

@ -40,7 +40,7 @@ namespace impl
: accumulator_base
{
// for boost::result_of
typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type;
weighted_median_impl(dont_care) {}
@ -65,7 +65,7 @@ namespace impl
struct with_density_weighted_median_impl
: accumulator_base
{
typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef iterator_range<typename histogram_type::iterator> range_type;
// for boost::result_of
@ -73,7 +73,7 @@ namespace impl
template<typename Args>
with_density_weighted_median_impl(Args const &args)
: sum(numeric::average(args[sample | Sample()], (std::size_t)1))
: sum(numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, is_dirty(true)
{
}
@ -99,7 +99,7 @@ namespace impl
++it;
}
--it;
float_type over = numeric::average(this->sum - 0.5 * cnt, it->second * cnt);
float_type over = numeric::fdiv(this->sum - 0.5 * cnt, it->second * cnt);
this->median = it->first * over + (it + 1)->first * ( 1. - over );
}
@ -127,7 +127,7 @@ namespace impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef iterator_range<typename histogram_type::iterator> range_type;
// for boost::result_of
@ -156,7 +156,7 @@ namespace impl
{
++it;
}
float_type over = numeric::average(it->second - 0.5, it->second - (it - 1)->second);
float_type over = numeric::fdiv(it->second - 0.5, it->second - (it - 1)->second);
this->median = it->first * over + (it + 1)->first * ( 1. - over );
}

View file

@ -40,7 +40,7 @@ namespace impl
BOOST_MPL_ASSERT_RELATION(N::value, >, 0);
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, Weight>::result_type result_type;
template<typename Args>
weighted_moment_impl(Args const &args)
@ -57,7 +57,7 @@ namespace impl
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(this->sum, sum_of_weights(args));
return numeric::fdiv(this->sum, sum_of_weights(args));
}
private:

View file

@ -53,7 +53,7 @@ namespace impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type float_type;
typedef std::vector<std::pair<float_type, float_type> > histogram_type;
typedef std::vector<float_type> array_type;
// for boost::result_of
@ -153,7 +153,7 @@ namespace impl
for (std::size_t i = 1; i < b + 1; ++i)
{
this->desired_positions[i] = this->actual_positions[0]
+ numeric::average((i-1) * (sum_of_weights(args) - this->actual_positions[0]), b);
+ numeric::fdiv((i-1) * (sum_of_weights(args) - this->actual_positions[0]), b);
}
// adjust heights of markers 2 to num_cells if necessary
@ -214,7 +214,7 @@ namespace impl
for (std::size_t i = 0; i < this->histogram.size(); ++i)
{
this->histogram[i] = std::make_pair(this->heights[i], numeric::average(this->actual_positions[i], sum_of_weights(args)));
this->histogram[i] = std::make_pair(this->heights[i], numeric::fdiv(this->actual_positions[i], sum_of_weights(args)));
}
}

View file

@ -55,7 +55,7 @@ namespace impl {
: accumulator_base
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type float_type;
typedef array<float_type, 5> array_type;
// for boost::result_of
typedef float_type result_type;

View file

@ -56,16 +56,16 @@ namespace impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Weight, Sample>::result_type weighted_sample;
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef boost::tuple<float_type, float_type, float_type> result_type;
template<typename Args>
weighted_peaks_over_threshold_impl(Args const &args)
: sign_((is_same<LeftRight, left>::value) ? -1 : 1)
, mu_(sign_ * numeric::average(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1))
, w_sum_(numeric::average(args[weight | Weight()], (std::size_t)1))
, mu_(sign_ * numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, w_sum_(numeric::fdiv(args[weight | Weight()], (std::size_t)1))
, threshold_(sign_ * args[pot_threshold_value])
, fit_parameters_(boost::make_tuple(0., 0., 0.))
, is_dirty_(true)
@ -92,13 +92,13 @@ namespace impl
{
this->is_dirty_ = false;
this->mu_ = this->sign_ * numeric::average(this->mu_, this->w_sum_);
this->sigma2_ = numeric::average(this->sigma2_, this->w_sum_);
this->mu_ = this->sign_ * numeric::fdiv(this->mu_, this->w_sum_);
this->sigma2_ = numeric::fdiv(this->sigma2_, this->w_sum_);
this->sigma2_ -= this->mu_ * this->mu_;
float_type threshold_probability = numeric::average(sum_of_weights(args) - this->w_sum_, sum_of_weights(args));
float_type threshold_probability = numeric::fdiv(sum_of_weights(args) - this->w_sum_, sum_of_weights(args));
float_type tmp = numeric::average(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_);
float_type tmp = numeric::fdiv(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_);
float_type xi_hat = 0.5 * ( 1. - tmp );
float_type beta_hat = 0.5 * ( this->mu_ - this->threshold_ ) * ( 1. + tmp );
float_type beta_bar = beta_hat * std::pow(1. - threshold_probability, xi_hat);
@ -135,15 +135,15 @@ namespace impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Weight, Sample>::result_type weighted_sample;
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type float_type;
// for boost::result_of
typedef boost::tuple<float_type, float_type, float_type> result_type;
template<typename Args>
weighted_peaks_over_threshold_prob_impl(Args const &args)
: sign_((is_same<LeftRight, left>::value) ? -1 : 1)
, mu_(sign_ * numeric::average(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1))
, mu_(sign_ * numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, sigma2_(numeric::fdiv(args[sample | Sample()], (std::size_t)1))
, threshold_probability_(args[pot_threshold_probability])
, fit_parameters_(boost::make_tuple(0., 0., 0.))
, is_dirty_(true)
@ -200,14 +200,14 @@ namespace impl
float_type u = *(tail(args).begin() + n - 1) * this->sign_;
this->mu_ = this->sign_ * numeric::average(this->mu_, sum);
this->sigma2_ = numeric::average(this->sigma2_, sum);
this->mu_ = this->sign_ * numeric::fdiv(this->mu_, sum);
this->sigma2_ = numeric::fdiv(this->sigma2_, sum);
this->sigma2_ -= this->mu_ * this->mu_;
if (is_same<LeftRight, left>::value)
this->threshold_probability_ = 1. - this->threshold_probability_;
float_type tmp = numeric::average(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_);
float_type tmp = numeric::fdiv(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_);
float_type xi_hat = 0.5 * ( 1. - tmp );
float_type beta_hat = 0.5 * ( this->mu_ - u ) * ( 1. + tmp );
float_type beta_bar = beta_hat * std::pow(1. - threshold_probability_, xi_hat);

View file

@ -51,14 +51,14 @@ namespace impl
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, weighted_sample>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, weighted_sample>::result_type result_type;
weighted_skewness_impl(dont_care) {}
template<typename Args>
result_type result(Args const &args) const
{
return numeric::average(
return numeric::fdiv(
accumulators::weighted_moment<3>(args)
- 3. * accumulators::weighted_moment<2>(args) * weighted_mean(args)
+ 2. * weighted_mean(args) * weighted_mean(args) * weighted_mean(args)

View file

@ -82,9 +82,9 @@ namespace impl
: accumulator_base
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Weight, std::size_t>::result_type float_type;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, std::size_t>::result_type result_type;
non_coherent_weighted_tail_mean_impl(dont_care) {}
@ -120,7 +120,7 @@ namespace impl
}
}
return numeric::average(
return numeric::fdiv(
std::inner_product(
tail(args).begin()
, tail(args).begin() + n

View file

@ -66,7 +66,7 @@ namespace impl
struct weighted_tail_quantile_impl
: accumulator_base
{
typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type;
typedef typename numeric::functional::fdiv<Weight, std::size_t>::result_type float_type;
// for boost::result_of
typedef Sample result_type;

View file

@ -107,8 +107,8 @@ namespace impl
struct weighted_tail_variate_means_impl
: accumulator_base
{
typedef typename numeric::functional::average<Weight, Weight>::result_type float_type;
typedef typename numeric::functional::average<typename numeric::functional::multiplies<VariateType, Weight>::result_type, Weight>::result_type array_type;
typedef typename numeric::functional::fdiv<Weight, Weight>::result_type float_type;
typedef typename numeric::functional::fdiv<typename numeric::functional::multiplies<VariateType, Weight>::result_type, Weight>::result_type array_type;
// for boost::result_of
typedef iterator_range<typename array_type::iterator> result_type;

View file

@ -41,7 +41,7 @@ namespace impl
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, Weight>::result_type result_type;
lazy_weighted_variance_impl(dont_care) {}
@ -73,11 +73,11 @@ namespace impl
{
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
// for boost::result_of
typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
typedef typename numeric::functional::fdiv<weighted_sample, Weight>::result_type result_type;
template<typename Args>
weighted_variance_impl(Args const &args)
: weighted_variance(numeric::average(args[sample | Sample()], numeric::one<Weight>::value))
: weighted_variance(numeric::fdiv(args[sample | Sample()], numeric::one<Weight>::value))
{
}
@ -93,8 +93,8 @@ namespace impl
result_type tmp = args[parameter::keyword<Tag>::get()] - some_mean(args);
this->weighted_variance =
numeric::average(this->weighted_variance * (sum_of_weights(args) - args[weight]), sum_of_weights(args))
+ numeric::average(tmp * tmp * args[weight], sum_of_weights(args) - args[weight] );
numeric::fdiv(this->weighted_variance * (sum_of_weights(args) - args[weight]), sum_of_weights(args))
+ numeric::fdiv(tmp * tmp * args[weight], sum_of_weights(args) - args[weight] );
}
}

View file

@ -31,8 +31,8 @@
namespace boost { namespace algorithm {
/// \fn clamp ( T const& val,
/// typename boost::mpl::identity<T>::type const& lo,
/// typename boost::mpl::identity<T>::type const& hi, Pred p )
/// typename boost::mpl::identity<T>::type const & lo,
/// typename boost::mpl::identity<T>::type const & hi, Pred p )
/// \return the value "val" brought into the range [ lo, hi ]
/// using the comparison predicate p.
/// If p ( val, lo ) return lo.
@ -56,8 +56,8 @@ namespace boost { namespace algorithm {
/// \fn clamp ( T const& val,
/// typename boost::mpl::identity<T>::type const& lo,
/// typename boost::mpl::identity<T>::type const& hi )
/// typename boost::mpl::identity<T>::type const & lo,
/// typename boost::mpl::identity<T>::type const & hi )
/// \return the value "val" brought into the range [ lo, hi ].
/// If the value is less than lo, return lo.
/// If the value is greater than "hi", return hi.
@ -76,8 +76,8 @@ namespace boost { namespace algorithm {
}
/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
/// std::iterator_traits<InputIterator>::value_type lo,
/// std::iterator_traits<InputIterator>::value_type hi )
/// std::iterator_traits<InputIterator>::value_type const & lo,
/// std::iterator_traits<InputIterator>::value_type const & hi )
/// \return clamp the sequence of values [first, last) into [ lo, hi ]
///
/// \param first The start of the range of values
@ -88,8 +88,8 @@ namespace boost { namespace algorithm {
///
template<typename InputIterator, typename OutputIterator>
OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
typename std::iterator_traits<InputIterator>::value_type lo,
typename std::iterator_traits<InputIterator>::value_type hi )
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 )
@ -98,8 +98,8 @@ namespace boost { namespace algorithm {
}
/// \fn clamp_range ( const Range &r, OutputIterator out,
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type lo,
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type hi )
/// 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 the sequence of values [first, last) into [ lo, hi ]
///
/// \param r The range of values to be clamped
@ -110,16 +110,16 @@ namespace boost { namespace algorithm {
template<typename Range, typename OutputIterator>
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 lo,
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type hi )
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 );
}
/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
/// std::iterator_traits<InputIterator>::value_type lo,
/// std::iterator_traits<InputIterator>::value_type hi, Pred p )
/// std::iterator_traits<InputIterator>::value_type const & lo,
/// std::iterator_traits<InputIterator>::value_type const & hi, Pred p )
/// \return clamp the sequence of values [first, last) into [ lo, hi ]
/// using the comparison predicate p.
///
@ -134,8 +134,8 @@ namespace boost { namespace algorithm {
///
template<typename InputIterator, typename OutputIterator, typename Pred>
OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
typename std::iterator_traits<InputIterator>::value_type lo,
typename std::iterator_traits<InputIterator>::value_type hi, Pred p )
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 )
@ -144,8 +144,8 @@ namespace boost { namespace algorithm {
}
/// \fn clamp_range ( const Range &r, OutputIterator out,
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type lo,
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type hi,
/// 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 the sequence of values [first, last) into [ lo, hi ]
/// using the comparison predicate p.
@ -162,8 +162,8 @@ namespace boost { namespace algorithm {
template<typename Range, typename OutputIterator, typename Pred>
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 lo,
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type hi,
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 );

View file

@ -63,8 +63,8 @@ void iota ( Range &r, T value )
template <typename OutputIterator, typename T>
OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
{
while ( n-- > 0 )
*out++ = value++;
for ( ; n > 0; --n, ++value )
*out++ = value;
return out;
}

View file

@ -9,8 +9,8 @@
/// \brief Is a sequence a permutation of another sequence
/// \author Marshall Clow
#ifndef BOOST_ALGORITHM_IS_PERMUTATION_HPP
#define BOOST_ALGORITHM_IS_PERMUTATION_HPP
#ifndef BOOST_ALGORITHM_IS_PERMUTATION11_HPP
#define BOOST_ALGORITHM_IS_PERMUTATION11_HPP
#include <algorithm> // for std::less, tie, mismatch and is_permutation (if available)
#include <utility> // for std::make_pair
@ -21,7 +21,6 @@
#include <boost/range/end.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/tr1/tr1/tuple> // for tie
namespace boost { namespace algorithm {
@ -121,7 +120,6 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, BinaryPredicate p )
{
// Skip the common prefix (if any)
// std::tie (first1, first2) = std::mismatch (first1, last1, first2, p);
std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2, p);
first1 = eq.first;
first2 = eq.second;
@ -165,56 +163,6 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIt
#endif
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last,
/// ForwardIterator2 first2, ForwardIterator2 last2 )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
///
/// \param first1 The start of the input sequence
/// \param last2 One past the end of the input sequence
/// \param first2 The start of the second sequence
/// \param last1 One past the end of the second sequence
/// \note This function is part of the C++2011 standard library.
/// We will use the standard one if it is available,
/// otherwise we have our own implementation.
template< class ForwardIterator1, class ForwardIterator2 >
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2 )
{
// How should I deal with the idea that ForwardIterator1::value_type
// and ForwardIterator2::value_type could be different? Define my own comparison predicate?
return boost::algorithm::detail::is_permutation_tag (
first1, last1, first2, last2,
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> (),
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
}
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last,
/// ForwardIterator2 first2, ForwardIterator2 last2,
/// BinaryPredicate p )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
///
/// \param first1 The start of the input sequence
/// \param last1 One past the end of the input sequence
/// \param first2 The start of the second sequence
/// \param last2 One past the end of the second sequence
/// \param pred The predicate to compare elements with
///
/// \note This function is part of the C++2011 standard library.
/// We will use the standard one if it is available,
/// otherwise we have our own implementation.
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred )
{
return boost::algorithm::detail::is_permutation_tag (
first1, last1, first2, last2, pred,
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
}
/// \fn is_permutation ( const Range &r, ForwardIterator first2 )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
@ -245,4 +193,4 @@ is_permutation ( const Range &r, ForwardIterator first2, BinaryPredicate pred )
}}
#endif // BOOST_ALGORITHM_IS_PERMUTATION_HPP
#endif // BOOST_ALGORITHM_IS_PERMUTATION11_HPP

View file

@ -12,41 +12,41 @@
#ifndef BOOST_ALGORITHM_EQUAL_HPP
#define BOOST_ALGORITHM_EQUAL_HPP
#include <algorithm> // for std::equal
#include <functional> // for std::equal_to
#include <algorithm> // for std::equal
#include <functional> // for std::equal_to
namespace boost { namespace algorithm {
namespace detail {
template <class T1, class T2>
struct eq : public std::binary_function<T1, T2, bool> {
bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
};
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
std::random_access_iterator_tag, std::random_access_iterator_tag )
{
// 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 );
}
template <class T1, class T2>
struct eq : public std::binary_function<T1, T2, bool> {
bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
};
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
bool equal ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
std::random_access_iterator_tag, std::random_access_iterator_tag )
{
// 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 );
}
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
bool equal ( InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred,
std::input_iterator_tag, std::input_iterator_tag )
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2 )
if ( !pred(*first1, *first2 ))
return false;
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
bool equal ( InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred,
std::input_iterator_tag, std::input_iterator_tag )
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2 )
if ( !pred(*first1, *first2 ))
return false;
return first1 == last1 && first2 == last2;
}
return first1 == last1 && first2 == last2;
}
}
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
@ -63,10 +63,10 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
bool equal ( InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred )
{
return boost::algorithm::detail::equal (
first1, last1, first2, last2, pred,
typename std::iterator_traits<InputIterator1>::iterator_category (),
typename std::iterator_traits<InputIterator2>::iterator_category ());
return boost::algorithm::detail::equal (
first1, last1, first2, last2, pred,
typename std::iterator_traits<InputIterator1>::iterator_category (),
typename std::iterator_traits<InputIterator2>::iterator_category ());
}
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
@ -81,16 +81,16 @@ template <class InputIterator1, class InputIterator2>
bool equal ( InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2 )
{
return boost::algorithm::detail::equal (
first1, last1, first2, last2,
boost::algorithm::detail::eq<
typename std::iterator_traits<InputIterator1>::value_type,
typename std::iterator_traits<InputIterator2>::value_type> (),
typename std::iterator_traits<InputIterator1>::iterator_category (),
typename std::iterator_traits<InputIterator2>::iterator_category ());
return boost::algorithm::detail::equal (
first1, last1, first2, last2,
boost::algorithm::detail::eq<
typename std::iterator_traits<InputIterator1>::value_type,
typename std::iterator_traits<InputIterator2>::value_type> (),
typename std::iterator_traits<InputIterator1>::iterator_category (),
typename std::iterator_traits<InputIterator2>::iterator_category ());
}
// There are already range-based versions of these.
// There are already range-based versions of these.
}} // namespace boost and algorithm

View file

@ -1,130 +1,86 @@
/*
Copyright (c) Marshall Clow 2013
/*
Copyright (c) Marshall Clow 2014.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
/// \file equal.hpp
/// \brief Determines if one
/// \file is_permutation.hpp
/// \brief Is a sequence a permutation of another sequence (four iterator versions)
/// \author Marshall Clow
#ifndef BOOST_ALGORITHM_IS_PERMUTATION_HPP
#define BOOST_ALGORITHM_IS_PERMUTATION_HPP
#ifndef BOOST_ALGORITHM_IS_PERMUTATION14_HPP
#define BOOST_ALGORITHM_IS_PERMUTATION14_HPP
#include <algorithm>
#include <functional> // for std::equal_to
#include <algorithm> // for std::less, tie, mismatch and is_permutation (if available)
#include <utility> // for std::make_pair
#include <functional> // for std::equal_to
#include <iterator>
#include <boost/algorithm/cxx11/is_permutation.hpp>
#include <boost/algorithm/cxx14/mismatch.hpp>
namespace boost { namespace algorithm {
namespace detail {
template <class T1, class T2>
struct is_perm_eq : public std::binary_function<T1, T2, bool> {
bool operator () ( const T1& v1, const T2& v2 ) const { return v1 == v2 ;}
};
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
bool is_permutation ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred,
std::random_access_iterator_tag, std::random_access_iterator_tag )
{
// 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::is_permutation ( first1, last1, first2, pred );
}
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
bool is_permutation (
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred,
std::forward_iterator_tag, std::forward_iterator_tag )
{
// Look for common prefix
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
if (!pred(*first1, *first2))
goto not_done;
// We've reached the end of one of the sequences without a mismatch.
return first1 == last1 && first2 == last2;
not_done:
// Check and make sure that we have the same # of elements left
typedef typename std::iterator_traits<ForwardIterator1>::difference_type diff1_t;
diff1_t len1 = _VSTD::distance(first1, last1);
typedef typename std::iterator_traits<ForwardIterator2>::difference_type diff2_t;
diff2_t len2 = _VSTD::distance(first2, last2);
if (len1 != len2)
return false;
// For each element in [f1, l1) see if there are the
// same number of equal elements in [f2, l2)
for ( ForwardIterator1 i = first1; i != last1; ++i )
{
// Have we already counted this value?
ForwardIterator1 j;
for ( j = first1; j != i; ++j )
if (pred(*j, *i))
break;
if ( j == i ) // didn't find it...
{
// Count number of *i in [f2, l2)
diff1_t c2 = 0;
for ( ForwardIterator2 iter2 = first2; iter2 != last2; ++iter2 )
if (pred(*i, *iter2))
++c2;
if (c2 == 0)
return false;
// Count number of *i in [i, l1)
diff1_t c1 = 0;
for (_ForwardIterator1 iter1 = i; iter1 != last1; ++iter1 )
if (pred(*i, *iter1))
++c1;
if (c1 != c2)
return false;
}
}
#if __cplusplus <= 201103L
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last,
/// ForwardIterator2 first2, ForwardIterator2 last2 )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
///
/// \param first1 The start of the input sequence
/// \param last2 One past the end of the input sequence
/// \param first2 The start of the second sequence
/// \param last1 One past the end of the second sequence
/// \note This function is part of the C++2014 standard library.
/// We will use the standard one if it is available,
/// otherwise we have our own implementation.
template< class ForwardIterator1, class ForwardIterator2 >
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2 )
{
// How should I deal with the idea that ForwardIterator1::value_type
// and ForwardIterator2::value_type could be different? Define my own comparison predicate?
std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch
( first1, last1, first2, last2 );
if ( eq.first == last1 && eq.second == last2)
return true;
}
return boost::algorithm::detail::is_permutation_tag (
eq.first, last1, eq.second, last2,
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> (),
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
}
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
bool is_permutation (
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred )
{
return boost::algorithm::detail::is_permutation (
first1, last1, first2, last2, pred,
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
}
template<class ForwardIterator1, class ForwardIterator2>
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last,
/// ForwardIterator2 first2, ForwardIterator2 last2,
/// BinaryPredicate p )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
///
/// \param first1 The start of the input sequence
/// \param last1 One past the end of the input sequence
/// \param first2 The start of the second sequence
/// \param last2 One past the end of the second sequence
/// \param pred The predicate to compare elements with
///
/// \note This function is part of the C++2014 standard library.
/// We will use the standard one if it is available,
/// otherwise we have our own implementation.
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2 )
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred )
{
typedef typename iterator_traits<_ForwardIterator1>::value_type value1_t;
typedef typename iterator_traits<_ForwardIterator2>::value_type value2_t;
return boost::algorithm::detail::is_permutation (
first1, last1, first2, last2,
boost::algorithm::detail::is_perm_eq<
typename std::iterator_traits<InputIterator1>::value_type,
typename std::iterator_traits<InputIterator2>::value_type> (),
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch
( first1, last1, first2, last2, pred );
if ( eq.first == last1 && eq.second == last2)
return true;
return boost::algorithm::detail::is_permutation_tag (
first1, last1, first2, last2, pred,
typename std::iterator_traits<ForwardIterator1>::iterator_category (),
typename std::iterator_traits<ForwardIterator2>::iterator_category ());
}
#endif
// There are already range-based versions of these.
}}
}} // namespace boost and algorithm
#endif // BOOST_ALGORITHM_IS_PERMUTATION_HPP
#endif // BOOST_ALGORITHM_IS_PERMUTATION14_HPP

View file

@ -12,13 +12,11 @@
#ifndef BOOST_ALGORITHM_MISMATCH_HPP
#define BOOST_ALGORITHM_MISMATCH_HPP
#include <algorithm> // for std::mismatch
#include <utility> // for std::pair
#include <algorithm> // for std::mismatch
#include <utility> // for std::pair
namespace boost { namespace algorithm {
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
/// InputIterator2 first2, InputIterator2 last2,
/// BinaryPredicate pred )
@ -29,10 +27,11 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
/// \param first2 The start of the second range.
/// \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 (
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred )
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred )
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
if ( !pred ( *first1, *first2 ))
@ -50,8 +49,8 @@ std::pair<InputIterator1, InputIterator2> mismatch (
/// \param last2 One past the end of the second range.
template <class InputIterator1, class InputIterator2>
std::pair<InputIterator1, InputIterator2> mismatch (
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2 )
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2 )
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
if ( *first1 != *first2 )
@ -59,7 +58,7 @@ std::pair<InputIterator1, InputIterator2> mismatch (
return std::pair<InputIterator1, InputIterator2>(first1, first2);
}
// There are already range-based versions of these.
// There are already range-based versions of these.
}} // namespace boost and algorithm

View file

@ -20,7 +20,11 @@
#include <boost/type_traits/remove_const.hpp>
#include <boost/array.hpp>
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
#include <boost/tr1/tr1/unordered_map>
#else
#include <unordered_map>
#endif
#include <boost/algorithm/searching/detail/debugging.hpp>
@ -35,7 +39,11 @@ namespace boost { namespace algorithm { namespace detail {
template<typename key_type, typename value_type>
class skip_table<key_type, value_type, false> {
private:
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
typedef std::tr1::unordered_map<key_type, value_type> skip_map;
#else
typedef std::unordered_map<key_type, value_type> skip_map;
#endif
const value_type k_default_value;
skip_map skip_;

View file

@ -12,7 +12,7 @@
#define BOOST_STRING_CONCEPT_HPP
#include <boost/concept_check.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>

View file

@ -12,7 +12,7 @@
#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/iterator.hpp>
#include <boost/algorithm/string/detail/find_format_store.hpp>

View file

@ -12,7 +12,7 @@
#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/algorithm/string/detail/find_format_store.hpp>

View file

@ -12,7 +12,7 @@
#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
namespace boost {
namespace algorithm {

View file

@ -12,7 +12,7 @@
#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/function.hpp>

View file

@ -15,7 +15,7 @@
#include <boost/algorithm/string/constants.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/empty.hpp>
@ -142,7 +142,6 @@ namespace boost {
ForwardIteratorT End,
std::forward_iterator_tag ) const
{
typedef ForwardIteratorT input_iterator_type;
typedef iterator_range<ForwardIteratorT> result_type;
first_finder_type first_finder(
@ -263,7 +262,6 @@ namespace boost {
ForwardIteratorT End,
unsigned int N) const
{
typedef ForwardIteratorT input_iterator_type;
typedef iterator_range<ForwardIteratorT> result_type;
// Sanity check
@ -298,7 +296,6 @@ namespace boost {
ForwardIteratorT End,
unsigned int N) const
{
typedef ForwardIteratorT input_iterator_type;
typedef iterator_range<ForwardIteratorT> result_type;
// Sanity check
@ -362,7 +359,6 @@ namespace boost {
unsigned int N,
std::random_access_iterator_tag )
{
typedef ForwardIteratorT input_iterator_type;
typedef iterator_range<ForwardIteratorT> result_type;
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
@ -436,7 +432,6 @@ namespace boost {
unsigned int N,
std::random_access_iterator_tag )
{
typedef ForwardIteratorT input_iterator_type;
typedef iterator_range<ForwardIteratorT> result_type;
if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
@ -627,8 +622,6 @@ namespace boost {
{
#if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
return iterator_range<const ForwardIterator2T>(this->m_Range);
#elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
return iterator_range<ForwardIterator2T>(m_Range.begin(), m_Range.end());
#else
return m_Range;
#endif

View file

@ -14,7 +14,7 @@
#include <boost/algorithm/string/config.hpp>
#include <boost/regex.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>

View file

@ -12,7 +12,7 @@
#define BOOST_STRING_FORMATTER_DETAIL_HPP
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/const_iterator.hpp>

View file

@ -13,7 +13,7 @@
#include <boost/algorithm/string/config.hpp>
#include <functional>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
namespace boost {
namespace algorithm {

View file

@ -13,7 +13,7 @@
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>

View file

@ -13,7 +13,7 @@
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>

View file

@ -13,7 +13,7 @@
#include <deque>
#include <boost/detail/iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/const_iterator.hpp>

View file

@ -15,7 +15,7 @@
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>
@ -132,12 +132,7 @@ namespace boost {
// increment
void increment()
{
if(m_Match.begin() == m_Match.end())
m_Match=this->do_find(m_Match.end(),m_End);
else {
input_iterator_type last = m_Match.begin();
m_Match=this->do_find(++last,m_End);
}
m_Match=this->do_find(m_Match.end(),m_End);
}
// comparison
@ -235,7 +230,7 @@ namespace boost {
\post eof()==true
*/
split_iterator() {}
split_iterator() { m_bEof = true; }
//! Copy constructor
/*!
Construct a copy of the split_iterator

View file

@ -13,7 +13,7 @@
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>

View file

@ -13,7 +13,7 @@
#include <boost/detail/iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/algorithm/string/detail/formatter.hpp>

View file

@ -16,7 +16,7 @@
#include <iterator>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>

View file

@ -17,7 +17,7 @@
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/algorithm/string/compare.hpp>
#include <boost/algorithm/string/find.hpp>

View file

@ -14,7 +14,7 @@
#include <boost/algorithm/string/config.hpp>
#include <boost/regex.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>

View file

@ -13,7 +13,7 @@
#include <boost/algorithm/string/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>

View file

@ -36,47 +36,6 @@ namespace boost {
// sequence traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//! Native replace tester
/*!
Declare an override of this tester function with return
type boost::string_algo::yes_type for a sequence with this property.
\return yes_type if the container has basic_string like native replace
method.
*/
no_type has_native_replace_tester(...);
//! Stable iterators tester
/*!
Declare an override of this tester function with return
type boost::string_algo::yes_type for a sequence with this property.
\return yes_type if the sequence's insert/replace/erase methods do not invalidate
existing iterators.
*/
no_type has_stable_iterators_tester(...);
//! const time insert tester
/*!
Declare an override of this tester function with return
type boost::string_algo::yes_type for a sequence with this property.
\return yes_type if the sequence's insert method is working in constant time
*/
no_type has_const_time_insert_tester(...);
//! const time erase tester
/*!
Declare an override of this tester function with return
type boost::string_algo::yes_type for a sequence with this property.
\return yes_type if the sequence's erase method is working in constant time
*/
no_type has_const_time_erase_tester(...);
#endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//! Native replace trait
/*!
@ -86,20 +45,12 @@ namespace boost {
class has_native_replace
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
enum { value = false };
# else
BOOST_STATIC_CONSTANT(bool, value=false);
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<has_native_replace<T>::value> type;
@ -114,20 +65,12 @@ namespace boost {
template< typename T >
class has_stable_iterators
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
enum { value = false };
# else
BOOST_STATIC_CONSTANT(bool, value=false);
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<has_stable_iterators<T>::value> type;
};
@ -141,20 +84,12 @@ namespace boost {
template< typename T >
class has_const_time_insert
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_const_time_insert_tester(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
enum { value = false };
# else
BOOST_STATIC_CONSTANT(bool, value=false);
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<has_const_time_insert<T>::value> type;
};
@ -168,20 +103,12 @@ namespace boost {
template< typename T >
class has_const_time_erase
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_const_time_erase_tester(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
enum { value = false };
# else
BOOST_STATIC_CONSTANT(bool, value=false);
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<has_const_time_erase<T>::value> type;
};

View file

@ -20,22 +20,6 @@ namespace boost {
// std::list<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators tester
template<typename T, typename AllocT>
yes_type has_stable_iterators_tester( const ::std::list<T,AllocT>* );
// const time insert tester
template<typename T, typename AllocT>
yes_type has_const_time_insert_tester( const ::std::list<T,AllocT>* );
// const time erase tester
template<typename T, typename AllocT>
yes_type has_const_time_erase_tester( const ::std::list<T,AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators trait
template<typename T, typename AllocT>
@ -75,7 +59,6 @@ namespace boost {
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
typedef mpl::bool_<has_const_time_erase<T>::value> type;
};
#endif
} // namespace algorithm

View file

@ -20,25 +20,6 @@ namespace boost {
// SGI's std::rope<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_native_replace_tester( const std::rope<T, TraitsT, AllocT>* );
// stable iterators tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_stable_iterators_tester( const std::rope<T, TraitsT, AllocT>* );
// const time insert tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_const_time_insert_tester( const std::rope<T, TraitsT, AllocT>* );
// const time erase tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_const_time_erase_tester( const std::rope<T, TraitsT, AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace trait
template<typename T, typename TraitsT, typename AllocT>
@ -91,7 +72,6 @@ namespace boost {
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
typedef mpl::bool_<value> type;
};
#endif
} // namespace algorithm

View file

@ -21,21 +21,6 @@ namespace boost {
// SGI's std::slist<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators tester
template<typename T, typename AllocT>
yes_type has_stable_iterators_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
// const time insert tester
template<typename T, typename AllocT>
yes_type has_const_time_insert_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
// const time erase tester
template<typename T, typename AllocT>
yes_type has_const_time_erase_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators trait
template<typename T, typename AllocT>
@ -75,7 +60,6 @@ namespace boost {
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
typedef mpl::bool_<has_const_time_erase<T>::value> type;
};
#endif
} // namespace algorithm

View file

@ -20,13 +20,6 @@ namespace boost {
// std::basic_string<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_native_replace_tester( const std::basic_string<T, TraitsT, AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace trait
template<typename T, typename TraitsT, typename AllocT>
@ -43,7 +36,6 @@ namespace boost {
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
} // namespace algorithm
} // namespace boost

View file

@ -17,7 +17,7 @@
#include <boost/range/end.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/as_literal.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/algorithm/string/detail/trim.hpp>
#include <boost/algorithm/string/classification.hpp>

View file

@ -0,0 +1,31 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_HPP
#define BOOST_ALIGN_HPP
/**
Boost.Align
all headers.
@note This header includes all public headers
of the Boost.Align library.
@file
@author Glen Fernandes
*/
#include <boost/align/align.hpp>
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_allocator.hpp>
#include <boost/align/aligned_allocator_adaptor.hpp>
#include <boost/align/aligned_delete.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/align/is_aligned.hpp>
#endif

View file

@ -0,0 +1,86 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGN_HPP
#define BOOST_ALIGN_ALIGN_HPP
/**
Function align.
@file
@author Glen Fernandes
*/
#include <boost/config.hpp>
/**
@cond
*/
#if !defined(BOOST_NO_CXX11_STD_ALIGN)
#include <boost/align/detail/align_cxx11.hpp>
#else
#include <boost/align/detail/align.hpp>
#endif
#if defined(BOOST_NO_CXX11_STD_ALIGN)
/**
@endcond
*/
/**
Boost namespace.
*/
namespace boost {
/**
Alignment namespace.
*/
namespace alignment {
/**
If it is possible to fit `size` bytes of storage
aligned by `alignment` into the buffer pointed to by
`ptr` with length `space`, the function updates `ptr`
to point to the first possible address of such
storage and decreases `space` by the number of bytes
used for alignment. Otherwise, the function does
nothing.
@param alignment Shall be a fundamental alignment
value or an extended alignment value, and shall be
a power of two.
@param size The size in bytes of storage to fit into
the buffer.
@param ptr Shall point to contiguous storage of at
least `space` bytes.
@param space The length of the buffer.
@return A null pointer if the requested aligned
buffer would not fit into the available space,
otherwise the adjusted value of `ptr`.
@remark **Note:** The function updates its `ptr` and
space arguments so that it can be called repeatedly
with possibly different `alignment` and `size`
arguments for the same buffer.
*/
inline void* align(std::size_t alignment, std::size_t size,
void*& ptr, std::size_t& space);
}
}
/**
@cond
*/
#endif
/**
@endcond
*/
#endif

View file

@ -0,0 +1,100 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOC_HPP
#define BOOST_ALIGN_ALIGNED_ALLOC_HPP
/**
Functions aligned_alloc and aligned_free.
@file
@author Glen Fernandes
*/
#include <boost/config.hpp>
/**
@cond
*/
#if defined(BOOST_HAS_UNISTD_H)
#include <unistd.h>
#endif
#if defined(__APPLE__) || defined(__APPLE_CC__) || defined(macintosh)
#include <AvailabilityMacros.h>
#endif
#if defined(_MSC_VER)
#include <boost/align/detail/aligned_alloc_msvc.hpp>
#elif defined(__MINGW32__) && (__MSVCRT_VERSION__ >= 0x0700)
#include <boost/align/detail/aligned_alloc_msvc.hpp>
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#include <boost/align/detail/aligned_alloc_posix.hpp>
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
#include <boost/align/detail/aligned_alloc_macos.hpp>
#elif defined(__ANDROID__)
#include <boost/align/detail/aligned_alloc_android.hpp>
#elif defined(__SunOS_5_11) || defined(__SunOS_5_12)
#include <boost/align/detail/aligned_alloc_posix.hpp>
#elif defined(sun) || defined(__sun)
#include <boost/align/detail/aligned_alloc_sunos.hpp>
#elif (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600)
#include <boost/align/detail/aligned_alloc_posix.hpp>
#else
#include <boost/align/detail/aligned_alloc.hpp>
#endif
/**
@endcond
*/
/**
Boost namespace.
*/
namespace boost {
/**
Alignment namespace.
*/
namespace alignment {
/**
Allocates space for an object whose alignment is
specified by `alignment`, whose size is
specified by `size`, and whose value is
indeterminate.
@param alignment Shall be a power of two.
@param size Size of space to allocate.
@return A null pointer or a pointer to the
allocated space.
@remark **Note:** On certain platforms, the
alignment may be rounded up to `alignof(void*)`
and the space allocated may be slightly larger
than `size` bytes, by an additional
`sizeof(void*)` and `alignment - 1` bytes.
*/
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT;
/**
Causes the space pointed to by `ptr` to be
deallocated, that is, made available for further
allocation. If `ptr` is a null pointer, no
action occurs. Otherwise, if the argument does
not match a pointer earlier returned by the
`aligned_alloc` function, or if the space has
been deallocated by a call to `aligned_free`,
the behavior is undefined.
*/
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT;
}
}
#endif

View file

@ -0,0 +1,287 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_HPP
/**
Class template aligned_allocator.
@file
@author Glen Fernandes
*/
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_allocator_forward.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/align/detail/addressof.hpp>
#include <boost/align/detail/is_alignment_const.hpp>
#include <boost/align/detail/max_align.hpp>
#include <boost/align/detail/max_count_of.hpp>
#include <new>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
/**
Boost namespace.
*/
namespace boost {
/**
Alignment namespace.
*/
namespace alignment {
/**
Class template aligned_allocator.
@tparam Alignment Is the minimum alignment to specify
for allocations, if it is larger than the alignment
of the value type. It shall be a power of two.
@remark **Note:** Except for the destructor, member
functions of the aligned allocator shall not
introduce data races as a result of concurrent calls
to those member functions from different threads.
Calls to these functions that allocate or deallocate
a particular unit of storage shall occur in a single
total order, and each such deallocation call shall
happen before the next allocation (if any) in this
order.
@note Specifying minimum alignment is generally only
suitable for containers such as vector and undesirable
with other, node-based, containers. For node-based
containers, such as list, the node object would have
the minimum alignment specified instead of the value
type object.
*/
template<class T, std::size_t Alignment>
class aligned_allocator {
/**
@cond
*/
BOOST_STATIC_ASSERT(detail::
is_alignment_const<Alignment>::value);
/**
@endcond
*/
public:
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef void* void_pointer;
typedef const void* const_void_pointer;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T& reference;
typedef const T& const_reference;
private:
enum {
TypeAlign = alignment_of<value_type>::value,
MaxAlign = detail::
max_align<Alignment, TypeAlign>::value
};
public:
/**
Rebind allocator.
*/
template<class U>
struct rebind {
typedef aligned_allocator<U, Alignment> other;
};
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
aligned_allocator()
BOOST_NOEXCEPT = default;
#else
aligned_allocator()
BOOST_NOEXCEPT {
}
#endif
template<class U>
aligned_allocator(const aligned_allocator<U,
Alignment>&) BOOST_NOEXCEPT {
}
/**
@return The actual address of the object referenced
by `value`, even in the presence of an overloaded
operator&.
*/
pointer address(reference value) const
BOOST_NOEXCEPT {
return detail::addressof(value);
}
/**
@return The actual address of the object referenced
by `value`, even in the presence of an overloaded
operator&.
*/
const_pointer address(const_reference value) const
BOOST_NOEXCEPT {
return detail::addressof(value);
}
/**
@return A pointer to the initial element of an array
of storage of size `n * sizeof(T)`, aligned on the
maximum of the minimum alignment specified and the
alignment of objects of type `T`.
@remark **Throw:** Throws `std::bad_alloc` if the
storage cannot be obtained.
@remark **Note:** The storage is obtained by calling
`aligned_alloc(std::size_t, std::size_t)`.
*/
pointer allocate(size_type size, const_void_pointer = 0) {
void* p = aligned_alloc(MaxAlign, sizeof(T) * size);
if (!p && size > 0) {
boost::throw_exception(std::bad_alloc());
}
return static_cast<T*>(p);
}
/**
Deallocates the storage referenced by `ptr`.
@param ptr Shall be a pointer value obtained from
`allocate()`.
@remark **Note:** Uses
`alignment::aligned_free(void*)`.
*/
void deallocate(pointer ptr, size_type) {
alignment::aligned_free(ptr);
}
/**
@return The largest value `N` for which the call
`allocate(N)` might succeed.
*/
BOOST_CONSTEXPR size_type max_size() const
BOOST_NOEXCEPT {
return detail::max_count_of<T>::value;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
/**
Calls global
`new((void*)ptr) U(std::forward<Args>(args)...)`.
*/
template<class U, class... Args>
void construct(U* ptr, Args&&... args) {
void* p = ptr;
::new(p) U(std::forward<Args>(args)...);
}
#else
/**
Calls global
`new((void*)ptr) U(std::forward<V>(value))`.
*/
template<class U, class V>
void construct(U* ptr, V&& value) {
void* p = ptr;
::new(p) U(std::forward<V>(value));
}
#endif
#else
/**
Calls global `new((void*)ptr) U(value)`.
*/
template<class U, class V>
void construct(U* ptr, const V& value) {
void* p = ptr;
::new(p) U(value);
}
#endif
/**
Calls global `new((void*)ptr) U()`.
*/
template<class U>
void construct(U* ptr) {
void* p = ptr;
::new(p) U();
}
/**
Calls `ptr->~U()`.
*/
template<class U>
void destroy(U* ptr) {
(void)ptr;
ptr->~U();
}
};
/**
Class template aligned_allocator
specialization.
*/
template<std::size_t Alignment>
class aligned_allocator<void, Alignment> {
/**
@cond
*/
BOOST_STATIC_ASSERT(detail::
is_alignment_const<Alignment>::value);
/**
@endcond
*/
public:
typedef void value_type;
typedef void* pointer;
typedef const void* const_pointer;
/**
Rebind allocator.
*/
template<class U>
struct rebind {
typedef aligned_allocator<U, Alignment> other;
};
};
/**
@return `true`.
*/
template<class T1, class T2, std::size_t Alignment>
inline bool operator==(const aligned_allocator<T1,
Alignment>&, const aligned_allocator<T2,
Alignment>&) BOOST_NOEXCEPT
{
return true;
}
/**
@return `false`.
*/
template<class T1, class T2, std::size_t Alignment>
inline bool operator!=(const aligned_allocator<T1,
Alignment>&, const aligned_allocator<T2,
Alignment>&) BOOST_NOEXCEPT
{
return false;
}
}
}
#endif

View file

@ -0,0 +1,325 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
/**
Class template aligned_allocator_adaptor.
@file
@author Glen Fernandes
*/
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/align/align.hpp>
#include <boost/align/aligned_allocator_adaptor_forward.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/align/detail/addressof.hpp>
#include <boost/align/detail/is_alignment_const.hpp>
#include <boost/align/detail/max_align.hpp>
#include <new>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <memory>
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
/**
Boost namespace.
*/
namespace boost {
/**
Alignment namespace.
*/
namespace alignment {
/**
Class template aligned_allocator_adaptor.
@tparam Alignment Is the minimum alignment to specify
for allocations, if it is larger than the alignment
of the value type. The value of `Alignment` shall be
a fundamental alignment value or an extended alignment
value, and shall be a power of two.
@note This adaptor can be used with a C++11 allocator
whose pointer type is a smart pointer but the adaptor
will expose only raw pointers.
*/
template<class Allocator, std::size_t Alignment>
class aligned_allocator_adaptor
: public Allocator {
/**
@cond
*/
BOOST_STATIC_ASSERT(detail::
is_alignment_const<Alignment>::value);
/**
@endcond
*/
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
/**
Exposition only.
*/
typedef std::allocator_traits<Allocator> Traits;
typedef typename Traits::
template rebind_alloc<char> CharAlloc;
typedef typename Traits::
template rebind_traits<char> CharTraits;
typedef typename CharTraits::pointer CharPtr;
#else
typedef typename Allocator::
template rebind<char>::other CharAlloc;
typedef typename CharAlloc::pointer CharPtr;
#endif
public:
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
typedef typename Traits::value_type value_type;
typedef typename Traits::size_type size_type;
#else
typedef typename Allocator::value_type value_type;
typedef typename Allocator::size_type size_type;
#endif
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef void* void_pointer;
typedef const void* const_void_pointer;
typedef std::ptrdiff_t difference_type;
private:
enum {
TypeAlign = alignment_of<value_type>::value,
PtrAlign = alignment_of<CharPtr>::value,
BlockAlign = detail::
max_align<PtrAlign, TypeAlign>::value,
MaxAlign = detail::
max_align<Alignment, BlockAlign>::value
};
public:
/**
Rebind allocator.
*/
template<class U>
struct rebind {
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
typedef aligned_allocator_adaptor<typename Traits::
template rebind_alloc<U>, Alignment> other;
#else
typedef aligned_allocator_adaptor<typename Allocator::
template rebind<U>::other, Alignment> other;
#endif
};
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
/**
Value-initializes the `Allocator`
base class.
*/
aligned_allocator_adaptor() = default;
#else
/**
Value-initializes the `Allocator`
base class.
*/
aligned_allocator_adaptor()
: Allocator() {
}
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
/**
Initializes the `Allocator` base class with
`std::forward<A>(alloc)`.
@remark **Require:** `Allocator` shall be
constructible from `A`.
*/
template<class A>
explicit aligned_allocator_adaptor(A&& alloc)
BOOST_NOEXCEPT
: Allocator(std::forward<A>(alloc)) {
}
#else
/**
Initializes the `Allocator` base class with
`alloc`.
@remark **Require:** `Allocator` shall be
constructible from `A`.
*/
template<class A>
explicit aligned_allocator_adaptor(const A& alloc)
BOOST_NOEXCEPT
: Allocator(alloc) {
}
#endif
/**
Initializes the `Allocator` base class with the
base from other.
*/
template<class U>
aligned_allocator_adaptor(const
aligned_allocator_adaptor<U, Alignment>& other)
BOOST_NOEXCEPT
: Allocator(other.base()) {
}
/**
@return `static_cast<Allocator&>(*this)`.
*/
Allocator& base()
BOOST_NOEXCEPT {
return static_cast<Allocator&>(*this);
}
/**
@return `static_cast<const Allocator&>(*this)`.
*/
const Allocator& base() const
BOOST_NOEXCEPT {
return static_cast<const Allocator&>(*this);
}
/**
@param size The size of the value type object to
allocate.
@return A pointer to the initial element of an
array of storage of size `n * sizeof(value_type)`,
aligned on the maximum of the minimum alignment
specified and the alignment of objects of type
`value_type`.
@remark **Throw:** Throws an exception thrown from
`A2::allocate` if the storage cannot be obtained.
@remark **Note:** The storage is obtained by calling
`A2::allocate` on an object `a2`, where `a2` of
type `A2` is a rebound copy of `base()` where its
`value_type` is unspecified.
*/
pointer allocate(size_type size) {
std::size_t n1 = size * sizeof(value_type);
std::size_t n2 = n1 + MaxAlign - 1;
CharAlloc a(base());
CharPtr p1 = a.allocate(sizeof p1 + n2);
void* p2 = detail::addressof(*p1) + sizeof p1;
(void)align(MaxAlign, n1, p2, n2);
void* p3 = static_cast<CharPtr*>(p2) - 1;
::new(p3) CharPtr(p1);
return static_cast<pointer>(p2);
}
/**
@param hint is a value obtained by calling
`allocate()` on any equivalent aligned allocator
adaptor object, or else `nullptr`.
@param size The size of the value type object to
allocate.
@return A pointer to the initial element of an
array of storage of size `n * sizeof(value_type)`,
aligned on the maximum of the minimum alignment
specified and the alignment of objects of type
`value_type`.
@remark **Throw:** Throws an exception thrown from
`A2::allocate` if the storage cannot be obtained.
@remark **Note:** The storage is obtained by calling
`A2::allocate` on an object `a2`, where `a2` of
type `A2` is a rebound copy of `base()` where its
`value_type` is unspecified.
*/
pointer allocate(size_type size, const_void_pointer hint) {
std::size_t n1 = size * sizeof(value_type);
std::size_t n2 = n1 + MaxAlign - 1;
CharPtr h = CharPtr();
if (hint) {
h = *(static_cast<const CharPtr*>(hint) - 1);
}
CharAlloc a(base());
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
CharPtr p1 = CharTraits::allocate(a, sizeof p1 +
n2, h);
#else
CharPtr p1 = a.allocate(sizeof p1 + n2, h);
#endif
void* p2 = detail::addressof(*p1) + sizeof p1;
(void)align(MaxAlign, n1, p2, n2);
void* p3 = static_cast<CharPtr*>(p2) - 1;
::new(p3) CharPtr(p1);
return static_cast<pointer>(p2);
}
/**
Deallocates the storage referenced by `ptr`.
@param ptr Shall be a pointer value obtained from
`allocate()`.
@param size Shall equal the value passed as the
first argument to the invocation of `allocate`
which returned `ptr`.
@remark **Note:** Uses `A2::deallocate` on an object
`a2`, where `a2` of type `A2` is a rebound copy of
`base()` where its `value_type` is unspecified.
*/
void deallocate(pointer ptr, size_type size) {
CharPtr* p1 = reinterpret_cast<CharPtr*>(ptr) - 1;
CharPtr p2 = *p1;
p1->~CharPtr();
CharAlloc a(base());
a.deallocate(p2, size * sizeof(value_type) +
MaxAlign + sizeof p2);
}
};
/**
@return `a.base() == b.base()`.
*/
template<class A1, class A2, std::size_t Alignment>
inline bool operator==(const aligned_allocator_adaptor<A1,
Alignment>& a, const aligned_allocator_adaptor<A2,
Alignment>& b) BOOST_NOEXCEPT
{
return a.base() == b.base();
}
/**
@return `!(a == b)`.
*/
template<class A1, class A2, std::size_t Alignment>
inline bool operator!=(const aligned_allocator_adaptor<A1,
Alignment>& a, const aligned_allocator_adaptor<A2,
Alignment>& b) BOOST_NOEXCEPT
{
return !(a == b);
}
}
}
#endif

View file

@ -0,0 +1,38 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_FORWARD_HPP
/**
Class template aligned_allocator_adaptor
forward declaration.
@note This header provides a forward declaration for
the `aligned_allocator_adaptor` class template.
@file
@author Glen Fernandes
*/
#include <cstddef>
/**
@cond
*/
namespace boost {
namespace alignment {
template<class Allocator, std::size_t Alignment = 1>
class aligned_allocator_adaptor;
}
}
/**
@endcond
*/
#endif

View file

@ -0,0 +1,38 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_FORWARD_HPP
/**
Class template aligned_allocator
forward declaration.
@note This header provides a forward declaration
for the `aligned_allocator` class template.
@file
@author Glen Fernandes
*/
#include <cstddef>
/**
@cond
*/
namespace boost {
namespace alignment {
template<class T, std::size_t Alignment = 1>
class aligned_allocator;
}
}
/**
@endcond
*/
#endif

View file

@ -0,0 +1,56 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_DELETE_HPP
#define BOOST_ALIGN_ALIGNED_DELETE_HPP
/**
Class aligned_delete.
@file
@author Glen Fernandes
*/
#include <boost/config.hpp>
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_delete_forward.hpp>
/**
Boost namespace.
*/
namespace boost {
/**
Alignment namespace.
*/
namespace alignment {
/**
Class aligned_delete.
*/
class aligned_delete {
public:
/**
Calls `~T()` on `ptr` to destroy the object and then
calls `aligned_free` on `ptr` to free the allocated
memory.
@remark **Note:** If `T` is an incomplete type, the
program is ill-formed.
*/
template<class T>
void operator()(T* ptr) const
BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(ptr->~T())) {
if (ptr) {
ptr->~T();
alignment::aligned_free(ptr);
}
}
};
}
}
#endif

View file

@ -0,0 +1,35 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_DELETE_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_DELETE_FORWARD_HPP
/**
Class aligned_delete
forward declaration.
@note This header provides a forward declaration
for the `aligned_delete` class.
@file
@author Glen Fernandes
*/
/**
@cond
*/
namespace boost {
namespace alignment {
class aligned_delete;
}
}
/**
@endcond
*/
#endif

View file

@ -0,0 +1,78 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNMENT_OF_HPP
#define BOOST_ALIGN_ALIGNMENT_OF_HPP
/**
Class template alignment_of.
@file
@author Glen Fernandes
*/
#include <boost/config.hpp>
#include <boost/align/alignment_of_forward.hpp>
#include <boost/align/detail/type_traits.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <boost/align/detail/alignment_of_cxx11.hpp>
#elif defined(BOOST_MSVC)
#include <boost/align/detail/alignment_of_msvc.hpp>
#elif defined(BOOST_CLANG)
#include <boost/align/detail/alignment_of_clang.hpp>
#elif defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
#include <boost/align/detail/alignment_of_gcc.hpp>
#elif defined(__CODEGEARC__)
#include <boost/align/detail/alignment_of_codegear.hpp>
#elif defined(__GNUC__) && defined(__unix__) && !defined(__LP64__)
#include <boost/align/detail/alignment_of.hpp>
#elif __GNUC__ > 4
#include <boost/align/detail/alignment_of_gcc.hpp>
#elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
#include <boost/align/detail/alignment_of_gcc.hpp>
#else
#include <boost/align/detail/alignment_of.hpp>
#endif
/**
Boost namespace.
*/
namespace boost {
/**
Alignment namespace.
*/
namespace alignment {
/**
Class template alignment_of.
@remark **Value:** `alignof(T)`.
*/
template<class T>
struct alignment_of {
/**
@enum
*/
enum {
/**
@cond
*/
value = detail::alignment_of<typename
detail::remove_cv<typename
detail::remove_all_extents<typename
detail::remove_reference<T>::
type>::type>::type>::value
/**
@endcond
*/
};
};
}
}
#endif

View file

@ -0,0 +1,36 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
#define BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
/**
Class template alignment_of
forward declaration.
@note This header provides a forward declaration
for the `alignment_of` class template.
@file
@author Glen Fernandes
*/
/**
@cond
*/
namespace boost {
namespace alignment {
template<class T>
struct alignment_of;
}
}
/**
@endcond
*/
#endif

View file

@ -0,0 +1,27 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ADDRESS_HPP
#define BOOST_ALIGN_DETAIL_ADDRESS_HPP
#include <boost/cstdint.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
#if defined(BOOST_HAS_INTPTR_T)
typedef boost::uintptr_t address_t;
#else
typedef std::size_t address_t;
#endif
}
}
}
#endif

View file

@ -0,0 +1,32 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ADDRESSOF_HPP
#define BOOST_ALIGN_DETAIL_ADDRESSOF_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ADDRESSOF)
#include <memory>
#else
#include <boost/core/addressof.hpp>
#endif
namespace boost {
namespace alignment {
namespace detail {
#if !defined(BOOST_NO_CXX11_ADDRESSOF)
using std::addressof;
#else
using boost::addressof;
#endif
}
}
}
#endif

View file

@ -0,0 +1,38 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_HPP
#include <boost/assert.hpp>
#include <boost/align/detail/address.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
inline void* align(std::size_t alignment, std::size_t size,
void*& ptr, std::size_t& space)
{
BOOST_ASSERT(detail::is_alignment(alignment));
std::size_t n = detail::address_t(ptr) & (alignment - 1);
if (n != 0) {
n = alignment - n;
}
void* p = 0;
if (n <= space && size <= space - n) {
p = static_cast<char*>(ptr) + n;
ptr = p;
space -= n;
}
return p;
}
}
}
#endif

View file

@ -0,0 +1,20 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
#include <memory>
namespace boost {
namespace alignment {
using std::align;
}
}
#endif

View file

@ -0,0 +1,53 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/align/align.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstdlib>
namespace boost {
namespace alignment {
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
enum {
void_align = alignment_of<void*>::value,
};
if (alignment < void_align) {
alignment = void_align;
}
std::size_t n = size + alignment - 1;
void* p1 = 0;
void* p2 = std::malloc(n + sizeof p1);
if (p2) {
p1 = static_cast<char*>(p2) + sizeof p1;
(void)align(alignment, size, p1, n);
*(static_cast<void**>(p1) - 1) = p2;
}
return p1;
}
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT
{
if (ptr) {
void* p = *(static_cast<void**>(ptr) - 1);
std::free(p);
}
}
}
}
#endif

View file

@ -0,0 +1,35 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstddef>
#include <malloc.h>
namespace boost {
namespace alignment {
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::memalign(alignment, size);
}
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT
{
::free(ptr);
}
}
}
#endif

View file

@ -0,0 +1,48 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstddef>
#include <stdlib.h>
namespace boost {
namespace alignment {
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
enum {
void_size = sizeof(void*)
};
if (!size) {
return 0;
}
if (alignment < void_size) {
alignment = void_size;
}
void* p;
if (::posix_memalign(&p, alignment, size) != 0) {
p = 0;
}
return p;
}
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT
{
::free(ptr);
}
}
}
#endif

View file

@ -0,0 +1,35 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstddef>
#include <malloc.h>
namespace boost {
namespace alignment {
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::_aligned_malloc(size, alignment);
}
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT
{
::_aligned_free(ptr);
}
}
}
#endif

View file

@ -0,0 +1,45 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstddef>
#include <stdlib.h>
namespace boost {
namespace alignment {
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
enum {
void_size = sizeof(void*)
};
if (alignment < void_size) {
alignment = void_size;
}
void* p;
if (::posix_memalign(&p, alignment, size) != 0) {
p = 0;
}
return p;
}
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT
{
::free(ptr);
}
}
}
#endif

View file

@ -0,0 +1,35 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/align/detail/is_alignment.hpp>
#include <cstddef>
#include <stdlib.h>
namespace boost {
namespace alignment {
inline void* aligned_alloc(std::size_t alignment,
std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::memalign(alignment, size);
}
inline void aligned_free(void* ptr)
BOOST_NOEXCEPT
{
::free(ptr);
}
}
}
#endif

View file

@ -0,0 +1,29 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
#include <boost/align/detail/min_size.hpp>
#include <boost/align/detail/padded.hpp>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of {
enum {
value = detail::min_size<sizeof(T),
sizeof(detail::padded<T>) - sizeof(T)>::value
};
};
}
}
}
#endif

View file

@ -0,0 +1,25 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of {
enum {
value = __alignof(T)
};
};
}
}
}
#endif

View file

@ -0,0 +1,25 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of {
enum {
value = alignof(T)
};
};
}
}
}
#endif

View file

@ -0,0 +1,22 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP
#include <type_traits>
namespace boost {
namespace alignment {
namespace detail {
using std::alignment_of;
}
}
}
#endif

View file

@ -0,0 +1,25 @@
/*
Copyright (c) 2014 Glen Joseph Fernandes
glenfe at live dot com
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of {
enum {
value = __alignof__(T)
};
};
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show more