Updated boost to 1.54

This commit is contained in:
Alex Zolotarev 2013-07-03 14:01:35 +03:00 committed by Alex Zolotarev
parent 1d7a209668
commit 996bbfcabd
1966 changed files with 195695 additions and 23932 deletions

View file

@ -185,8 +185,18 @@ namespace detail
inline void ignore_variable(void const *) {}
#define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X)\
namespace detail { inline void BOOST_PP_CAT(ignore_, X)() { boost::accumulators::detail::ignore_variable(&X); } }
#define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \
namespace detail \
{ \
struct BOOST_PP_CAT(ignore_, X) \
{ \
void ignore() \
{ \
boost::accumulators::detail::ignore_variable(&X); \
} \
}; \
} \
/**/
}
}} // namespace boost::accumulators

View file

@ -215,7 +215,7 @@ namespace boost { namespace accumulators
template<typename Args>
void on_drop(Args const &args)
{
// cache the result at the point this calcuation was dropped
// cache the result at the point this calculation was dropped
BOOST_ASSERT(!this->has_result());
this->set(this->Accumulator::result(args));
}

View file

@ -356,7 +356,7 @@ namespace boost { namespace accumulators
type;
};
// BUGBUG work around a MPL bug wrt map insertion
// BUGBUG work around an MPL bug wrt map insertion
template<typename FeatureMap, typename Feature>
struct insert_feature
: mpl::eval_if<

View file

@ -9,11 +9,13 @@
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
BOOST_PARAMETER_KEYWORD(tag, accumulator)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(accumulator)
}} // namespace boost::accumulators

View file

@ -9,11 +9,13 @@
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
BOOST_PARAMETER_KEYWORD(tag, sample)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(sample)
}} // namespace boost::accumulators

View file

@ -9,12 +9,14 @@
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
// The weight of a single sample
BOOST_PARAMETER_KEYWORD(tag, weight)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weight)
}} // namespace boost::accumulators

View file

@ -9,12 +9,14 @@
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
// The weight accumulator
BOOST_PARAMETER_KEYWORD(tag, weights)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weights)
}} // namespace boost::accumulators

View file

@ -20,6 +20,7 @@
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/numeric/functional_fwd.hpp>
#include <boost/accumulators/numeric/detail/function1.hpp>
#include <boost/accumulators/numeric/detail/function2.hpp>
@ -166,6 +167,7 @@ namespace boost { namespace numeric
{ \
op::Name const &Name = boost::detail::pod_singleton<op::Name>::instance; \
} \
BOOST_ACCUMULATORS_IGNORE_GLOBAL(Name) \
/**/
/// INTERNAL ONLY
@ -416,6 +418,14 @@ namespace boost { namespace numeric
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;
op::as_one const &as_one = boost::detail::pod_singleton<op::as_one>::instance;
BOOST_ACCUMULATORS_IGNORE_GLOBAL(min_assign)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(max_assign)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(average)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_min)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_max)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_zero)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_one)
}
///////////////////////////////////////////////////////////////////////////////

View file

@ -15,6 +15,7 @@
#include <boost/range.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
@ -34,6 +35,9 @@ namespace boost { namespace accumulators
BOOST_PARAMETER_NESTED_KEYWORD(tag, density_cache_size, cache_size)
BOOST_PARAMETER_NESTED_KEYWORD(tag, density_num_bins, num_bins)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(density_cache_size)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(density_num_bins)
namespace impl
{
///////////////////////////////////////////////////////////////////////////////

View file

@ -18,7 +18,7 @@
#include <boost/iterator/permutation_iterator.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
#include <boost/accumulators/framework/parameters/sample.hpp>
@ -34,6 +34,8 @@ namespace boost { namespace accumulators
//
BOOST_PARAMETER_NESTED_KEYWORD(tag, extended_p_square_probabilities, probabilities)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_probabilities)
namespace impl
{
///////////////////////////////////////////////////////////////////////////////
@ -55,9 +57,9 @@ namespace impl
K. E. E. Raatikainen, Simultaneous estimation of several quantiles, Simulation, Volume 49,
Number 4 (October), 1986, p. 159-164.
The extended \f$ P^2 \f$ algorithm generalizess the \f$ P^2 \f$ algorithm of
The extended \f$ P^2 \f$ algorithm generalizes the \f$ P^2 \f$ algorithm of
R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and
R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and
histograms without storing observations, Communications of the ACM,
Volume 28 (October), Number 10, 1985, p. 1076-1085.
@ -256,7 +258,7 @@ namespace tag
typedef accumulators::impl::extended_p_square_impl<mpl::_1> impl;
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// tag::extended_p_square::probabilities named paramter
/// tag::extended_p_square::probabilities named parameter
static boost::parameter::keyword<tag::probabilities> const probabilities;
#endif
};

View file

@ -13,6 +13,7 @@
#include <boost/parameter/keyword.hpp>
#include <boost/range.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
@ -27,6 +28,8 @@ namespace boost { namespace accumulators
//
BOOST_PARAMETER_NESTED_KEYWORD(tag, p_square_cumulative_distribution_num_cells, num_cells)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_cumulative_distribution_num_cells)
namespace impl
{
///////////////////////////////////////////////////////////////////////////////
@ -41,7 +44,7 @@ namespace impl
For further details, see
R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and
R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and
histograms without storing observations, Communications of the ACM,
Volume 28 (October), Number 10, 1985, p. 1076-1085.

View file

@ -44,7 +44,7 @@ namespace impl
For further details, see
R. Jain and I. Chlamtac, The P^2 algorithmus fordynamic calculation of quantiles and
R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and
histograms without storing observations, Communications of the ACM,
Volume 28 (October), Number 10, 1985, p. 1076-1085.
@ -105,7 +105,7 @@ namespace impl
{
std::size_t sample_cell = 1; // k
// find cell k such that heights[k-1] <= args[sample] < heights[k] and ajust extreme values
// find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values
if (args[sample] < this->heights[0])
{
this->heights[0] = args[sample];

View file

@ -9,12 +9,15 @@
#define BOOST_ACCUMULATORS_STATISTICS_PARAMETERS_QUANTILE_PROBABILITY_HPP_EAN_03_11_2005
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
BOOST_PARAMETER_KEYWORD(tag, quantile_probability)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(quantile_probability)
}} // namespace boost::accumulators
#endif

View file

@ -22,6 +22,7 @@
#include <boost/mpl/placeholders.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
@ -46,6 +47,9 @@ namespace boost { namespace accumulators
BOOST_PARAMETER_NESTED_KEYWORD(tag, pot_threshold_value, threshold_value)
BOOST_PARAMETER_NESTED_KEYWORD(tag, pot_threshold_probability, threshold_probability)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(pot_threshold_value)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(pot_threshold_probability)
namespace impl
{
///////////////////////////////////////////////////////////////////////////////

View file

@ -13,6 +13,7 @@
#include <boost/assert.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
@ -28,6 +29,8 @@ namespace boost { namespace accumulators
// tag::rolling_window::size named parameter
BOOST_PARAMETER_NESTED_KEYWORD(tag, rolling_window_size, window_size)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_window_size)
namespace impl
{
///////////////////////////////////////////////////////////////////////////////

View file

@ -31,7 +31,7 @@ namespace impl
@brief Skewness estimation
The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the \f$ 3/2 \f$-th power
of the 2nd central moment (the variance) of the sampless 3. The skewness can also be expressed by the simple moments:
of the 2nd central moment (the variance) of the samples 3. The skewness can also be expressed by the simple moments:
\f[
\hat{g}_1 =

View file

@ -18,6 +18,7 @@
#include <boost/parameter/keyword.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/iterator/permutation_iterator.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/numeric/functional.hpp>
@ -32,6 +33,9 @@ namespace boost { namespace accumulators
BOOST_PARAMETER_NESTED_KEYWORD(tag, right_tail_cache_size, cache_size)
BOOST_PARAMETER_NESTED_KEYWORD(tag, left_tail_cache_size, cache_size)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(right_tail_cache_size)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(left_tail_cache_size)
namespace detail
{
///////////////////////////////////////////////////////////////////////////////

View file

@ -46,7 +46,7 @@ namespace impl
@brief Tail quantile estimation based on order statistics (for both left and right tails)
The estimation of a tail quantile \f$\hat{q}\f$ with level \f$\alpha\f$ based on order statistics requires the
chaching of at least the \f$\lceil n\alpha\rceil\f$ smallest or the \f$\lceil n(1-\alpha)\rceil\f$ largest samples,
caching of at least the \f$\lceil n\alpha\rceil\f$ smallest or the \f$\lceil n(1-\alpha)\rceil\f$ largest samples,
\f$n\f$ being the total number of samples. The largest of the \f$\lceil n\alpha\rceil\f$ smallest samples or the
smallest of the \f$\lceil n(1-\alpha)\rceil\f$ largest samples provides an estimate for the quantile:

View file

@ -9,6 +9,7 @@
#define BOOST_ACCUMULATORS_STATISTICS_VARIATES_COVARIATE_HPP_EAN_03_11_2005
#include <boost/parameter/keyword.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
@ -16,6 +17,9 @@ namespace boost { namespace accumulators
BOOST_PARAMETER_KEYWORD(tag, covariate1)
BOOST_PARAMETER_KEYWORD(tag, covariate2)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(covariate1)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(covariate2)
}} // namespace boost::accumulators
#endif

View file

@ -54,9 +54,9 @@ namespace impl
K. E. E. Raatikainen, Simultaneous estimation of several quantiles, Simulation, Volume 49,
Number 4 (October), 1986, p. 159-164.
The extended \f$ P^2 \f$ algorithm generalizess the \f$ P^2 \f$ algorithm of
The extended \f$ P^2 \f$ algorithm generalizes the \f$ P^2 \f$ algorithm of
R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and
R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and
histograms without storing observations, Communications of the ACM,
Volume 28 (October), Number 10, 1985, p. 1076-1085.

View file

@ -42,7 +42,7 @@ namespace impl
For further details, see
R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and
R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and
histograms without storing observations, Communications of the ACM,
Volume 28 (October), Number 10, 1985, p. 1076-1085.

View file

@ -44,7 +44,7 @@ namespace impl {
For further details, see
R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and
R. Jain and I. Chlamtac, The P^2 algorithm for dynamic calculation of quantiles and
histograms without storing observations, Communications of the ACM,
Volume 28 (October), Number 10, 1985, p. 1076-1085.
@ -80,7 +80,7 @@ namespace impl {
this->heights[cnt - 1] = args[sample];
// In this initialization phase, actual_positions stores the weights of the
// inital samples that are needed at the end of the initialization phase to
// initial samples that are needed at the end of the initialization phase to
// compute the correct initial positions of the markers.
this->actual_positions[cnt - 1] = args[weight];

View file

@ -37,7 +37,7 @@
namespace boost
{
// for _BinaryOperatrion2 in std::inner_product below
// mutliplies two values and promotes the result to double
// multiplies two values and promotes the result to double
namespace numeric { namespace functional
{
///////////////////////////////////////////////////////////////////////////////

View file

@ -64,7 +64,7 @@ namespace impl
,\quad n\ge2,\quad\hat{\sigma}_0^2 = 0.
\f]
where \f$\bar{w}_n\f$ is the sum of the \f$n\f$ weights \f$w_i\f$ and \f$\hat{\mu}_n\f$
the estimate of the mean of the weighted smaples. Note that the sample variance is not defined for
the estimate of the mean of the weighted samples. Note that the sample variance is not defined for
\f$n <= 1\f$.
*/
template<typename Sample, typename Weight, typename MeanFeature, typename Tag>

View file

@ -63,7 +63,7 @@ OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p )
/// \fn copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
/// \brief Copies all the elements at the start of the input range that
/// satisfy the predicate to the output range.
/// \return The updated output iterator
/// \return The updated input and output iterators
///
/// \param first The start of the input sequence
/// \param last One past the end of the input sequence
@ -71,25 +71,26 @@ OutputIterator copy_if ( const Range &r, OutputIterator result, Predicate p )
/// \param p A predicate for testing the elements of the range
///
template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator copy_while ( InputIterator first, InputIterator last,
OutputIterator result, Predicate p )
std::pair<InputIterator, OutputIterator>
copy_while ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
{
for ( ; first != last && p(*first); ++first )
*result++ = *first;
return result;
return std::make_pair(first, result);
}
/// \fn copy_while ( const Range &r, OutputIterator result, Predicate p )
/// \brief Copies all the elements at the start of the input range that
/// satisfy the predicate to the output range.
/// \return The updated output iterator
/// \return The updated input and output iterators
///
/// \param r The input range
/// \param result An output iterator to write the results into
/// \param p A predicate for testing the elements of the range
///
template<typename Range, typename OutputIterator, typename Predicate>
OutputIterator copy_while ( const Range &r, OutputIterator result, Predicate p )
std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
copy_while ( const Range &r, OutputIterator result, Predicate p )
{
return boost::algorithm::copy_while (boost::begin (r), boost::end(r), result, p);
}
@ -106,11 +107,12 @@ OutputIterator copy_while ( const Range &r, OutputIterator result, Predicate p )
/// \param p A predicate for testing the elements of the range
///
template<typename InputIterator, typename OutputIterator, typename Predicate>
OutputIterator copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
std::pair<InputIterator, OutputIterator>
copy_until ( InputIterator first, InputIterator last, OutputIterator result, Predicate p )
{
for ( ; first != last && !p(*first); ++first )
*result++ = *first;
return result;
return std::make_pair(first, result);
}
/// \fn copy_until ( const Range &r, OutputIterator result, Predicate p )
@ -123,7 +125,8 @@ OutputIterator copy_until ( InputIterator first, InputIterator last, OutputItera
/// \param p A predicate for testing the elements of the range
///
template<typename Range, typename OutputIterator, typename Predicate>
OutputIterator copy_until ( const Range &r, OutputIterator result, Predicate p )
std::pair<typename boost::range_iterator<const Range>::type, OutputIterator>
copy_until ( const Range &r, OutputIterator result, Predicate p )
{
return boost::algorithm::copy_until (boost::begin (r), boost::end(r), result, p);
}

View file

@ -24,11 +24,11 @@ namespace boost { namespace algorithm {
using std::is_partitioned; // Section 25.3.13
#else
/// \fn is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p )
/// \brief Tests to see if a sequence is partititioned according to a predicate
/// \brief Tests to see if a sequence is partitioned according to a predicate
///
/// \param first The start of the input sequence
/// \param last One past the end of the input sequence
/// \param p The predicicate to test the values with
/// \param p The predicate to test the values 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.
@ -51,7 +51,7 @@ bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p
/// \brief Generates an increasing sequence of values, and stores them in the input Range.
///
/// \param r The input range
/// \param p The predicicate to test the values with
/// \param p The predicate to test the values with
///
template <typename Range, typename UnaryPredicate>
bool is_partitioned ( const Range &r, UnaryPredicate p )

View file

@ -25,10 +25,6 @@
namespace boost { namespace algorithm {
#if __cplusplus >= 201103L
// Use the C++11 versions of is_permutation if it is available
using std::is_permutation; // Section 25.2.12
#else
/// \cond DOXYGEN_HIDE
namespace detail {
template <typename Predicate, typename Iterator>
@ -38,18 +34,82 @@ namespace detail {
template <typename T1>
bool operator () ( const T1 &t1 ) const { return p_ ( *it_, t1 ); }
private:
Predicate &p_;
Predicate p_;
Iterator it_;
};
// Preconditions:
// 1. The sequences are the same length
// 2. Any common elements on the front have been removed (not necessary for correctness, just for performance)
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
bool is_permutation_inner ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate p ) {
// for each unique value in the sequence [first1,last1), count how many times
// it occurs, and make sure it occurs the same number of times in [first2, last2)
for ( ForwardIterator1 iter = first1; iter != last1; ++iter ) {
value_predicate<BinaryPredicate, ForwardIterator1> pred ( p, iter );
/* For each value we haven't seen yet... */
if ( std::find_if ( first1, iter, pred ) == iter ) {
std::size_t dest_count = std::count_if ( first2, last2, pred );
if ( dest_count == 0 || dest_count != (std::size_t) std::count_if ( iter, last1, pred ))
return false;
}
}
return true;
}
template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
bool is_permutation_tag ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate p,
std::forward_iterator_tag, std::forward_iterator_tag ) {
// Skip the common prefix (if any)
while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) {
++first1;
++first2;
}
if ( first1 != last1 && first2 != last2 )
return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2,
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ());
return first1 == last1 && first2 == last2;
}
template <class RandomAccessIterator1, class RandomAccessIterator2, class BinaryPredicate>
bool is_permutation_tag ( RandomAccessIterator1 first1, RandomAccessIterator1 last1,
RandomAccessIterator2 first2, RandomAccessIterator2 last2,
BinaryPredicate p,
std::random_access_iterator_tag, std::random_access_iterator_tag ) {
// Cheap check
if ( std::distance ( first1, last1 ) != std::distance ( first2, last2 ))
return false;
// Skip the common prefix (if any)
while ( first1 != last1 && first2 != last2 && p ( *first1, *first2 )) {
++first1;
++first2;
}
if ( first1 != last1 && first2 != last2 )
return is_permutation_inner (first1, last1, first2, last2, p);
return first1 == last1 && first2 == last2;
}
}
/// \endcond
#if __cplusplus >= 201103L
// Use the C++11 versions of is_permutation if it is available
using std::is_permutation; // Section 25.2.12
#else
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2, BinaryPredicate p )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
///
/// \param first The start of the input sequence
/// \param last One past the end of the input sequence
/// \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 p The predicate to compare elements with
///
@ -69,19 +129,7 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
// Create last2
ForwardIterator2 last2 = first2;
std::advance ( last2, std::distance (first1, last1));
// for each unique value in the sequence [first1,last1), count how many times
// it occurs, and make sure it occurs the same number of times in [first2, last2)
for ( ForwardIterator1 iter = first1; iter != last1; ++iter ) {
detail::value_predicate<BinaryPredicate, ForwardIterator1> pred ( p, iter );
/* For each value we haven't seen yet... */
if ( std::find_if ( first1, iter, pred ) == iter ) {
std::size_t dest_count = std::count_if ( first2, last2, pred );
if ( dest_count == 0 || dest_count != (std::size_t) std::count_if ( iter, last1, pred ))
return false;
}
}
return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2, p );
}
return true;
@ -90,23 +138,84 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
/// \fn is_permutation ( ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 first2 )
/// \brief Tests to see if the sequence [first,last) is a permutation of the sequence starting at first2
///
/// \param first The start of the input sequence
/// \param last One past the end of the input sequence
/// \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
/// \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 first, ForwardIterator1 last, ForwardIterator2 first2 )
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2 )
{
// 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::is_permutation ( first, last, first2,
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ());
// Skip the common prefix (if any)
std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2 );
first1 = eq.first;
first2 = eq.second;
if ( first1 != last1 ) {
// Create last2
ForwardIterator2 last2 = first2;
std::advance ( last2, std::distance (first1, last1));
return boost::algorithm::detail::is_permutation_inner ( first1, last1, first2, last2,
std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> ());
}
return true;
}
#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
///

View file

@ -0,0 +1,97 @@
/*
Copyright (c) Marshall Clow 2008-2012.
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 Test ranges to if they are equal
/// \author Marshall Clow
#ifndef BOOST_ALGORITHM_EQUAL_HPP
#define BOOST_ALGORITHM_EQUAL_HPP
#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 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;
}
}
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
/// InputIterator2 first2, InputIterator2 last2,
/// BinaryPredicate pred )
/// \return true if all elements in the two ranges are equal
///
/// \param first1 The start of the first range.
/// \param last1 One past the end of the first range.
/// \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>
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 ());
}
/// \fn equal ( InputIterator1 first1, InputIterator1 last1,
/// InputIterator2 first2, InputIterator2 last2 )
/// \return true if all elements in the two ranges are equal
///
/// \param first1 The start of the first range.
/// \param last1 One past the end of the first range.
/// \param first2 The start of the second range.
/// \param last2 One past the end of the second range.
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 ());
}
// There are already range-based versions of these.
}} // namespace boost and algorithm
#endif // BOOST_ALGORITHM_EQUAL_HPP

View file

@ -0,0 +1,130 @@
/*
Copyright (c) Marshall Clow 2013
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
/// \file equal.hpp
/// \brief Determines if one
/// \author Marshall Clow
#ifndef BOOST_ALGORITHM_IS_PERMUTATION_HPP
#define BOOST_ALGORITHM_IS_PERMUTATION_HPP
#include <algorithm>
#include <functional> // for std::equal_to
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;
}
}
return true;
}
}
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>
bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2 )
{
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 ());
}
// There are already range-based versions of these.
}} // namespace boost and algorithm
#endif // BOOST_ALGORITHM_IS_PERMUTATION_HPP

View file

@ -0,0 +1,66 @@
/*
Copyright (c) Marshall Clow 2008-2012.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
*/
/// \file mismatch.hpp
/// \brief Find the first mismatched element in a sequence
/// \author Marshall Clow
#ifndef BOOST_ALGORITHM_MISMATCH_HPP
#define BOOST_ALGORITHM_MISMATCH_HPP
#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 )
/// \return a pair of iterators pointing to the first elements in the sequence that do not match
///
/// \param first1 The start of the first range.
/// \param last1 One past the end of the first range.
/// \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
std::pair<InputIterator1, InputIterator2> mismatch (
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred )
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
if ( !pred ( *first1, *first2 ))
break;
return std::pair<InputIterator1, InputIterator2>(first1, first2);
}
/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
/// InputIterator2 first2, InputIterator2 last2 )
/// \return a pair of iterators pointing to the first elements in the sequence that do not match
///
/// \param first1 The start of the first range.
/// \param last1 One past the end of the first range.
/// \param first2 The start of the second range.
/// \param last2 One past the end of the second range.
template <class InputIterator1, class InputIterator2>
std::pair<InputIterator1, InputIterator2> mismatch (
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2 )
{
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
if ( *first1 != *first2 )
break;
return std::pair<InputIterator1, InputIterator2>(first1, first2);
}
// There are already range-based versions of these.
}} // namespace boost and algorithm
#endif // BOOST_ALGORITHM_MISMATCH_HPP

View file

@ -0,0 +1,123 @@
/*
Copyright 2008 Adobe Systems Incorporated
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)
Revision history:
January 2008 mtc Version for Adobe Source Library
January 2013 mtc Version for Boost.Algorithm
*/
/**************************************************************************************************/
/*!
\author Marshall Clow
\date January 2008
*/
#ifndef BOOST_ALGORITHM_GATHER_HPP
#define BOOST_ALGORITHM_GATHER_HPP
#include <algorithm> // for std::stable_partition
#include <functional>
#include <boost/bind.hpp> // for boost::bind
#include <boost/range/begin.hpp> // for boost::begin(range)
#include <boost/range/end.hpp> // for boost::end(range)
/**************************************************************************************************/
/*!
\defgroup gather gather
\ingroup mutating_algorithm
\c gather() takes a collection of elements defined by a pair of iterators and moves
the ones satisfying a predicate to them to a position (called the pivot) within
the sequence. The algorithm is stable. The result is a pair of iterators that
contains the items that satisfy the predicate.
Given an sequence containing:
<pre>
0 1 2 3 4 5 6 7 8 9
</pre>
a call to gather ( arr, arr + 10, arr + 4, IsEven ()) will result in:
<pre>
1 3 0 2 4 6 8 5 7 9
|---|-----|
first | second
pivot
</pre>
The problem is broken down into two basic steps, namely, moving the items before the pivot
and then moving the items from the pivot to the end. These "moves" are done with calls to
stable_partition.
\par Storage Requirements:
The algorithm uses stable_partition, which will attempt to allocate temporary memory,
but will work in-situ if there is none available.
\par Time Complexity:
If there is sufficient memory available, the run time is linear in <code>N</code>.
If there is not any memory available, then the run time is <code>O(N log N)</code>.
*/
/**************************************************************************************************/
namespace boost { namespace algorithm {
/**************************************************************************************************/
/*!
\ingroup gather
\brief iterator-based gather implementation
*/
template <
typename BidirectionalIterator, // Iter models BidirectionalIterator
typename Pred> // Pred models UnaryPredicate
std::pair<BidirectionalIterator, BidirectionalIterator> gather
( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred )
{
// The first call partitions everything up to (but not including) the pivot element,
// while the second call partitions the rest of the sequence.
return std::make_pair (
std::stable_partition ( first, pivot, !boost::bind<bool> ( pred, _1 )),
std::stable_partition ( pivot, last, boost::bind<bool> ( pred, _1 )));
}
/**************************************************************************************************/
/*!
\ingroup gather
\brief range-based gather implementation
*/
template <
typename BidirectionalRange, //
typename Pred> // Pred models UnaryPredicate
std::pair<
typename boost::range_iterator<const BidirectionalRange>::type,
typename boost::range_iterator<const BidirectionalRange>::type>
gather (
const BidirectionalRange &range,
typename boost::range_iterator<const BidirectionalRange>::type pivot,
Pred pred )
{
return boost::algorithm::gather ( boost::begin ( range ), boost::end ( range ), pivot, pred );
}
/**************************************************************************************************/
}} // namespace
/**************************************************************************************************/
#endif

View file

@ -10,12 +10,6 @@
/*
General problem - turn a sequence of integral types into a sequence of hexadecimal characters.
- and back.
TO DO:
1. these should really only work on integral types. (see the >> and << operations)
-- this is done, I think.
2. The 'value_type_or_char' struct is really a hack.
-- but it's a better hack now that it works with back_insert_iterators
*/
/// \file hex.hpp
@ -42,11 +36,11 @@ namespace boost { namespace algorithm {
/*!
\struct hex_decode_error
\brief Base exception class for all hex decoding errors
*/ /*!
\struct non_hex_input
\brief Thrown when a non-hex value (0-9, A-F) encountered when decoding.
Contains the offending character
*/ /*!
\struct not_enough_input
\brief Thrown when the input sequence unexpectedly ends
@ -69,18 +63,16 @@ namespace detail {
return std::copy ( res, res + num_hex_digits, out );
}
// this needs to be in an un-named namespace because it is not a template
// and might get included in several compilation units. This could cause
// multiple definition errors at link time.
namespace {
unsigned hex_char_to_int ( char c ) {
if ( c >= '0' && c <= '9' ) return c - '0';
if ( c >= 'A' && c <= 'F' ) return c - 'A' + 10;
if ( c >= 'a' && c <= 'f' ) return c - 'a' + 10;
BOOST_THROW_EXCEPTION (non_hex_input() << bad_char (c));
return 0; // keep dumb compilers happy
template <typename T>
unsigned char hex_char_to_int ( T val ) {
char c = static_cast<char> ( val );
unsigned retval = 0;
if ( c >= '0' && c <= '9' ) retval = c - '0';
else if ( c >= 'A' && c <= 'F' ) retval = c - 'A' + 10;
else if ( c >= 'a' && c <= 'f' ) retval = c - 'a' + 10;
else BOOST_THROW_EXCEPTION (non_hex_input() << bad_char (c));
return retval;
}
}
// My own iterator_traits class.
// It is here so that I can "reach inside" some kinds of output iterators
@ -134,7 +126,7 @@ namespace detail {
for ( std::size_t i = 0; i < 2 * sizeof ( T ); ++i, ++first ) {
if ( pred ( first, last ))
BOOST_THROW_EXCEPTION (not_enough_input ());
res = ( 16 * res ) + hex_char_to_int (static_cast<char> (*first));
res = ( 16 * res ) + hex_char_to_int (*first);
}
*out = res;

View file

@ -99,8 +99,10 @@ namespace boost {
// if odd number of elements, treat last element
if (first != last) { // odd number of elements
if (comp(first, min_result))
min_result = first, potential_min_result = last;
if (comp(first, min_result)) {
min_result = first;
potential_min_result = last;
}
else if (comp(max_result, first))
max_result = first;
}

View file

@ -33,8 +33,8 @@ References:
http://www.cs.utexas.edu/users/moore/best-ideas/string-searching/
http://www.cs.utexas.edu/~moore/publications/fstrpos.pdf
Explanations: boostinspect:noascii (test tool complains)
http://en.wikipedia.org/wiki/BoyerMoore_string_search_algorithm
Explanations:
http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm
http://www.movsd.com/bm.htm
http://www.cs.ucdavis.edu/~gusfield/cs224f09/bnotes.pdf

View file

@ -56,7 +56,7 @@ namespace boost {
// Copy the beginning of the sequence
Output = std::copy( ::boost::begin(Input), ::boost::begin(M), Output );
// Format find result
// Copy formated result
// Copy formatted result
Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
// Copy the rest of the sequence
Output = std::copy( M.end(), ::boost::end(Input), Output );
@ -118,11 +118,11 @@ namespace boost {
InputT Output;
// Copy the beginning of the sequence
insert( Output, ::boost::end(Output), ::boost::begin(Input), M.begin() );
// Copy formated result
insert( Output, ::boost::end(Output), M.format_result() );
boost::algorithm::detail::insert( Output, ::boost::end(Output), ::boost::begin(Input), M.begin() );
// Copy formatted result
boost::algorithm::detail::insert( Output, ::boost::end(Output), M.format_result() );
// Copy the rest of the sequence
insert( Output, ::boost::end(Output), M.end(), ::boost::end(Input) );
boost::algorithm::detail::insert( Output, ::boost::end(Output), M.end(), ::boost::end(Input) );
return Output;
}

View file

@ -58,7 +58,7 @@ namespace boost {
{
// Copy the beginning of the sequence
Output = std::copy( LastMatch, M.begin(), Output );
// Copy formated result
// Copy formatted result
Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
// Proceed to the next match
@ -134,9 +134,9 @@ namespace boost {
while( M )
{
// Copy the beginning of the sequence
insert( Output, ::boost::end(Output), LastMatch, M.begin() );
// Copy formated result
insert( Output, ::boost::end(Output), M.format_result() );
boost::algorithm::detail::insert( Output, ::boost::end(Output), LastMatch, M.begin() );
// Copy formatted result
boost::algorithm::detail::insert( Output, ::boost::end(Output), M.format_result() );
// Proceed to the next match
LastMatch=M.end();
@ -218,7 +218,7 @@ namespace boost {
// Adjust search iterator
SearchIt=M.end();
// Copy formated replace to the storage
// Copy formatted replace to the storage
::boost::algorithm::detail::copy_to_storage( Storage, M.format_result() );
// Find range for a next match

View file

@ -92,7 +92,7 @@ namespace boost {
// find last functor -----------------------------------------------//
// find the last match a subseqeunce in the sequence ( functor )
// find the last match a subsequence in the sequence ( functor )
/*
Returns a pair <begin,end> marking the subsequence in the sequence.
If the find fails, returns <End,End>

View file

@ -60,14 +60,14 @@ namespace boost {
return *this;
}
// Match result retrival
// Match result retrieval
const match_results_type& match_results() const
{
return m_MatchResults;
}
private:
// Saved matchresult
// Saved match result
match_results_type m_MatchResults;
};

View file

@ -86,7 +86,7 @@ namespace boost {
//! Find first algorithm ( case insensitive )
/*!
Search for the first occurence of the substring in the input.
Search for the first occurrence of the substring in the input.
Searching is case insensitive.
\param Input A string which will be searched.
@ -293,7 +293,7 @@ namespace boost {
If the "token compress mode" is enabled, adjacent tokens are considered to be one match.
\param Input A input string.
\param Pred An unary predicate to identify a token
\param Pred A unary predicate to identify a token
\param eCompress Enable/Disable compressing of adjacent tokens
\return
An \c iterator_range delimiting the match.

View file

@ -132,7 +132,12 @@ namespace boost {
// increment
void increment()
{
m_Match=this->do_find(m_Match.end(),m_End);
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);
}
}
// comparison

View file

@ -39,7 +39,7 @@ namespace boost {
Constructs a \c const_formatter. Const formatter always returns
the same value, regardless of the parameter.
\param Format A predefined value used as a result for formating
\param Format A predefined value used as a result for formatting
\return An instance of the \c const_formatter object.
*/
template<typename RangeT>
@ -95,7 +95,7 @@ namespace boost {
to extract a portion of the formatted sequence. The first finder's match is returned
as a result
\param Finder a finder used to select a portion of the formated sequence
\param Finder a finder used to select a portion of the formatted sequence
\return An instance of the \c dissect_formatter object.
*/
template<typename FinderT>

View file

@ -15,7 +15,7 @@
/*
\file boost/algorith/string/predicate_facade.hpp
This file containes predicate_facade definition. This template class is used
This file contains predicate_facade definition. This template class is used
to identify classification predicates, so they can be combined using
composition operators.
*/

View file

@ -32,7 +32,7 @@ namespace boost {
Construct the \c regex_finder. Finder uses the regex engine to search
for a match.
Result is given in \c regex_search_result. This is an extension
of the iterator_range. In addition it containes match results
of the iterator_range. In addition it contains match results
from the \c regex_search algorithm.
\param Rx A regular expression

View file

@ -50,7 +50,7 @@ namespace boost {
\param Output An output iterator to which the result will be copied
\param Input An input range
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
\return
An output iterator pointing just after the last inserted character or
a copy of the input
@ -118,7 +118,7 @@ namespace boost {
The input sequence is modified in-place.
\param Input An input sequence
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
*/
template<typename SequenceT, typename PredicateT>
inline void trim_left_if(SequenceT& Input, PredicateT IsSpace)
@ -158,7 +158,7 @@ namespace boost {
\param Output An output iterator to which the result will be copied
\param Input An input range
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
\return
An output iterator pointing just after the last inserted character or
a copy of the input
@ -228,7 +228,7 @@ namespace boost {
The input sequence is modified in-place.
\param Input An input sequence
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
*/
template<typename SequenceT, typename PredicateT>
inline void trim_right_if(SequenceT& Input, PredicateT IsSpace)
@ -270,7 +270,7 @@ namespace boost {
\param Output An output iterator to which the result will be copied
\param Input An input range
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
\return
An output iterator pointing just after the last inserted character or
a copy of the input
@ -352,7 +352,7 @@ namespace boost {
The input sequence is modified in-place.
\param Input An input sequence
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
*/
template<typename SequenceT, typename PredicateT>
inline void trim_if(SequenceT& Input, PredicateT IsSpace)

View file

@ -49,7 +49,7 @@ namespace boost {
The result is a trimmed copy of the input
\param Input An input sequence
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
\return A trimmed copy of the input
*/
template<typename SequenceT, typename PredicateT>
@ -70,7 +70,7 @@ namespace boost {
The input sequence is modified in-place.
\param Input An input sequence
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
*/
template<typename SequenceT, typename PredicateT>
inline void trim_all_if(SequenceT& Input, PredicateT IsSpace)
@ -126,7 +126,7 @@ namespace boost {
\param Input An input sequence
\param Fill A string used to fill the inner spaces
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
\return A trimmed copy of the input
*/
template<typename SequenceT, typename RangeT, typename PredicateT>
@ -149,7 +149,7 @@ namespace boost {
\param Input An input sequence
\param Fill A string used to fill the inner spaces
\param IsSpace An unary predicate identifying spaces
\param IsSpace A unary predicate identifying spaces
*/
template<typename SequenceT, typename RangeT, typename PredicateT>
inline void trim_fill_if(SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)

View file

@ -13,7 +13,7 @@
/*! \file
Cumulative include for string_algo library.
In addtion to string.hpp contains also regex-related stuff.
In addition to string.hpp contains also regex-related stuff.
*/
#include <boost/regex.hpp>

View file

@ -3,12 +3,16 @@
#ifndef BOOST_ANY_INCLUDED
#define BOOST_ANY_INCLUDED
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// what: variant type boost::any
// who: contributed by Kevlin Henney,
// with features contributed and bugs found by
// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran
// when: July 2001
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
// Antony Polukhin, Ed Brey, Mark Rodgers,
// Peter Dimov, and James Curran
// when: July 2001, Aplril 2013
#include <algorithm>
#include <typeinfo>
@ -18,6 +22,8 @@
#include <boost/type_traits/is_reference.hpp>
#include <boost/throw_exception.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
// See boost/python/type_id.hpp
// TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp
@ -36,7 +42,7 @@ namespace boost
{
public: // structors
any()
any() BOOST_NOEXCEPT
: content(0)
{
}
@ -52,19 +58,37 @@ namespace boost
{
}
~any()
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
// Move constructor
any(any&& other) BOOST_NOEXCEPT
: content(other.content)
{
other.content = 0;
}
// Perfect forwarding of ValueType
template<typename ValueType>
any(ValueType&& value, typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0)
: content(new holder< typename remove_reference<ValueType>::type >(static_cast<ValueType&&>(value)))
{
}
#endif
~any() BOOST_NOEXCEPT
{
delete content;
}
public: // modifiers
any & swap(any & rhs)
any & swap(any & rhs) BOOST_NOEXCEPT
{
std::swap(content, rhs.content);
return *this;
}
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
template<typename ValueType>
any & operator=(const ValueType & rhs)
{
@ -74,13 +98,37 @@ namespace boost
any & operator=(any rhs)
{
rhs.swap(*this);
any(rhs).swap(*this);
return *this;
}
#else
any & operator=(const any& rhs)
{
any(rhs).swap(*this);
return *this;
}
// move assignement
any & operator=(any&& rhs) BOOST_NOEXCEPT
{
rhs.swap(*this);
any().swap(rhs);
return *this;
}
// Perfect forwarding of ValueType
template <class ValueType>
any & operator=(ValueType&& rhs)
{
any(static_cast<ValueType&&>(rhs)).swap(*this);
return *this;
}
#endif
public: // queries
bool empty() const
bool empty() const BOOST_NOEXCEPT
{
return !content;
}
@ -122,6 +170,12 @@ namespace boost
{
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
holder(ValueType&& value)
: held(static_cast< ValueType&& >(value))
{
}
#endif
public: // queries
virtual const std::type_info & type() const
@ -147,10 +201,10 @@ namespace boost
private: // representation
template<typename ValueType>
friend ValueType * any_cast(any *);
friend ValueType * any_cast(any *) BOOST_NOEXCEPT;
template<typename ValueType>
friend ValueType * unsafe_any_cast(any *);
friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT;
#else
@ -161,6 +215,11 @@ namespace boost
placeholder * content;
};
inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT
{
lhs.swap(rhs);
}
class bad_any_cast : public std::bad_cast
{
@ -173,7 +232,7 @@ namespace boost
};
template<typename ValueType>
ValueType * any_cast(any * operand)
ValueType * any_cast(any * operand) BOOST_NOEXCEPT
{
return operand &&
#ifdef BOOST_AUX_ANY_TYPE_ID_NAME
@ -186,7 +245,7 @@ namespace boost
}
template<typename ValueType>
inline const ValueType * any_cast(const any * operand)
inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT
{
return any_cast<ValueType>(const_cast<any *>(operand));
}
@ -232,13 +291,13 @@ namespace boost
// use typeid() comparison, e.g., when our types may travel across
// different shared libraries.
template<typename ValueType>
inline ValueType * unsafe_any_cast(any * operand)
inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT
{
return &static_cast<any::holder<ValueType> *>(operand->content)->held;
}
template<typename ValueType>
inline const ValueType * unsafe_any_cast(const any * operand)
inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT
{
return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
}

View file

@ -43,6 +43,8 @@ namespace archive {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) archive_exception :
public virtual std::exception
{
protected:
char m_buffer[128];
public:
typedef enum {
no_exception, // initialized without code
@ -74,8 +76,6 @@ public:
// type has been instantiated in more than one module.
output_stream_error // error on input stream
} exception_code;
protected:
std::string m_msg;
public:
exception_code code;
archive_exception(
@ -83,9 +83,11 @@ public:
const char * e1 = NULL,
const char * e2 = NULL
);
~archive_exception() throw ();
virtual const char *what( ) const throw();
virtual ~archive_exception() throw();
virtual const char *what() const throw();
protected:
unsigned int
append(unsigned int l, const char * a);
archive_exception();
};

View file

@ -86,23 +86,21 @@ basic_text_iprimitive<IStream>::load_binary(
,CharType
>
binary;
binary ti_begin = binary(
binary i = binary(
BOOST_MAKE_PFTO_WRAPPER(
iterators::istream_iterator<CharType>(is)
)
);
char * caddr = static_cast<char *>(address);
// take care that we don't increment anymore than necessary
while(--count > 0){
*caddr++ = static_cast<char>(*ti_begin);
++ti_begin;
while(count-- > 0){
*caddr++ = static_cast<char>(*i++);
}
*caddr++ = static_cast<char>(*ti_begin);
iterators::istream_iterator<CharType> i;
// skip over any excess input
for(;;){
BOOST_DEDUCED_TYPENAME IStream::int_type r;
r = is.get();
@ -112,7 +110,7 @@ basic_text_iprimitive<IStream>::load_binary(
break;
}
}
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_text_iprimitive<IStream>::basic_text_iprimitive(

View file

@ -51,7 +51,7 @@ basic_text_oprimitive<OStream>::save_binary(
8
>
>
,72
,76
,const char // cwpro8 needs this
>
base64_text;

View file

@ -43,7 +43,7 @@ struct to_6_bit {
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
52,53,54,55,56,57,58,59,60,61,-1,-1,-1, 0,-1,-1, // render '=' as 0
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,

View file

@ -49,16 +49,17 @@ class istream_iterator :
> super_t;
typedef BOOST_DEDUCED_TYPENAME std::basic_istream<Elem> istream_type;
//Access the value referred to
Elem dereference() const {
return m_current_value;
}
bool equal(const this_t & rhs) const {
// note: only works for comparison against end of stream
return m_istream == rhs.m_istream;
}
/*
//Access the value referred to
Elem dereference() const {
return m_current_value;
}
void increment(){
if(NULL != m_istream){
m_current_value = static_cast<Elem>(m_istream->get());
@ -67,6 +68,17 @@ class istream_iterator :
}
}
}
*/
//Access the value referred to
Elem dereference() const {
return m_istream->peek();
}
void increment(){
if(NULL != m_istream){
m_istream->ignore(1);
}
}
istream_type *m_istream;
Elem m_current_value;
@ -74,7 +86,7 @@ public:
istream_iterator(istream_type & is) :
m_istream(& is)
{
increment();
//increment();
}
istream_iterator() :

View file

@ -24,8 +24,6 @@
// character and 8 bit bytes. Lowest common multiple is 24 => 4 6 bit characters
// or 3 8 bit characters
#include <algorithm>
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME & PTFO
#include <boost/serialization/pfto.hpp>
@ -66,101 +64,105 @@ class transform_width :
typedef transform_width<Base, BitsOut, BitsIn, CharType> this_t;
typedef BOOST_DEDUCED_TYPENAME iterator_value<Base>::type base_value_type;
CharType fill();
CharType dereference_impl(){
if(! m_full){
m_current_value = fill();
m_full = true;
}
return m_current_value;
}
void fill();
CharType dereference() const {
return const_cast<this_t *>(this)->dereference_impl();
if(!m_buffer_out_full)
const_cast<this_t *>(this)->fill();
return m_buffer_out;
}
// test for iterator equality
bool equal_impl(const this_t & rhs){
if(BitsIn < BitsOut) // discard any left over bits
return this->base_reference() == rhs.base_reference();
else{
// BitsIn > BitsOut // zero fill
if(this->base_reference() == rhs.base_reference()){
m_end_of_sequence = true;
return 0 == m_remaining_bits;
}
return false;
}
}
// standard iterator interface
bool equal(const this_t & rhs) const {
return
this->base_reference() == rhs.base_reference();
;
return const_cast<this_t *>(this)->equal_impl(rhs);
}
void increment(){
m_displacement += BitsOut;
while(m_displacement >= BitsIn){
m_displacement -= BitsIn;
if(0 == m_displacement)
m_bufferfull = false;
if(! m_bufferfull){
// note: suspect that this is not invoked for borland
++(this->base_reference());
}
}
m_full = false;
m_buffer_out_full = false;
}
CharType m_current_value;
// number of bits left in current input character buffer
unsigned int m_displacement;
base_value_type m_buffer;
// flag to current output character is ready - just used to save time
bool m_full;
// flag to indicate that m_buffer has data
bool m_bufferfull;
bool m_buffer_out_full;
CharType m_buffer_out;
// last read element from input
base_value_type m_buffer_in;
// number of bits to left in the input buffer.
unsigned int m_remaining_bits;
// flag to indicate we've reached end of data.
bool m_end_of_sequence;
public:
// make composible buy using templated constructor
template<class T>
transform_width(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
m_displacement(0),
m_full(false),
m_bufferfull(false)
m_buffer_out_full(false),
m_remaining_bits(0),
m_end_of_sequence(false)
{}
// intel 7.1 doesn't like default copy constructor
transform_width(const transform_width & rhs) :
super_t(rhs.base_reference()),
m_current_value(rhs.m_current_value),
m_displacement(rhs.m_displacement),
m_buffer(rhs.m_buffer),
m_full(rhs.m_full),
m_bufferfull(rhs.m_bufferfull)
m_buffer_out_full(rhs.m_buffer_out_full),
m_remaining_bits(rhs.m_remaining_bits),
m_buffer_in(rhs.m_buffer_in),
m_end_of_sequence(false)
{}
};
template<class Base, int BitsOut, int BitsIn, class CharType>
CharType transform_width<Base, BitsOut, BitsIn, CharType>::fill(){
CharType retval = 0;
template<
class Base,
int BitsOut,
int BitsIn,
class CharType
>
void transform_width<Base, BitsOut, BitsIn, CharType>::fill() {
unsigned int missing_bits = BitsOut;
for(;;){
unsigned int bcount;
if(! m_bufferfull){
m_buffer = * this->base_reference();
m_bufferfull = true;
bcount = BitsIn;
m_buffer_out = 0;
do{
if(0 == m_remaining_bits){
if(m_end_of_sequence){
m_buffer_in = 0;
m_remaining_bits = missing_bits;
}
else{
m_buffer_in = * this->base_reference()++;
m_remaining_bits = BitsIn;
}
}
else
bcount = BitsIn - m_displacement;
unsigned int i = (std::min)(bcount, missing_bits);
// append these bits to the next output
// up to the size of the output
unsigned int i = std::min(missing_bits, m_remaining_bits);
// shift interesting bits to least significant position
unsigned int j = m_buffer >> (bcount - i);
// strip off uninteresting bits
// (note presumption of two's complement arithmetic)
j &= ~(-(1 << i));
base_value_type j = m_buffer_in >> (m_remaining_bits - i);
// and mask off the un interesting higher bits
// note presumption of twos complement notation
j &= (1 << i) - 1;
// append then interesting bits to the output value
retval <<= i;
retval |= j;
m_buffer_out <<= i;
m_buffer_out |= j;
// and update counters
missing_bits -= i;
if(0 == missing_bits)
break;
// note: suspect that this is not invoked for borland 5.51
++(this->base_reference());
m_bufferfull = false;
}
return retval;
m_remaining_bits -= i;
}while(0 < missing_bits);
m_buffer_out_full = true;
}
} // namespace iterators

View file

@ -2,7 +2,7 @@
// asio.hpp
// ~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,6 +17,7 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/async_result.hpp>
#include <boost/asio/basic_datagram_socket.hpp>
#include <boost/asio/basic_deadline_timer.hpp>
#include <boost/asio/basic_io_object.hpp>
@ -40,12 +41,20 @@
#include <boost/asio/buffers_iterator.hpp>
#include <boost/asio/completion_condition.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/datagram_socket_service.hpp>
#include <boost/asio/deadline_timer_service.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/generic/basic_endpoint.hpp>
#include <boost/asio/generic/datagram_protocol.hpp>
#include <boost/asio/generic/raw_protocol.hpp>
#include <boost/asio/generic/seq_packet_protocol.hpp>
#include <boost/asio/generic/stream_protocol.hpp>
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
#include <boost/asio/handler_type.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/asio/ip/address_v4.hpp>

View file

@ -0,0 +1,96 @@
//
// async_result.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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_ASIO_ASYNC_RESULT_HPP
#define BOOST_ASIO_ASYNC_RESULT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/handler_type.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
/// An interface for customising the behaviour of an initiating function.
/**
* This template may be specialised for user-defined handler types.
*/
template <typename Handler>
class async_result
{
public:
/// The return type of the initiating function.
typedef void type;
/// Construct an async result from a given handler.
/**
* When using a specalised async_result, the constructor has an opportunity
* to initialise some state associated with the handler, which is then
* returned from the initiating function.
*/
explicit async_result(Handler&)
{
}
/// Obtain the value to be returned from the initiating function.
type get()
{
}
};
namespace detail {
// Helper template to deduce the true type of a handler, capture a local copy
// of the handler, and then create an async_result for the handler.
template <typename Handler, typename Signature>
struct async_result_init
{
explicit async_result_init(BOOST_ASIO_MOVE_ARG(Handler) orig_handler)
: handler(BOOST_ASIO_MOVE_CAST(Handler)(orig_handler)),
result(handler)
{
}
typename handler_type<Handler, Signature>::type handler;
async_result<typename handler_type<Handler, Signature>::type> result;
};
template <typename Handler, typename Signature>
struct async_result_type_helper
{
typedef typename async_result<
typename handler_type<Handler, Signature>::type
>::type type;
};
} // namespace detail
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#if defined(GENERATING_DOCUMENTATION)
# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
void_or_deduced
#elif defined(_MSC_VER) && (_MSC_VER < 1500)
# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
typename ::boost::asio::detail::async_result_type_helper<h, sig>::type
#else
# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
typename ::boost::asio::async_result< \
typename ::boost::asio::handler_type<h, sig>::type>::type
#endif
#endif // BOOST_ASIO_ASYNC_RESULT_HPP

View file

@ -2,7 +2,7 @@
// basic_datagram_socket.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -21,6 +21,7 @@
#include <boost/asio/datagram_socket_service.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -166,6 +167,50 @@ public:
BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other));
return *this;
}
/// Move-construct a basic_datagram_socket from a socket of another protocol
/// type.
/**
* This constructor moves a datagram socket from one object to another.
*
* @param other The other basic_datagram_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_datagram_socket(io_service&) constructor.
*/
template <typename Protocol1, typename DatagramSocketService1>
basic_datagram_socket(
basic_datagram_socket<Protocol1, DatagramSocketService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_socket<Protocol, DatagramSocketService>(
BOOST_ASIO_MOVE_CAST2(basic_datagram_socket<
Protocol1, DatagramSocketService1>)(other))
{
}
/// Move-assign a basic_datagram_socket from a socket of another protocol
/// type.
/**
* This assignment operator moves a datagram socket from one object to
* another.
*
* @param other The other basic_datagram_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_datagram_socket(io_service&) constructor.
*/
template <typename Protocol1, typename DatagramSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
basic_datagram_socket>::type& operator=(
basic_datagram_socket<Protocol1, DatagramSocketService1>&& other)
{
basic_socket<Protocol, DatagramSocketService>::operator=(
BOOST_ASIO_MOVE_CAST2(basic_datagram_socket<
Protocol1, DatagramSocketService1>)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on a connected socket.
@ -290,14 +335,16 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(),
return this->get_service().async_send(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -331,7 +378,9 @@ public:
* socket.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -339,7 +388,7 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(),
return this->get_service().async_send(this->get_implementation(),
buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -469,7 +518,9 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send_to(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send_to(const ConstBufferSequence& buffers,
const endpoint_type& destination,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -477,8 +528,9 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send_to(this->get_implementation(), buffers,
destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
return this->get_service().async_send_to(
this->get_implementation(), buffers, destination, 0,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Start an asynchronous send.
@ -509,7 +561,9 @@ public:
* boost::asio::io_service::post().
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send_to(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send_to(const ConstBufferSequence& buffers,
const endpoint_type& destination, socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -517,8 +571,9 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send_to(this->get_implementation(), buffers,
destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
return this->get_service().async_send_to(
this->get_implementation(), buffers, destination, flags,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Receive some data on a connected socket.
@ -647,14 +702,16 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
@ -687,7 +744,9 @@ public:
* datagram socket.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -695,7 +754,7 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
@ -825,7 +884,9 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive_from(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender_endpoint,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -833,8 +894,9 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive_from(this->get_implementation(), buffers,
sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return this->get_service().async_receive_from(
this->get_implementation(), buffers, sender_endpoint, 0,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
/// Start an asynchronous receive.
@ -867,7 +929,9 @@ public:
* boost::asio::io_service::post().
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive_from(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender_endpoint, socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -875,8 +939,9 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive_from(this->get_implementation(), buffers,
sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return this->get_service().async_receive_from(
this->get_implementation(), buffers, sender_endpoint, flags,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_deadline_timer.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -16,6 +16,10 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
|| defined(GENERATING_DOCUMENTATION)
#include <cstddef>
#include <boost/asio/basic_io_object.hpp>
#include <boost/asio/deadline_timer_service.hpp>
@ -492,13 +496,15 @@ public:
* boost::asio::io_service::post().
*/
template <typename WaitHandler>
void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
void (boost::system::error_code))
async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WaitHandler.
BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
this->service.async_wait(this->implementation,
return this->service.async_wait(this->implementation,
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
}
};
@ -508,4 +514,7 @@ public:
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP

View file

@ -2,7 +2,7 @@
// basic_io_object.hpp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// basic_raw_socket.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -20,6 +20,7 @@
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/raw_socket_service.hpp>
@ -165,6 +166,46 @@ public:
BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other));
return *this;
}
/// Move-construct a basic_raw_socket from a socket of another protocol type.
/**
* This constructor moves a raw socket from one object to another.
*
* @param other The other basic_raw_socket object from which the move will
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_raw_socket(io_service&) constructor.
*/
template <typename Protocol1, typename RawSocketService1>
basic_raw_socket(basic_raw_socket<Protocol1, RawSocketService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_socket<Protocol, RawSocketService>(
BOOST_ASIO_MOVE_CAST2(basic_raw_socket<
Protocol1, RawSocketService1>)(other))
{
}
/// Move-assign a basic_raw_socket from a socket of another protocol type.
/**
* This assignment operator moves a raw socket from one object to another.
*
* @param other The other basic_raw_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_raw_socket(io_service&) constructor.
*/
template <typename Protocol1, typename RawSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
basic_raw_socket>::type& operator=(
basic_raw_socket<Protocol1, RawSocketService1>&& other)
{
basic_socket<Protocol, RawSocketService>::operator=(
BOOST_ASIO_MOVE_CAST2(basic_raw_socket<
Protocol1, RawSocketService1>)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on a connected socket.
@ -285,14 +326,16 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(),
return this->get_service().async_send(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -325,7 +368,9 @@ public:
* socket.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -333,7 +378,7 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(),
return this->get_service().async_send(this->get_implementation(),
buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -463,7 +508,9 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send_to(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send_to(const ConstBufferSequence& buffers,
const endpoint_type& destination,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -471,8 +518,8 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send_to(this->get_implementation(), buffers,
destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
return this->get_service().async_send_to(this->get_implementation(),
buffers, destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Start an asynchronous send.
@ -503,7 +550,9 @@ public:
* boost::asio::io_service::post().
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send_to(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send_to(const ConstBufferSequence& buffers,
const endpoint_type& destination, socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -511,8 +560,9 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send_to(this->get_implementation(), buffers,
destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
return this->get_service().async_send_to(
this->get_implementation(), buffers, destination, flags,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
/// Receive some data on a connected socket.
@ -641,14 +691,16 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
@ -681,7 +733,9 @@ public:
* raw socket.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -689,7 +743,7 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
@ -819,7 +873,9 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive_from(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender_endpoint,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -827,8 +883,9 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive_from(this->get_implementation(), buffers,
sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return this->get_service().async_receive_from(
this->get_implementation(), buffers, sender_endpoint, 0,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
/// Start an asynchronous receive.
@ -861,7 +918,9 @@ public:
* boost::asio::io_service::post().
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive_from(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive_from(const MutableBufferSequence& buffers,
endpoint_type& sender_endpoint, socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -869,8 +928,9 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive_from(this->get_implementation(), buffers,
sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return this->get_service().async_receive_from(
this->get_implementation(), buffers, sender_endpoint, flags,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_seq_packet_socket.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -171,6 +171,51 @@ public:
BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other));
return *this;
}
/// Move-construct a basic_seq_packet_socket from a socket of another protocol
/// type.
/**
* This constructor moves a sequenced packet socket from one object to
* another.
*
* @param other The other basic_seq_packet_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
*/
template <typename Protocol1, typename SeqPacketSocketService1>
basic_seq_packet_socket(
basic_seq_packet_socket<Protocol1, SeqPacketSocketService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_socket<Protocol, SeqPacketSocketService>(
BOOST_ASIO_MOVE_CAST2(basic_seq_packet_socket<
Protocol1, SeqPacketSocketService1>)(other))
{
}
/// Move-assign a basic_seq_packet_socket from a socket of another protocol
/// type.
/**
* This assignment operator moves a sequenced packet socket from one object to
* another.
*
* @param other The other basic_seq_packet_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
*/
template <typename Protocol1, typename SeqPacketSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
basic_seq_packet_socket>::type& operator=(
basic_seq_packet_socket<Protocol1, SeqPacketSocketService1>&& other)
{
basic_socket<Protocol, SeqPacketSocketService>::operator=(
BOOST_ASIO_MOVE_CAST2(basic_seq_packet_socket<
Protocol1, SeqPacketSocketService1>)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on the socket.
@ -267,7 +312,9 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -275,7 +322,7 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(),
return this->get_service().async_send(this->get_implementation(),
buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -437,7 +484,9 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags& out_flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -445,8 +494,9 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(), buffers,
0, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return this->get_service().async_receive(
this->get_implementation(), buffers, 0, out_flags,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
/// Start an asynchronous receive.
@ -492,7 +542,9 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags in_flags,
socket_base::message_flags& out_flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
@ -501,8 +553,9 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(), buffers,
in_flags, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
return this->get_service().async_receive(
this->get_implementation(), buffers, in_flags, out_flags,
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_serial_port.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
@ -559,14 +559,16 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_write_some(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_write_some(this->get_implementation(),
return this->get_service().async_write_some(this->get_implementation(),
buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -670,14 +672,16 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_read_some(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_read_some(this->get_implementation(),
return this->get_service().async_read_some(this->get_implementation(),
buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_signal_set.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -365,13 +365,15 @@ public:
* boost::asio::io_service::post().
*/
template <typename SignalHandler>
void async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
BOOST_ASIO_INITFN_RESULT_TYPE(SignalHandler,
void (boost::system::error_code, int))
async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a SignalHandler.
BOOST_ASIO_SIGNAL_HANDLER_CHECK(SignalHandler, handler) type_check;
this->service.async_wait(this->implementation,
return this->service.async_wait(this->implementation,
BOOST_ASIO_MOVE_CAST(SignalHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_socket.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -16,9 +16,11 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/basic_io_object.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/socket_base.hpp>
@ -173,6 +175,51 @@ public:
BOOST_ASIO_MOVE_CAST(basic_socket)(other));
return *this;
}
// All sockets have access to each other's implementations.
template <typename Protocol1, typename SocketService1>
friend class basic_socket;
/// Move-construct a basic_socket from a socket of another protocol type.
/**
* This constructor moves a socket from one object to another.
*
* @param other The other basic_socket object from which the move will
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
*/
template <typename Protocol1, typename SocketService1>
basic_socket(basic_socket<Protocol1, SocketService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_io_object<SocketService>(other.get_io_service())
{
this->get_service().template converting_move_construct<Protocol1>(
this->get_implementation(), other.get_implementation());
}
/// Move-assign a basic_socket from a socket of another protocol type.
/**
* This assignment operator moves a socket from one object to another.
*
* @param other The other basic_socket object from which the move will
* occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
*/
template <typename Protocol1, typename SocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
basic_socket>::type& operator=(
basic_socket<Protocol1, SocketService1>&& other)
{
basic_socket tmp(BOOST_ASIO_MOVE_CAST2(basic_socket<
Protocol1, SocketService1>)(other));
basic_io_object<SocketService>::operator=(
BOOST_ASIO_MOVE_CAST(basic_socket)(tmp));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Get a reference to the lowest layer.
@ -395,7 +442,7 @@ public:
* CancelIoEx function is always used. This function does not have the
* problems described above.
*/
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) \
#if defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC >= 1400) \
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \
&& !defined(BOOST_ASIO_ENABLE_CANCELIO)
__declspec(deprecated("By default, this function always fails with "
@ -443,7 +490,7 @@ public:
* CancelIoEx function is always used. This function does not have the
* problems described above.
*/
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) \
#if defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC >= 1400) \
&& (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \
&& !defined(BOOST_ASIO_ENABLE_CANCELIO)
__declspec(deprecated("By default, this function always fails with "
@ -698,7 +745,9 @@ public:
* @endcode
*/
template <typename ConnectHandler>
void async_connect(const endpoint_type& peer_endpoint,
BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
void (boost::system::error_code))
async_connect(const endpoint_type& peer_endpoint,
BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
{
// If you get an error on the following line it means that your handler does
@ -711,14 +760,21 @@ public:
const protocol_type protocol = peer_endpoint.protocol();
if (this->get_service().open(this->get_implementation(), protocol, ec))
{
detail::async_result_init<
ConnectHandler, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
this->get_io_service().post(
boost::asio::detail::bind_handler(
BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler), ec));
return;
BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(
ConnectHandler, void (boost::system::error_code)))(
init.handler), ec));
return init.result.get();
}
}
this->get_service().async_connect(this->get_implementation(),
return this->get_service().async_connect(this->get_implementation(),
peer_endpoint, BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
}
@ -843,7 +899,7 @@ public:
* ...
* boost::asio::ip::tcp::socket::keep_alive option;
* socket.get_option(option);
* bool is_set = option.get();
* bool is_set = option.value();
* @endcode
*/
template <typename GettableSocketOption>
@ -891,7 +947,7 @@ public:
* {
* // An error occurred.
* }
* bool is_set = option.get();
* bool is_set = option.value();
* @endcode
*/
template <typename GettableSocketOption>

View file

@ -2,7 +2,7 @@
// basic_socket_acceptor.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -20,6 +20,7 @@
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/socket_acceptor_service.hpp>
#include <boost/asio/socket_base.hpp>
@ -211,6 +212,54 @@ public:
BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other));
return *this;
}
// All socket acceptors have access to each other's implementations.
template <typename Protocol1, typename SocketAcceptorService1>
friend class basic_socket_acceptor;
/// Move-construct a basic_socket_acceptor from an acceptor of another
/// protocol type.
/**
* This constructor moves an acceptor from one object to another.
*
* @param other The other basic_socket_acceptor object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
*/
template <typename Protocol1, typename SocketAcceptorService1>
basic_socket_acceptor(
basic_socket_acceptor<Protocol1, SocketAcceptorService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_io_object<SocketAcceptorService>(other.get_io_service())
{
this->get_service().template converting_move_construct<Protocol1>(
this->get_implementation(), other.get_implementation());
}
/// Move-assign a basic_socket_acceptor from an acceptor of another protocol
/// type.
/**
* This assignment operator moves an acceptor from one object to another.
*
* @param other The other basic_socket_acceptor object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_socket(io_service&) constructor.
*/
template <typename Protocol1, typename SocketAcceptorService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
basic_socket_acceptor>::type& operator=(
basic_socket_acceptor<Protocol1, SocketAcceptorService1>&& other)
{
basic_socket_acceptor tmp(BOOST_ASIO_MOVE_CAST2(basic_socket_acceptor<
Protocol1, SocketAcceptorService1>)(other));
basic_io_object<SocketAcceptorService>::operator=(
BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(tmp));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Open the acceptor using the specified protocol.
@ -316,8 +365,9 @@ public:
* @par Example
* @code
* boost::asio::ip::tcp::acceptor acceptor(io_service);
* acceptor.open(boost::asio::ip::tcp::v4());
* acceptor.bind(boost::asio::ip::tcp::endpoint(12345));
* boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 12345);
* acceptor.open(endpoint.protocol());
* acceptor.bind(endpoint);
* @endcode
*/
void bind(const endpoint_type& endpoint)
@ -340,9 +390,10 @@ public:
* @par Example
* @code
* boost::asio::ip::tcp::acceptor acceptor(io_service);
* acceptor.open(boost::asio::ip::tcp::v4());
* boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 12345);
* acceptor.open(endpoint.protocol());
* boost::system::error_code ec;
* acceptor.bind(boost::asio::ip::tcp::endpoint(12345), ec);
* acceptor.bind(endpoint, ec);
* if (ec)
* {
* // An error occurred.
@ -871,11 +922,13 @@ public:
* acceptor.accept(socket);
* @endcode
*/
template <typename SocketService>
void accept(basic_socket<protocol_type, SocketService>& peer)
template <typename Protocol1, typename SocketService>
void accept(basic_socket<Protocol1, SocketService>& peer,
typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
boost::system::error_code ec;
this->get_service().accept(this->get_implementation(), peer, 0, ec);
this->get_service().accept(this->get_implementation(),
peer, static_cast<endpoint_type*>(0), ec);
boost::asio::detail::throw_error(ec, "accept");
}
@ -902,12 +955,14 @@ public:
* }
* @endcode
*/
template <typename SocketService>
template <typename Protocol1, typename SocketService>
boost::system::error_code accept(
basic_socket<protocol_type, SocketService>& peer,
boost::system::error_code& ec)
basic_socket<Protocol1, SocketService>& peer,
boost::system::error_code& ec,
typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
return this->get_service().accept(this->get_implementation(), peer, 0, ec);
return this->get_service().accept(this->get_implementation(),
peer, static_cast<endpoint_type*>(0), ec);
}
/// Start an asynchronous accept.
@ -948,16 +1003,20 @@ public:
* acceptor.async_accept(socket, accept_handler);
* @endcode
*/
template <typename SocketService, typename AcceptHandler>
void async_accept(basic_socket<protocol_type, SocketService>& peer,
BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
template <typename Protocol1, typename SocketService, typename AcceptHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
void (boost::system::error_code))
async_accept(basic_socket<Protocol1, SocketService>& peer,
BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a AcceptHandler.
BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
this->get_service().async_accept(this->get_implementation(),
peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
return this->get_service().async_accept(this->get_implementation(),
peer, static_cast<endpoint_type*>(0),
BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
}
/// Accept a new connection and obtain the endpoint of the peer
@ -1057,14 +1116,16 @@ public:
* boost::asio::io_service::post().
*/
template <typename SocketService, typename AcceptHandler>
void async_accept(basic_socket<protocol_type, SocketService>& peer,
BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
void (boost::system::error_code))
async_accept(basic_socket<protocol_type, SocketService>& peer,
endpoint_type& peer_endpoint, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a AcceptHandler.
BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
this->get_service().async_accept(this->get_implementation(), peer,
return this->get_service().async_accept(this->get_implementation(), peer,
&peer_endpoint, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_socket_iostream.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,9 +17,10 @@
#include <boost/asio/detail/config.hpp>
#if !defined(BOOST_NO_IOSTREAM)
#if !defined(BOOST_ASIO_NO_IOSTREAM)
#include <boost/utility/base_from_member.hpp>
#include <istream>
#include <ostream>
#include <boost/asio/basic_socket_streambuf.hpp>
#include <boost/asio/stream_socket_service.hpp>
@ -37,9 +38,10 @@
// A macro that should expand to:
// template <typename T1, ..., typename Tn>
// explicit basic_socket_iostream(T1 x1, ..., Tn xn)
// : basic_iostream<char>(&this->boost::base_from_member<
// basic_socket_streambuf<Protocol, StreamSocketService,
// Time, TimeTraits, TimerService> >::member)
// : std::basic_iostream<char>(
// &this->detail::socket_iostream_base<
// Protocol, StreamSocketService, Time,
// TimeTraits, TimerService>::streambuf_)
// {
// if (rdbuf()->connect(x1, ..., xn) == 0)
// this->setstate(std::ios_base::failbit);
@ -49,9 +51,10 @@
# define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
: std::basic_iostream<char>(&this->boost::base_from_member< \
basic_socket_streambuf<Protocol, StreamSocketService, \
Time, TimeTraits, TimerService> >::member) \
: std::basic_iostream<char>( \
&this->detail::socket_iostream_base< \
Protocol, StreamSocketService, Time, \
TimeTraits, TimerService>::streambuf_) \
{ \
this->setf(std::ios_base::unitbuf); \
if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
@ -83,34 +86,69 @@
namespace boost {
namespace asio {
namespace detail {
// A separate base class is used to ensure that the streambuf is initialised
// prior to the basic_socket_iostream's basic_iostream base class.
template <typename Protocol, typename StreamSocketService,
typename Time, typename TimeTraits, typename TimerService>
class socket_iostream_base
{
protected:
basic_socket_streambuf<Protocol, StreamSocketService,
Time, TimeTraits, TimerService> streambuf_;
};
}
/// Iostream interface for a socket.
template <typename Protocol,
typename StreamSocketService = stream_socket_service<Protocol>,
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
|| defined(GENERATING_DOCUMENTATION)
typename Time = boost::posix_time::ptime,
typename TimeTraits = boost::asio::time_traits<Time>,
typename TimerService = deadline_timer_service<Time, TimeTraits> >
#else
typename Time = steady_timer::clock_type,
typename TimeTraits = steady_timer::traits_type,
typename TimerService = steady_timer::service_type>
#endif
class basic_socket_iostream
: public boost::base_from_member<
basic_socket_streambuf<Protocol, StreamSocketService,
Time, TimeTraits, TimerService> >,
: private detail::socket_iostream_base<Protocol,
StreamSocketService, Time, TimeTraits, TimerService>,
public std::basic_iostream<char>
{
private:
// These typedefs are intended keep this class's implementation independent
// of whether it's using Boost.DateTime, Boost.Chrono or std::chrono.
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
typedef TimeTraits traits_helper;
#else
typedef detail::chrono_time_traits<Time, TimeTraits> traits_helper;
#endif
public:
/// The endpoint type.
typedef typename Protocol::endpoint endpoint_type;
#if defined(GENERATING_DOCUMENTATION)
/// The time type.
typedef typename TimeTraits::time_type time_type;
/// The duration type.
typedef typename TimeTraits::duration_type duration_type;
#else
typedef typename traits_helper::time_type time_type;
typedef typename traits_helper::duration_type duration_type;
#endif
/// Construct a basic_socket_iostream without establishing a connection.
basic_socket_iostream()
: std::basic_iostream<char>(&this->boost::base_from_member<
basic_socket_streambuf<Protocol, StreamSocketService,
Time, TimeTraits, TimerService> >::member)
: std::basic_iostream<char>(
&this->detail::socket_iostream_base<
Protocol, StreamSocketService, Time,
TimeTraits, TimerService>::streambuf_)
{
this->setf(std::ios_base::unitbuf);
}
@ -127,9 +165,10 @@ public:
#elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename... T>
explicit basic_socket_iostream(T... x)
: std::basic_iostream<char>(&this->boost::base_from_member<
basic_socket_streambuf<Protocol, StreamSocketService,
Time, TimeTraits, TimerService> >::member)
: std::basic_iostream<char>(
&this->detail::socket_iostream_base<
Protocol, StreamSocketService, Time,
TimeTraits, TimerService>::streambuf_)
{
this->setf(std::ios_base::unitbuf);
if (rdbuf()->connect(x...) == 0)
@ -176,9 +215,9 @@ public:
{
return const_cast<basic_socket_streambuf<Protocol, StreamSocketService,
Time, TimeTraits, TimerService>*>(
&this->boost::base_from_member<
basic_socket_streambuf<Protocol, StreamSocketService,
Time, TimeTraits, TimerService> >::member);
&this->detail::socket_iostream_base<
Protocol, StreamSocketService, Time,
TimeTraits, TimerService>::streambuf_);
}
/// Get the last error associated with the stream.
@ -255,6 +294,6 @@ public:
# undef BOOST_ASIO_PRIVATE_CONNECT_DEF
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
#endif // defined(BOOST_NO_IOSTREAM)
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
#endif // BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP

View file

@ -2,7 +2,7 @@
// basic_socket_streambuf.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,21 +17,21 @@
#include <boost/asio/detail/config.hpp>
#if !defined(BOOST_NO_IOSTREAM)
#if !defined(BOOST_ASIO_NO_IOSTREAM)
#include <streambuf>
#include <boost/utility/base_from_member.hpp>
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/deadline_timer_service.hpp>
#include <boost/asio/detail/array.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/stream_socket_service.hpp>
#include <boost/asio/time_traits.hpp>
#include <boost/asio/detail/push_options.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/asio/detail/pop_options.hpp>
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
# include <boost/asio/deadline_timer.hpp>
#else
# include <boost/asio/steady_timer.hpp>
#endif
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
@ -82,32 +82,64 @@
namespace boost {
namespace asio {
namespace detail {
// A separate base class is used to ensure that the io_service is initialised
// prior to the basic_socket_streambuf's basic_socket base class.
class socket_streambuf_base
{
protected:
io_service io_service_;
};
} // namespace detail
/// Iostream streambuf for a socket.
template <typename Protocol,
typename StreamSocketService = stream_socket_service<Protocol>,
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
|| defined(GENERATING_DOCUMENTATION)
typename Time = boost::posix_time::ptime,
typename TimeTraits = boost::asio::time_traits<Time>,
typename TimerService = deadline_timer_service<Time, TimeTraits> >
#else
typename Time = steady_timer::clock_type,
typename TimeTraits = steady_timer::traits_type,
typename TimerService = steady_timer::service_type>
#endif
class basic_socket_streambuf
: public std::streambuf,
private boost::base_from_member<io_service>,
private detail::socket_streambuf_base,
public basic_socket<Protocol, StreamSocketService>
{
private:
// These typedefs are intended keep this class's implementation independent
// of whether it's using Boost.DateTime, Boost.Chrono or std::chrono.
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
typedef TimeTraits traits_helper;
#else
typedef detail::chrono_time_traits<Time, TimeTraits> traits_helper;
#endif
public:
/// The endpoint type.
typedef typename Protocol::endpoint endpoint_type;
#if defined(GENERATING_DOCUMENTATION)
/// The time type.
typedef typename TimeTraits::time_type time_type;
/// The duration type.
typedef typename TimeTraits::duration_type duration_type;
#else
typedef typename traits_helper::time_type time_type;
typedef typename traits_helper::duration_type duration_type;
#endif
/// Construct a basic_socket_streambuf without establishing a connection.
basic_socket_streambuf()
: basic_socket<Protocol, StreamSocketService>(
boost::base_from_member<boost::asio::io_service>::member),
this->detail::socket_streambuf_base::io_service_),
unbuffered_(false),
timer_service_(0),
timer_state_(no_timer)
@ -252,7 +284,7 @@ public:
*/
duration_type expires_from_now() const
{
return TimeTraits::subtract(expires_at(), TimeTraits::now());
return traits_helper::subtract(expires_at(), traits_helper::now());
}
/// Set the stream buffer's expiry time relative to now.
@ -424,8 +456,7 @@ private:
{
typedef typename Protocol::resolver resolver_type;
typedef typename resolver_type::iterator iterator_type;
resolver_type resolver(
boost::base_from_member<boost::asio::io_service>::member);
resolver_type resolver(detail::socket_streambuf_base::io_service_);
iterator_type i = resolver.resolve(query, ec_);
if (!ec_)
{
@ -477,12 +508,12 @@ private:
void operator()(const boost::system::error_code&)
{
time_type now = TimeTraits::now();
time_type now = traits_helper::now();
time_type expiry_time = this_->timer_service_->expires_at(
this_->timer_implementation_);
if (TimeTraits::less_than(now, expiry_time))
if (traits_helper::less_than(now, expiry_time))
{
this_->timer_state_ = timer_is_pending;
this_->timer_service_->async_wait(this_->timer_implementation_, *this);
@ -501,7 +532,7 @@ private:
if (timer_service_ == 0)
{
TimerService& timer_service = use_service<TimerService>(
boost::base_from_member<boost::asio::io_service>::member);
detail::socket_streambuf_base::io_service_);
timer_service.construct(timer_implementation_);
timer_service_ = &timer_service;
}
@ -543,6 +574,6 @@ private:
# undef BOOST_ASIO_PRIVATE_CONNECT_DEF
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
#endif // !defined(BOOST_NO_IOSTREAM)
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
#endif // BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP

View file

@ -2,7 +2,7 @@
// basic_stream_socket.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,6 +17,7 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/async_result.hpp>
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
@ -166,6 +167,48 @@ public:
BOOST_ASIO_MOVE_CAST(basic_stream_socket)(other));
return *this;
}
/// Move-construct a basic_stream_socket from a socket of another protocol
/// type.
/**
* This constructor moves a stream socket from one object to another.
*
* @param other The other basic_stream_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_socket(io_service&) constructor.
*/
template <typename Protocol1, typename StreamSocketService1>
basic_stream_socket(
basic_stream_socket<Protocol1, StreamSocketService1>&& other,
typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
: basic_socket<Protocol, StreamSocketService>(
BOOST_ASIO_MOVE_CAST2(basic_stream_socket<
Protocol1, StreamSocketService1>)(other))
{
}
/// Move-assign a basic_stream_socket from a socket of another protocol type.
/**
* This assignment operator moves a stream socket from one object to another.
*
* @param other The other basic_stream_socket object from which the move
* will occur.
*
* @note Following the move, the moved-from object is in the same state as if
* constructed using the @c basic_stream_socket(io_service&) constructor.
*/
template <typename Protocol1, typename StreamSocketService1>
typename enable_if<is_convertible<Protocol1, Protocol>::value,
basic_stream_socket>::type& operator=(
basic_stream_socket<Protocol1, StreamSocketService1>&& other)
{
basic_socket<Protocol, StreamSocketService>::operator=(
BOOST_ASIO_MOVE_CAST2(basic_stream_socket<
Protocol1, StreamSocketService1>)(other));
return *this;
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on the socket.
@ -303,14 +346,17 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(), buffers, 0,
return this->get_service().async_send(
this->get_implementation(), buffers, 0,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -352,7 +398,9 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(const ConstBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
@ -360,7 +408,8 @@ public:
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(), buffers, flags,
return this->get_service().async_send(
this->get_implementation(), buffers, flags,
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -507,14 +556,16 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
@ -558,7 +609,9 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(const MutableBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
@ -566,7 +619,7 @@ public:
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
@ -666,14 +719,16 @@ public:
* std::vector.
*/
template <typename ConstBufferSequence, typename WriteHandler>
void async_write_some(const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_write_some(const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
this->get_service().async_send(this->get_implementation(),
return this->get_service().async_send(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
}
@ -777,14 +832,16 @@ public:
* std::vector.
*/
template <typename MutableBufferSequence, typename ReadHandler>
void async_read_some(const MutableBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_read_some(const MutableBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a ReadHandler.
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
this->get_service().async_receive(this->get_implementation(),
return this->get_service().async_receive(this->get_implementation(),
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// basic_streambuf.hpp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,18 +17,18 @@
#include <boost/asio/detail/config.hpp>
#if !defined(BOOST_NO_IOSTREAM)
#if !defined(BOOST_ASIO_NO_IOSTREAM)
#include <algorithm>
#include <cstring>
#include <stdexcept>
#include <streambuf>
#include <vector>
#include <boost/limits.hpp>
#include <boost/throw_exception.hpp>
#include <boost/asio/basic_streambuf_fwd.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/detail/limits.hpp>
#include <boost/asio/detail/noncopyable.hpp>
#include <boost/asio/detail/throw_exception.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -327,7 +327,7 @@ protected:
else
{
std::length_error ex("boost::asio::streambuf too long");
boost::throw_exception(ex);
boost::asio::detail::throw_exception(ex);
}
}
@ -365,6 +365,6 @@ inline std::size_t read_size_helper(
#include <boost/asio/detail/pop_options.hpp>
#endif // !defined(BOOST_NO_IOSTREAM)
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
#endif // BOOST_ASIO_BASIC_STREAMBUF_HPP

View file

@ -2,7 +2,7 @@
// basic_streambuf_fwd.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,7 +17,7 @@
#include <boost/asio/detail/config.hpp>
#if !defined(BOOST_NO_IOSTREAM)
#if !defined(BOOST_ASIO_NO_IOSTREAM)
#include <memory>
@ -30,6 +30,6 @@ class basic_streambuf;
} // namespace asio
} // namespace boost
#endif // !defined(BOOST_NO_IOSTREAM)
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
#endif // BOOST_ASIO_BASIC_STREAMBUF_FWD_HPP

View file

@ -2,7 +2,7 @@
// basic_waitable_timer.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -38,7 +38,8 @@ namespace asio {
* If the wait() or async_wait() function is called on an expired timer, the
* wait operation will complete immediately.
*
* Most applications will use the boost::asio::waitable_timer typedef.
* Most applications will use one of the boost::asio::steady_timer,
* boost::asio::system_timer or boost::asio::high_resolution_timer typedefs.
*
* @note This waitable timer functionality is for use with the C++11 standard
* library's @c &lt;chrono&gt; facility, or with the Boost.Chrono library.
@ -48,20 +49,20 @@ namespace asio {
* @e Shared @e objects: Unsafe.
*
* @par Examples
* Performing a blocking wait:
* Performing a blocking wait (C++11):
* @code
* // Construct a timer without setting an expiry time.
* boost::asio::waitable_timer timer(io_service);
* boost::asio::steady_timer timer(io_service);
*
* // Set an expiry time relative to now.
* timer.expires_from_now(boost::posix_time::seconds(5));
* timer.expires_from_now(std::chrono::seconds(5));
*
* // Wait for the timer to expire.
* timer.wait();
* @endcode
*
* @par
* Performing an asynchronous wait:
* Performing an asynchronous wait (C++11):
* @code
* void handler(const boost::system::error_code& error)
* {
@ -74,14 +75,14 @@ namespace asio {
* ...
*
* // Construct a timer with an absolute expiry time.
* boost::asio::waitable_timer timer(io_service,
* boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
* boost::asio::steady_timer timer(io_service,
* std::chrono::steady_clock::now() + std::chrono::seconds(60));
*
* // Start an asynchronous wait.
* timer.async_wait(handler);
* @endcode
*
* @par Changing an active waitable_timer's expiry time
* @par Changing an active waitable timer's expiry time
*
* Changing the expiry time of a timer while there are pending asynchronous
* waits causes those wait operations to be cancelled. To ensure that the action
@ -499,13 +500,15 @@ public:
* boost::asio::io_service::post().
*/
template <typename WaitHandler>
void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
void (boost::system::error_code))
async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WaitHandler.
BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
this->service.async_wait(this->implementation,
return this->service.async_wait(this->implementation,
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
}
};

View file

@ -2,7 +2,7 @@
// buffer.hpp
// ~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -20,16 +20,15 @@
#include <cstring>
#include <string>
#include <vector>
#include <boost/detail/workaround.hpp>
#include <boost/asio/detail/array_fwd.hpp>
#if defined(BOOST_MSVC)
#if defined(BOOST_ASIO_MSVC)
# if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0)
# if !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING)
# define BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
# endif // !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING)
# endif // defined(_HAS_ITERATOR_DEBUGGING)
#endif // defined(BOOST_MSVC)
#endif // defined(BOOST_ASIO_MSVC)
#if defined(__GNUC__)
# if defined(_GLIBCXX_DEBUG)
@ -40,14 +39,21 @@
#endif // defined(__GNUC__)
#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
# include <boost/function.hpp>
# include <boost/asio/detail/function.hpp>
#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
# include <boost/type_traits/is_const.hpp>
#endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
// || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
#if defined(BOOST_ASIO_HAS_BOOST_WORKAROUND)
# include <boost/detail/workaround.hpp>
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
# define BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND
# endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
// || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
#endif // defined(BOOST_ASIO_HAS_BOOST_WORKAROUND)
#if defined(BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND)
# include <boost/asio/detail/type_traits.hpp>
#endif // defined(BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND)
#include <boost/asio/detail/push_options.hpp>
@ -102,14 +108,14 @@ public:
#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
mutable_buffer(void* data, std::size_t size,
boost::function<void()> debug_check)
boost::asio::detail::function<void()> debug_check)
: data_(data),
size_(size),
debug_check_(debug_check)
{
}
const boost::function<void()>& get_debug_check() const
const boost::asio::detail::function<void()>& get_debug_check() const
{
return debug_check_;
}
@ -125,7 +131,7 @@ private:
std::size_t size_;
#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
boost::function<void()> debug_check_;
boost::asio::detail::function<void()> debug_check_;
#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
};
@ -232,14 +238,14 @@ public:
#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
const_buffer(const void* data, std::size_t size,
boost::function<void()> debug_check)
boost::asio::detail::function<void()> debug_check)
: data_(data),
size_(size),
debug_check_(debug_check)
{
}
const boost::function<void()>& get_debug_check() const
const boost::asio::detail::function<void()>& get_debug_check() const
{
return debug_check_;
}
@ -255,7 +261,7 @@ private:
std::size_t size_;
#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
boost::function<void()> debug_check_;
boost::asio::detail::function<void()> debug_check_;
#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
};
@ -512,12 +518,12 @@ public:
~buffer_debug_check()
{
#if BOOST_WORKAROUND(BOOST_MSVC, == 1400)
#if defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC == 1400)
// MSVC 8's string iterator checking may crash in a std::string::iterator
// object's destructor when the iterator points to an already-destroyed
// std::string object, unless the iterator is cleared first.
iter_ = Iterator();
#endif // BOOST_WORKAROUND(BOOST_MSVC, == 1400)
#endif // defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC == 1400)
}
void operator()()
@ -828,8 +834,7 @@ inline const_buffers_1 buffer(const PodType (&data)[N],
? N * sizeof(PodType) : max_size_in_bytes));
}
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
#if defined(BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND)
// Borland C++ and Sun Studio think the overloads:
//
@ -864,7 +869,7 @@ struct buffer_types_base<true>
template <typename PodType>
struct buffer_types
: public buffer_types_base<boost::is_const<PodType>::value>
: public buffer_types_base<is_const<PodType>::value>
{
};
@ -896,8 +901,7 @@ buffer(boost::array<PodType, N>& data, std::size_t max_size_in_bytes)
? data.size() * sizeof(PodType) : max_size_in_bytes));
}
#else // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
// || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
#else // defined(BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND)
/// Create a new modifiable buffer that represents the given POD array.
/**
@ -961,8 +965,7 @@ inline const_buffers_1 buffer(boost::array<const PodType, N>& data,
? data.size() * sizeof(PodType) : max_size_in_bytes));
}
#endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
// || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
#endif // defined(BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND)
/// Create a new non-modifiable buffer that represents the given POD array.
/**

View file

@ -2,7 +2,7 @@
// buffered_read_stream.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,13 +17,13 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/asio/buffered_read_stream_fwd.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/buffer_resize_guard.hpp>
#include <boost/asio/detail/buffered_stream_storage.hpp>
#include <boost/asio/detail/noncopyable.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@ -50,7 +50,7 @@ class buffered_read_stream
{
public:
/// The type of the next layer.
typedef typename boost::remove_reference<Stream>::type next_layer_type;
typedef typename remove_reference<Stream>::type next_layer_type;
/// The type of the lowest layer.
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
@ -59,7 +59,7 @@ public:
/// The default buffer size.
static const std::size_t default_buffer_size = implementation_defined;
#else
BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
BOOST_ASIO_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
#endif
/// Construct, passing the specified argument to initialise the next layer.

View file

@ -2,7 +2,7 @@
// buffered_read_stream_fwd.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// buffered_stream.hpp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -47,7 +47,7 @@ class buffered_stream
{
public:
/// The type of the next layer.
typedef typename boost::remove_reference<Stream>::type next_layer_type;
typedef typename remove_reference<Stream>::type next_layer_type;
/// The type of the lowest layer.
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;

View file

@ -2,7 +2,7 @@
// buffered_stream_fwd.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// buffered_write_stream.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,13 +17,13 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/asio/buffered_write_stream_fwd.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/completion_condition.hpp>
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/buffered_stream_storage.hpp>
#include <boost/asio/detail/noncopyable.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/write.hpp>
@ -51,7 +51,7 @@ class buffered_write_stream
{
public:
/// The type of the next layer.
typedef typename boost::remove_reference<Stream>::type next_layer_type;
typedef typename remove_reference<Stream>::type next_layer_type;
/// The type of the lowest layer.
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
@ -60,7 +60,7 @@ public:
/// The default buffer size.
static const std::size_t default_buffer_size = implementation_defined;
#else
BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
BOOST_ASIO_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
#endif
/// Construct, passing the specified argument to initialise the next layer.

View file

@ -2,7 +2,7 @@
// buffered_write_stream_fwd.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// buffers_iterator.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -18,11 +18,9 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <iterator>
#include <boost/assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/detail/assert.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -41,7 +39,7 @@ namespace detail
template <typename ByteType>
struct byte_type
{
typedef typename boost::add_const<ByteType>::type type;
typedef typename add_const<ByteType>::type type;
};
};
@ -61,8 +59,9 @@ namespace detail
{
enum
{
is_mutable = boost::is_convertible<
typename BufferSequence::value_type, mutable_buffer>::value
is_mutable = is_convertible<
typename BufferSequence::value_type,
mutable_buffer>::value
};
typedef buffers_iterator_types_helper<is_mutable> helper;
typedef typename helper::buffer_type buffer_type;
@ -127,9 +126,9 @@ public:
/// Construct an iterator representing the beginning of the buffers' data.
static buffers_iterator begin(const BufferSequence& buffers)
#if BOOST_WORKAROUND(__GNUC__, == 4) && BOOST_WORKAROUND(__GNUC_MINOR__, == 3)
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
__attribute__ ((__noinline__))
#endif
#endif // defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
{
buffers_iterator new_iter;
new_iter.begin_ = buffers.begin();
@ -147,9 +146,9 @@ public:
/// Construct an iterator representing the end of the buffers' data.
static buffers_iterator end(const BufferSequence& buffers)
#if BOOST_WORKAROUND(__GNUC__, == 4) && BOOST_WORKAROUND(__GNUC_MINOR__, == 3)
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
__attribute__ ((__noinline__))
#endif
#endif // defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
{
buffers_iterator new_iter;
new_iter.begin_ = buffers.begin();
@ -314,7 +313,7 @@ private:
// Increment the iterator.
void increment()
{
BOOST_ASSERT(current_ != end_ && "iterator out of bounds");
BOOST_ASIO_ASSERT(current_ != end_ && "iterator out of bounds");
++position_;
// Check if the increment can be satisfied by the current buffer.
@ -337,7 +336,7 @@ private:
// Decrement the iterator.
void decrement()
{
BOOST_ASSERT(position_ > 0 && "iterator out of bounds");
BOOST_ASIO_ASSERT(position_ > 0 && "iterator out of bounds");
--position_;
// Check if the decrement can be satisfied by the current buffer.
@ -369,7 +368,7 @@ private:
{
if (n > 0)
{
BOOST_ASSERT(current_ != end_ && "iterator out of bounds");
BOOST_ASIO_ASSERT(current_ != end_ && "iterator out of bounds");
for (;;)
{
std::ptrdiff_t current_buffer_balance
@ -392,7 +391,7 @@ private:
// next iteration of this loop.
if (++current_ == end_)
{
BOOST_ASSERT(n == 0 && "iterator out of bounds");
BOOST_ASIO_ASSERT(n == 0 && "iterator out of bounds");
current_buffer_ = buffer_type();
current_buffer_position_ = 0;
return;
@ -404,7 +403,7 @@ private:
else if (n < 0)
{
std::size_t abs_n = -n;
BOOST_ASSERT(position_ >= abs_n && "iterator out of bounds");
BOOST_ASIO_ASSERT(position_ >= abs_n && "iterator out of bounds");
for (;;)
{
// Check if the advance can be satisfied by the current buffer.
@ -422,7 +421,7 @@ private:
// Check if we've reached the beginning of the buffers.
if (current_ == begin_)
{
BOOST_ASSERT(abs_n == 0 && "iterator out of bounds");
BOOST_ASIO_ASSERT(abs_n == 0 && "iterator out of bounds");
current_buffer_position_ = 0;
return;
}

View file

@ -2,7 +2,7 @@
// completion_condition.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// connect.hpp
// ~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -16,6 +16,7 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/error.hpp>
@ -516,7 +517,9 @@ Iterator connect(basic_socket<Protocol, SocketService>& s,
*/
template <typename Protocol, typename SocketService,
typename Iterator, typename ComposedConnectHandler>
void async_connect(basic_socket<Protocol, SocketService>& s,
BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
void (boost::system::error_code, Iterator))
async_connect(basic_socket<Protocol, SocketService>& s,
Iterator begin, BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
/// Asynchronously establishes a socket connection by trying each endpoint in a
@ -585,7 +588,9 @@ void async_connect(basic_socket<Protocol, SocketService>& s,
*/
template <typename Protocol, typename SocketService,
typename Iterator, typename ComposedConnectHandler>
void async_connect(basic_socket<Protocol, SocketService>& s,
BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
void (boost::system::error_code, Iterator))
async_connect(basic_socket<Protocol, SocketService>& s,
Iterator begin, Iterator end,
BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
@ -693,7 +698,9 @@ void async_connect(basic_socket<Protocol, SocketService>& s,
*/
template <typename Protocol, typename SocketService, typename Iterator,
typename ConnectCondition, typename ComposedConnectHandler>
void async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
void (boost::system::error_code, Iterator))
async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
ConnectCondition connect_condition,
BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
@ -800,7 +807,9 @@ void async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
*/
template <typename Protocol, typename SocketService, typename Iterator,
typename ConnectCondition, typename ComposedConnectHandler>
void async_connect(basic_socket<Protocol, SocketService>& s,
BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
void (boost::system::error_code, Iterator))
async_connect(basic_socket<Protocol, SocketService>& s,
Iterator begin, Iterator end, ConnectCondition connect_condition,
BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);

View file

@ -0,0 +1,330 @@
//
// coroutine.hpp
// ~~~~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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_ASIO_COROUTINE_HPP
#define BOOST_ASIO_COROUTINE_HPP
namespace boost {
namespace asio {
namespace detail {
class coroutine_ref;
} // namespace detail
/// Provides support for implementing stackless coroutines.
/**
* The @c coroutine class may be used to implement stackless coroutines. The
* class itself is used to store the current state of the coroutine.
*
* Coroutines are copy-constructible and assignable, and the space overhead is
* a single int. They can be used as a base class:
*
* @code class session : coroutine
* {
* ...
* }; @endcode
*
* or as a data member:
*
* @code class session
* {
* ...
* coroutine coro_;
* }; @endcode
*
* or even bound in as a function argument using lambdas or @c bind(). The
* important thing is that as the application maintains a copy of the object
* for as long as the coroutine must be kept alive.
*
* @par Pseudo-keywords
*
* A coroutine is used in conjunction with certain "pseudo-keywords", which
* are implemented as macros. These macros are defined by a header file:
*
* @code #include <boost/asio/yield.hpp>@endcode
*
* and may conversely be undefined as follows:
*
* @code #include <boost/asio/unyield.hpp>@endcode
*
* <b>reenter</b>
*
* The @c reenter macro is used to define the body of a coroutine. It takes a
* single argument: a pointer or reference to a coroutine object. For example,
* if the base class is a coroutine object you may write:
*
* @code reenter (this)
* {
* ... coroutine body ...
* } @endcode
*
* and if a data member or other variable you can write:
*
* @code reenter (coro_)
* {
* ... coroutine body ...
* } @endcode
*
* When @c reenter is executed at runtime, control jumps to the location of the
* last @c yield or @c fork.
*
* The coroutine body may also be a single statement, such as:
*
* @code reenter (this) for (;;)
* {
* ...
* } @endcode
*
* @b Limitation: The @c reenter macro is implemented using a switch. This
* means that you must take care when using local variables within the
* coroutine body. The local variable is not allowed in a position where
* reentering the coroutine could bypass the variable definition.
*
* <b>yield <em>statement</em></b>
*
* This form of the @c yield keyword is often used with asynchronous operations:
*
* @code yield socket_->async_read_some(buffer(*buffer_), *this); @endcode
*
* This divides into four logical steps:
*
* @li @c yield saves the current state of the coroutine.
* @li The statement initiates the asynchronous operation.
* @li The resume point is defined immediately following the statement.
* @li Control is transferred to the end of the coroutine body.
*
* When the asynchronous operation completes, the function object is invoked
* and @c reenter causes control to transfer to the resume point. It is
* important to remember to carry the coroutine state forward with the
* asynchronous operation. In the above snippet, the current class is a
* function object object with a coroutine object as base class or data member.
*
* The statement may also be a compound statement, and this permits us to
* define local variables with limited scope:
*
* @code yield
* {
* mutable_buffers_1 b = buffer(*buffer_);
* socket_->async_read_some(b, *this);
* } @endcode
*
* <b>yield return <em>expression</em> ;</b>
*
* This form of @c yield is often used in generators or coroutine-based parsers.
* For example, the function object:
*
* @code struct interleave : coroutine
* {
* istream& is1;
* istream& is2;
* char operator()(char c)
* {
* reenter (this) for (;;)
* {
* yield return is1.get();
* yield return is2.get();
* }
* }
* }; @endcode
*
* defines a trivial coroutine that interleaves the characters from two input
* streams.
*
* This type of @c yield divides into three logical steps:
*
* @li @c yield saves the current state of the coroutine.
* @li The resume point is defined immediately following the semicolon.
* @li The value of the expression is returned from the function.
*
* <b>yield ;</b>
*
* This form of @c yield is equivalent to the following steps:
*
* @li @c yield saves the current state of the coroutine.
* @li The resume point is defined immediately following the semicolon.
* @li Control is transferred to the end of the coroutine body.
*
* This form might be applied when coroutines are used for cooperative
* threading and scheduling is explicitly managed. For example:
*
* @code struct task : coroutine
* {
* ...
* void operator()()
* {
* reenter (this)
* {
* while (... not finished ...)
* {
* ... do something ...
* yield;
* ... do some more ...
* yield;
* }
* }
* }
* ...
* };
* ...
* task t1, t2;
* for (;;)
* {
* t1();
* t2();
* } @endcode
*
* <b>yield break ;</b>
*
* The final form of @c yield is used to explicitly terminate the coroutine.
* This form is comprised of two steps:
*
* @li @c yield sets the coroutine state to indicate termination.
* @li Control is transferred to the end of the coroutine body.
*
* Once terminated, calls to is_complete() return true and the coroutine cannot
* be reentered.
*
* Note that a coroutine may also be implicitly terminated if the coroutine
* body is exited without a yield, e.g. by return, throw or by running to the
* end of the body.
*
* <b>fork <em>statement</em></b>
*
* The @c fork pseudo-keyword is used when "forking" a coroutine, i.e. splitting
* it into two (or more) copies. One use of @c fork is in a server, where a new
* coroutine is created to handle each client connection:
*
* @code reenter (this)
* {
* do
* {
* socket_.reset(new tcp::socket(io_service_));
* yield acceptor->async_accept(*socket_, *this);
* fork server(*this)();
* } while (is_parent());
* ... client-specific handling follows ...
* } @endcode
*
* The logical steps involved in a @c fork are:
*
* @li @c fork saves the current state of the coroutine.
* @li The statement creates a copy of the coroutine and either executes it
* immediately or schedules it for later execution.
* @li The resume point is defined immediately following the semicolon.
* @li For the "parent", control immediately continues from the next line.
*
* The functions is_parent() and is_child() can be used to differentiate
* between parent and child. You would use these functions to alter subsequent
* control flow.
*
* Note that @c fork doesn't do the actual forking by itself. It is the
* application's responsibility to create a clone of the coroutine and call it.
* The clone can be called immediately, as above, or scheduled for delayed
* execution using something like io_service::post().
*
* @par Alternate macro names
*
* If preferred, an application can use macro names that follow a more typical
* naming convention, rather than the pseudo-keywords. These are:
*
* @li @c BOOST_ASIO_CORO_REENTER instead of @c reenter
* @li @c BOOST_ASIO_CORO_YIELD instead of @c yield
* @li @c BOOST_ASIO_CORO_FORK instead of @c fork
*/
class coroutine
{
public:
/// Constructs a coroutine in its initial state.
coroutine() : value_(0) {}
/// Returns true if the coroutine is the child of a fork.
bool is_child() const { return value_ < 0; }
/// Returns true if the coroutine is the parent of a fork.
bool is_parent() const { return !is_child(); }
/// Returns true if the coroutine has reached its terminal state.
bool is_complete() const { return value_ == -1; }
private:
friend class detail::coroutine_ref;
int value_;
};
namespace detail {
class coroutine_ref
{
public:
coroutine_ref(coroutine& c) : value_(c.value_), modified_(false) {}
coroutine_ref(coroutine* c) : value_(c->value_), modified_(false) {}
~coroutine_ref() { if (!modified_) value_ = -1; }
operator int() const { return value_; }
int& operator=(int v) { modified_ = true; return value_ = v; }
private:
void operator=(const coroutine_ref&);
int& value_;
bool modified_;
};
} // namespace detail
} // namespace asio
} // namespace boost
#define BOOST_ASIO_CORO_REENTER(c) \
switch (::boost::asio::detail::coroutine_ref _coro_value = c) \
case -1: if (_coro_value) \
{ \
goto terminate_coroutine; \
terminate_coroutine: \
_coro_value = -1; \
goto bail_out_of_coroutine; \
bail_out_of_coroutine: \
break; \
} \
else case 0:
#define BOOST_ASIO_CORO_YIELD_IMPL(n) \
for (_coro_value = (n);;) \
if (_coro_value == 0) \
{ \
case (n): ; \
break; \
} \
else \
switch (_coro_value ? 0 : 1) \
for (;;) \
case -1: if (_coro_value) \
goto terminate_coroutine; \
else for (;;) \
case 1: if (_coro_value) \
goto bail_out_of_coroutine; \
else case 0:
#define BOOST_ASIO_CORO_FORK_IMPL(n) \
for (_coro_value = -(n);; _coro_value = (n)) \
if (_coro_value == (n)) \
{ \
case -(n): ; \
break; \
} \
else
#if defined(_MSC_VER)
# define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__COUNTER__ + 1)
# define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__COUNTER__ + 1)
#else // defined(_MSC_VER)
# define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__LINE__)
# define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__LINE__)
#endif // defined(_MSC_VER)
#endif // BOOST_ASIO_COROUTINE_HPP

View file

@ -2,7 +2,7 @@
// datagram_socket_service.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,6 +17,8 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@ -111,6 +113,19 @@ public:
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
/// Move-construct a new datagram socket implementation from another protocol
/// type.
template <typename Protocol1>
void converting_move_construct(implementation_type& impl,
typename datagram_socket_service<
Protocol1>::implementation_type& other_impl,
typename enable_if<is_convertible<
Protocol1, Protocol>::value>::type* = 0)
{
service_impl_.template converting_move_construct<Protocol1>(
impl, other_impl);
}
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a datagram socket implementation.
@ -200,12 +215,19 @@ public:
/// Start an asynchronous connect.
template <typename ConnectHandler>
void async_connect(implementation_type& impl,
BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
void (boost::system::error_code))
async_connect(implementation_type& impl,
const endpoint_type& peer_endpoint,
BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
{
service_impl_.async_connect(impl, peer_endpoint,
detail::async_result_init<
ConnectHandler, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
service_impl_.async_connect(impl, peer_endpoint, init.handler);
return init.result.get();
}
/// Set a socket option.
@ -290,12 +312,19 @@ public:
/// Start an asynchronous send.
template <typename ConstBufferSequence, typename WriteHandler>
void async_send(implementation_type& impl, const ConstBufferSequence& buffers,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send(implementation_type& impl, const ConstBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
service_impl_.async_send(impl, buffers, flags,
detail::async_result_init<
WriteHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
service_impl_.async_send(impl, buffers, flags, init.handler);
return init.result.get();
}
/// Send a datagram to the specified endpoint.
@ -309,13 +338,21 @@ public:
/// Start an asynchronous send.
template <typename ConstBufferSequence, typename WriteHandler>
void async_send_to(implementation_type& impl,
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_send_to(implementation_type& impl,
const ConstBufferSequence& buffers, const endpoint_type& destination,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
service_impl_.async_send_to(impl, buffers, destination, flags,
detail::async_result_init<
WriteHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
service_impl_.async_send_to(impl, buffers,
destination, flags, init.handler);
return init.result.get();
}
/// Receive some data from the peer.
@ -329,13 +366,20 @@ public:
/// Start an asynchronous receive.
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive(implementation_type& impl,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive(implementation_type& impl,
const MutableBufferSequence& buffers,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
service_impl_.async_receive(impl, buffers, flags,
detail::async_result_init<
ReadHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
service_impl_.async_receive(impl, buffers, flags, init.handler);
return init.result.get();
}
/// Receive a datagram with the endpoint of the sender.
@ -350,13 +394,21 @@ public:
/// Start an asynchronous receive that will get the endpoint of the sender.
template <typename MutableBufferSequence, typename ReadHandler>
void async_receive_from(implementation_type& impl,
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
void (boost::system::error_code, std::size_t))
async_receive_from(implementation_type& impl,
const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
service_impl_.async_receive_from(impl, buffers, sender_endpoint, flags,
detail::async_result_init<
ReadHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
service_impl_.async_receive_from(impl, buffers,
sender_endpoint, flags, init.handler);
return init.result.get();
}
private:

View file

@ -2,7 +2,7 @@
// deadline_timer.hpp
// ~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -16,6 +16,10 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
|| defined(GENERATING_DOCUMENTATION)
#include <boost/asio/detail/socket_types.hpp> // Must come before posix_time.
#include <boost/asio/basic_deadline_timer.hpp>
@ -32,4 +36,7 @@ typedef basic_deadline_timer<boost::posix_time::ptime> deadline_timer;
} // namespace asio
} // namespace boost
#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_DEADLINE_TIMER_HPP

View file

@ -2,7 +2,7 @@
// deadline_timer_service.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -16,7 +16,12 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
|| defined(GENERATING_DOCUMENTATION)
#include <cstddef>
#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/deadline_timer_service.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/time_traits.hpp>
@ -132,10 +137,18 @@ public:
// Start an asynchronous wait on the timer.
template <typename WaitHandler>
void async_wait(implementation_type& impl,
BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
void (boost::system::error_code))
async_wait(implementation_type& impl,
BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
{
service_impl_.async_wait(impl, BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
detail::async_result_init<
WaitHandler, void (boost::system::error_code)> init(
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
service_impl_.async_wait(impl, init.handler);
return init.result.get();
}
private:
@ -154,4 +167,7 @@ private:
#include <boost/asio/detail/pop_options.hpp>
#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_DEADLINE_TIMER_SERVICE_HPP

View file

@ -0,0 +1,40 @@
//
// detail/addressof.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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_ASIO_DETAIL_ADDRESSOF_HPP
#define BOOST_ASIO_DETAIL_ADDRESSOF_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
# include <memory>
#else // defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
# include <boost/utility/addressof.hpp>
#endif // defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
namespace boost {
namespace asio {
namespace detail {
#if defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
using std::addressof;
#else // defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
using boost::addressof;
#endif // defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
} // namespace detail
} // namespace asio
} // namespace boost
#endif // BOOST_ASIO_DETAIL_ADDRESSOF_HPP

View file

@ -2,7 +2,7 @@
// detail/array.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// detail/array_fwd.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -0,0 +1,32 @@
//
// detail/assert.hpp
// ~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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_ASIO_DETAIL_ASSERT_HPP
#define BOOST_ASIO_DETAIL_ASSERT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_BOOST_ASSERT)
# include <boost/assert.hpp>
#else // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
# include <cassert>
#endif // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
#if defined(BOOST_ASIO_HAS_BOOST_ASSERT)
# define BOOST_ASIO_ASSERT(expr) BOOST_ASSERT(expr)
#else // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
# define BOOST_ASIO_ASSERT(expr) assert(expr)
#endif // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
#endif // BOOST_ASIO_DETAIL_ASSERT_HPP

View file

@ -2,7 +2,7 @@
// detail/atomic_count.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,7 +17,7 @@
#include <boost/asio/detail/config.hpp>
#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
#if !defined(BOOST_ASIO_HAS_THREADS)
// Nothing to include.
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)
# include <atomic>
@ -29,7 +29,7 @@ namespace boost {
namespace asio {
namespace detail {
#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
#if !defined(BOOST_ASIO_HAS_THREADS)
typedef long atomic_count;
inline void increment(atomic_count& a, long b) { a += b; }
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)

View file

@ -2,7 +2,7 @@
// detail/base_from_completion_cond.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)

View file

@ -2,7 +2,7 @@
// detail/bind_handler.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,6 +17,7 @@
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/handler_cont_helpers.hpp>
#include <boost/asio/detail/handler_invoke_helpers.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -72,6 +73,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
pointer, size, this_handler->handler_);
}
template <typename Handler, typename Arg1>
inline bool asio_handler_is_continuation(
binder1<Handler, Arg1>* this_handler)
{
return boost_asio_handler_cont_helpers::is_continuation(
this_handler->handler_);
}
template <typename Function, typename Handler, typename Arg1>
inline void asio_handler_invoke(Function& function,
binder1<Handler, Arg1>* this_handler)
@ -146,6 +155,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
pointer, size, this_handler->handler_);
}
template <typename Handler, typename Arg1, typename Arg2>
inline bool asio_handler_is_continuation(
binder2<Handler, Arg1, Arg2>* this_handler)
{
return boost_asio_handler_cont_helpers::is_continuation(
this_handler->handler_);
}
template <typename Function, typename Handler, typename Arg1, typename Arg2>
inline void asio_handler_invoke(Function& function,
binder2<Handler, Arg1, Arg2>* this_handler)
@ -226,6 +243,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
pointer, size, this_handler->handler_);
}
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
inline bool asio_handler_is_continuation(
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
{
return boost_asio_handler_cont_helpers::is_continuation(
this_handler->handler_);
}
template <typename Function, typename Handler, typename Arg1, typename Arg2,
typename Arg3>
inline void asio_handler_invoke(Function& function,
@ -315,6 +340,15 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
pointer, size, this_handler->handler_);
}
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
typename Arg4>
inline bool asio_handler_is_continuation(
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
{
return boost_asio_handler_cont_helpers::is_continuation(
this_handler->handler_);
}
template <typename Function, typename Handler, typename Arg1, typename Arg2,
typename Arg3, typename Arg4>
inline void asio_handler_invoke(Function& function,
@ -411,6 +445,15 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
pointer, size, this_handler->handler_);
}
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
typename Arg4, typename Arg5>
inline bool asio_handler_is_continuation(
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
{
return boost_asio_handler_cont_helpers::is_continuation(
this_handler->handler_);
}
template <typename Function, typename Handler, typename Arg1, typename Arg2,
typename Arg3, typename Arg4, typename Arg5>
inline void asio_handler_invoke(Function& function,

View file

@ -2,7 +2,7 @@
// detail/buffer_resize_guard.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -16,7 +16,7 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/limits.hpp>
#include <boost/asio/detail/limits.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -39,8 +39,7 @@ public:
// Destructor rolls back the buffer resize unless commit was called.
~buffer_resize_guard()
{
if (old_size_
!= std::numeric_limits<size_t>::max BOOST_PREVENT_MACRO_SUBSTITUTION())
if (old_size_ != (std::numeric_limits<size_t>::max)())
{
buffer_.resize(old_size_);
}
@ -49,8 +48,7 @@ public:
// Commit the resize transaction.
void commit()
{
old_size_
= std::numeric_limits<size_t>::max BOOST_PREVENT_MACRO_SUBSTITUTION();
old_size_ = (std::numeric_limits<size_t>::max)();
}
private:

View file

@ -2,7 +2,7 @@
// detail/buffer_sequence_adapter.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -29,7 +29,7 @@ namespace detail {
class buffer_sequence_adapter_base
{
protected:
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
typedef WSABUF native_buffer_type;
static void init_native_buffer(WSABUF& buf,
@ -45,7 +45,7 @@ protected:
buf.buf = const_cast<char*>(boost::asio::buffer_cast<const char*>(buffer));
buf.len = static_cast<ULONG>(boost::asio::buffer_size(buffer));
}
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#else // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
typedef iovec native_buffer_type;
static void init_iov_base(void*& base, void* addr)
@ -73,7 +73,7 @@ protected:
boost::asio::buffer_cast<const void*>(buffer)));
iov.iov_len = boost::asio::buffer_size(buffer);
}
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
};
// Helper class to translate buffers into the native buffer representation.

View file

@ -2,7 +2,7 @@
// detail/buffered_stream_storage.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,7 +17,7 @@
#include <boost/asio/detail/config.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/assert.hpp>
#include <boost/asio/detail/assert.hpp>
#include <cstddef>
#include <cstring>
#include <vector>
@ -79,7 +79,7 @@ public:
// Resize the buffer to the specified length.
void resize(size_type length)
{
BOOST_ASSERT(length <= capacity());
BOOST_ASIO_ASSERT(length <= capacity());
if (begin_offset_ + length <= capacity())
{
end_offset_ = begin_offset_ + length;
@ -102,7 +102,7 @@ public:
// Consume multiple bytes from the beginning of the buffer.
void consume(size_type count)
{
BOOST_ASSERT(begin_offset_ + count <= end_offset_);
BOOST_ASIO_ASSERT(begin_offset_ + count <= end_offset_);
begin_offset_ += count;
if (empty())
clear();

View file

@ -2,7 +2,7 @@
// detail/call_stack.hpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -102,6 +102,13 @@ public:
return 0;
}
// Obtain the value at the top of the stack.
static Value* top()
{
context* elem = top_;
return elem ? elem->value_ : 0;
}
private:
// The top of the stack of calls for the current thread.
static tss_ptr<context> top_;

View file

@ -2,7 +2,7 @@
// detail/chrono_time_traits.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -15,7 +15,7 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/cstdint.hpp>
#include <boost/asio/detail/cstdint.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -48,13 +48,63 @@ struct chrono_time_traits
// Add a duration to a time.
static time_type add(const time_type& t, const duration_type& d)
{
const time_type epoch;
if (t >= epoch)
{
if ((time_type::max)() - t < d)
return (time_type::max)();
}
else // t < epoch
{
if (-(t - (time_type::min)()) > d)
return (time_type::min)();
}
return t + d;
}
// Subtract one time from another.
static duration_type subtract(const time_type& t1, const time_type& t2)
{
return t1 - t2;
const time_type epoch;
if (t1 >= epoch)
{
if (t2 >= epoch)
{
return t1 - t2;
}
else if (t2 == (time_type::min)())
{
return (duration_type::max)();
}
else if ((time_type::max)() - t1 < epoch - t2)
{
return (duration_type::max)();
}
else
{
return t1 - t2;
}
}
else // t1 < epoch
{
if (t2 < epoch)
{
return t1 - t2;
}
else if (t1 == (time_type::min)())
{
return (duration_type::min)();
}
else if ((time_type::max)() - t2 < epoch - t1)
{
return (duration_type::min)();
}
else
{
return -(t2 - t1);
}
}
}
// Test whether one time is less than another.
@ -73,32 +123,32 @@ struct chrono_time_traits
{
}
boost::int64_t ticks() const
int64_t ticks() const
{
return d_.count();
}
boost::int64_t total_seconds() const
int64_t total_seconds() const
{
return duration_cast<1, 1>();
}
boost::int64_t total_milliseconds() const
int64_t total_milliseconds() const
{
return duration_cast<1, 1000>();
}
boost::int64_t total_microseconds() const
int64_t total_microseconds() const
{
return duration_cast<1, 1000000>();
}
private:
template <boost::int64_t Num, boost::int64_t Den>
boost::int64_t duration_cast() const
template <int64_t Num, int64_t Den>
int64_t duration_cast() const
{
const boost::int64_t num = period_type::num * Den;
const boost::int64_t den = period_type::den * Num;
const int64_t num = period_type::num * Den;
const int64_t den = period_type::den * Num;
if (num == 1 && den == 1)
return ticks();

View file

@ -2,7 +2,7 @@
// detail/completion_handler.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -15,6 +15,7 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/addressof.hpp>
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/fenced_block.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
@ -45,7 +46,7 @@ public:
{
// Take ownership of the handler object.
completion_handler* h(static_cast<completion_handler*>(base));
ptr p = { boost::addressof(h->handler_), h, h };
ptr p = { boost::asio::detail::addressof(h->handler_), h, h };
BOOST_ASIO_HANDLER_COMPLETION((h));
@ -56,7 +57,7 @@ public:
// to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here.
Handler handler(BOOST_ASIO_MOVE_CAST(Handler)(h->handler_));
p.h = boost::addressof(handler);
p.h = boost::asio::detail::addressof(handler);
p.reset();
// Make the upcall if required.

View file

@ -2,7 +2,7 @@
// detail/config.hpp
// ~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -11,8 +11,22 @@
#ifndef BOOST_ASIO_DETAIL_CONFIG_HPP
#define BOOST_ASIO_DETAIL_CONFIG_HPP
#include <boost/config.hpp>
#include <boost/version.hpp>
#if defined(BOOST_ASIO_STANDALONE)
# define BOOST_ASIO_DISABLE_BOOST_ARRAY 1
# define BOOST_ASIO_DISABLE_BOOST_ASSERT 1
# define BOOST_ASIO_DISABLE_BOOST_BIND 1
# define BOOST_ASIO_DISABLE_BOOST_CHRONO 1
# define BOOST_ASIO_DISABLE_BOOST_DATE_TIME 1
# define BOOST_ASIO_DISABLE_BOOST_LIMITS 1
# define BOOST_ASIO_DISABLE_BOOST_REGEX 1
# define BOOST_ASIO_DISABLE_BOOST_STATIC_CONSTANT 1
# define BOOST_ASIO_DISABLE_BOOST_THROW_EXCEPTION 1
# define BOOST_ASIO_DISABLE_BOOST_WORKAROUND 1
#else // defined(BOOST_ASIO_STANDALONE)
# include <boost/config.hpp>
# include <boost/version.hpp>
# define BOOST_ASIO_HAS_BOOST_CONFIG 1
#endif // defined(BOOST_ASIO_STANDALONE)
// Default to a header-only implementation. The user must specifically request
// separate compilation by defining either BOOST_ASIO_SEPARATE_COMPILATION or
@ -20,7 +34,7 @@
#if !defined(BOOST_ASIO_HEADER_ONLY)
# if !defined(BOOST_ASIO_SEPARATE_COMPILATION)
# if !defined(BOOST_ASIO_DYN_LINK)
# define BOOST_ASIO_HEADER_ONLY
# define BOOST_ASIO_HEADER_ONLY 1
# endif // !defined(BOOST_ASIO_DYN_LINK)
# endif // !defined(BOOST_ASIO_SEPARATE_COMPILATION)
#endif // !defined(BOOST_ASIO_HEADER_ONLY)
@ -28,7 +42,7 @@
#if defined(BOOST_ASIO_HEADER_ONLY)
# define BOOST_ASIO_DECL inline
#else // defined(BOOST_ASIO_HEADER_ONLY)
# if defined(BOOST_HAS_DECLSPEC)
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
// We need to import/export our code only if the user has specifically asked
// for it by defining BOOST_ASIO_DYN_LINK.
# if defined(BOOST_ASIO_DYN_LINK)
@ -39,7 +53,7 @@
# define BOOST_ASIO_DECL __declspec(dllimport)
# endif // defined(BOOST_ASIO_SOURCE)
# endif // defined(BOOST_ASIO_DYN_LINK)
# endif // defined(BOOST_HAS_DECLSPEC)
# endif // defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
#endif // defined(BOOST_ASIO_HEADER_ONLY)
// If BOOST_ASIO_DECL isn't defined yet define it now.
@ -47,16 +61,44 @@
# define BOOST_ASIO_DECL
#endif // !defined(BOOST_ASIO_DECL)
// Microsoft Visual C++ detection.
#if !defined(BOOST_ASIO_MSVC)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_MSVC)
# define BOOST_ASIO_MSVC BOOST_MSVC
# elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__)
# define BOOST_ASIO_MSVC _MSC_VER
# endif // defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_MSVC)
#endif // defined(BOOST_ASIO_MSVC)
// Clang / libc++ detection.
#if defined(__clang__)
# if (__cplusplus >= 201103)
# if __has_include(<__config>)
# include <__config>
# if defined(_LIBCPP_VERSION)
# define BOOST_ASIO_HAS_CLANG_LIBCXX 1
# endif // defined(_LIBCPP_VERSION)
# endif // __has_include(<__config>)
# endif // (__cplusplus >= 201103)
#endif // defined(__clang__)
// Support move construction and assignment on compilers known to allow it.
#if !defined(BOOST_ASIO_DISABLE_MOVE)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_MOVE
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
#endif // !defined(BOOST_ASIO_DISABLE_MOVE)
#if !defined(BOOST_ASIO_HAS_MOVE)
# if !defined(BOOST_ASIO_DISABLE_MOVE)
# if defined(__clang__)
# if __has_feature(__cxx_rvalue_references__)
# define BOOST_ASIO_HAS_MOVE 1
# endif // __has_feature(__cxx_rvalue_references__)
# endif // defined(__clang__)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_MOVE 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_MOVE)
#endif // !defined(BOOST_ASIO_HAS_MOVE)
// If BOOST_ASIO_MOVE_CAST isn't defined, and move support is available, define
// BOOST_ASIO_MOVE_ARG and BOOST_ASIO_MOVE_CAST to take advantage of rvalue
@ -64,6 +106,7 @@
#if defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
# define BOOST_ASIO_MOVE_ARG(type) type&&
# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
# define BOOST_ASIO_MOVE_CAST2(type1, type2) static_cast<type1, type2&&>
#endif // defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
// If BOOST_ASIO_MOVE_CAST still isn't defined, default to a C++03-compatible
@ -78,7 +121,7 @@
# else // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
# define BOOST_ASIO_MOVE_ARG(type) type
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
# elif defined(BOOST_MSVC)
# elif defined(BOOST_ASIO_MSVC)
# if (_MSC_VER >= 1400)
# define BOOST_ASIO_MOVE_ARG(type) const type&
# else // (_MSC_VER >= 1400)
@ -88,33 +131,50 @@
# define BOOST_ASIO_MOVE_ARG(type) type
# endif
# define BOOST_ASIO_MOVE_CAST(type) static_cast<const type&>
#endif // !defined_BOOST_ASIO_MOVE_CAST
# define BOOST_ASIO_MOVE_CAST2(type1, type2) static_cast<const type1, type2&>
#endif // !defined(BOOST_ASIO_MOVE_CAST)
// Support variadic templates on compilers known to allow it.
#if !defined(BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_VARIADIC_TEMPLATES
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
#endif // !defined(BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES)
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
# if !defined(BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES)
# if defined(__clang__)
# if __has_feature(__cxx_variadic_templates__)
# define BOOST_ASIO_HAS_VARIADIC_TEMPLATES 1
# endif // __has_feature(__cxx_variadic_templates__)
# endif // defined(__clang__)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_VARIADIC_TEMPLATES 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES)
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
// Standard library support for system errors.
#if !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_SYSTEM_ERROR
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
#endif // !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
# if !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_SYSTEM_ERROR 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_SYSTEM_ERROR 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
// Compliant C++11 compilers put noexcept specifiers on error_category members.
#if !defined(BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT)
# if defined(__GNUC__)
# if (BOOST_VERSION >= 105300)
# define BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT BOOST_NOEXCEPT
# elif defined(__clang__)
# if __has_feature(__cxx_noexcept__)
# define BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true)
# endif // __has_feature(__cxx_noexcept__)
# elif defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true)
@ -127,73 +187,175 @@
#endif // !defined(BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT)
// Standard library support for arrays.
#if !defined(BOOST_ASIO_DISABLE_STD_ARRAY)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_ARRAY
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# if defined(BOOST_MSVC)
# if (_MSC_VER >= 1600)
# define BOOST_ASIO_HAS_STD_ARRAY
# endif // (_MSC_VER >= 1600)
# endif // defined(BOOST_MSVC)
#endif // !defined(BOOST_ASIO_DISABLE_STD_ARRAY)
#if !defined(BOOST_ASIO_HAS_STD_ARRAY)
# if !defined(BOOST_ASIO_DISABLE_STD_ARRAY)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_ARRAY 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_ARRAY 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# if defined(BOOST_ASIO_MSVC)
# if (_MSC_VER >= 1600)
# define BOOST_ASIO_HAS_STD_ARRAY 1
# endif // (_MSC_VER >= 1600)
# endif // defined(BOOST_ASIO_MSVC)
# endif // !defined(BOOST_ASIO_DISABLE_STD_ARRAY)
#endif // !defined(BOOST_ASIO_HAS_STD_ARRAY)
// Standard library support for shared_ptr and weak_ptr.
#if !defined(BOOST_ASIO_DISABLE_STD_SHARED_PTR)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_SHARED_PTR
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# if defined(BOOST_MSVC)
# if (_MSC_VER >= 1600)
# define BOOST_ASIO_HAS_STD_SHARED_PTR
# endif // (_MSC_VER >= 1600)
# endif // defined(BOOST_MSVC)
#endif // !defined(BOOST_ASIO_DISABLE_STD_SHARED_PTR)
#if !defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
# if !defined(BOOST_ASIO_DISABLE_STD_SHARED_PTR)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_SHARED_PTR 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_SHARED_PTR 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# if defined(BOOST_ASIO_MSVC)
# if (_MSC_VER >= 1600)
# define BOOST_ASIO_HAS_STD_SHARED_PTR 1
# endif // (_MSC_VER >= 1600)
# endif // defined(BOOST_ASIO_MSVC)
# endif // !defined(BOOST_ASIO_DISABLE_STD_SHARED_PTR)
#endif // !defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
// Standard library support for atomic operations.
#if !defined(BOOST_ASIO_DISABLE_STD_ATOMIC)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_ATOMIC
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
#endif // !defined(BOOST_ASIO_DISABLE_STD_ATOMIC)
#if !defined(BOOST_ASIO_HAS_STD_ATOMIC)
# if !defined(BOOST_ASIO_DISABLE_STD_ATOMIC)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_ATOMIC 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_ATOMIC 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_STD_ATOMIC)
#endif // !defined(BOOST_ASIO_HAS_STD_ATOMIC)
// Standard library support for chrono. Some standard libraries (such as the
// libstdc++ shipped with gcc 4.6) provide monotonic_clock as per early C++0x
// drafts, rather than the eventually standardised name of steady_clock.
#if !defined(BOOST_ASIO_DISABLE_STD_CHRONO)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_CHRONO
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
# define BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
#endif // !defined(BOOST_ASIO_DISABLE_STD_CHRONO)
#if !defined(BOOST_ASIO_HAS_STD_CHRONO)
# if !defined(BOOST_ASIO_DISABLE_STD_CHRONO)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_CHRONO 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_CHRONO 1
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
# define BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK 1
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ == 6))
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_STD_CHRONO)
#endif // !defined(BOOST_ASIO_HAS_STD_CHRONO)
// Boost support for chrono.
#if !defined(BOOST_ASIO_DISABLE_BOOST_CHRONO)
# if (BOOST_VERSION >= 104700)
# define BOOST_ASIO_HAS_BOOST_CHRONO
# endif // (BOOST_VERSION >= 104700)
#endif // !defined(BOOST_ASIO_DISABLE_BOOST_CHRONO)
#if !defined(BOOST_ASIO_HAS_BOOST_CHRONO)
# if !defined(BOOST_ASIO_DISABLE_BOOST_CHRONO)
# if (BOOST_VERSION >= 104700)
# define BOOST_ASIO_HAS_BOOST_CHRONO 1
# endif // (BOOST_VERSION >= 104700)
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_CHRONO)
#endif // !defined(BOOST_ASIO_HAS_BOOST_CHRONO)
// Boost support for the DateTime library.
#if !defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
# if !defined(BOOST_ASIO_DISABLE_BOOST_DATE_TIME)
# define BOOST_ASIO_HAS_BOOST_DATE_TIME 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_DATE_TIME)
#endif // !defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
// Standard library support for addressof.
#if !defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
# if !defined(BOOST_ASIO_DISABLE_STD_ADDRESSOF)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_ADDRESSOF 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_ADDRESSOF 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_STD_ADDRESSOF)
#endif // !defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
// Standard library support for the function class.
#if !defined(BOOST_ASIO_HAS_STD_FUNCTION)
# if !defined(BOOST_ASIO_DISABLE_STD_FUNCTION)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_FUNCTION 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_FUNCTION 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_STD_FUNCTION)
#endif // !defined(BOOST_ASIO_HAS_STD_FUNCTION)
// Standard library support for type traits.
#if !defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
# if !defined(BOOST_ASIO_DISABLE_STD_TYPE_TRAITS)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_STD_TYPE_TRAITS 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_STD_TYPE_TRAITS 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_STD_TYPE_TRAITS)
#endif // !defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
// Standard library support for the cstdint header.
#if !defined(BOOST_ASIO_HAS_CSTDINT)
# if !defined(BOOST_ASIO_DISABLE_CSTDINT)
# if defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# define BOOST_ASIO_HAS_CSTDINT 1
# endif // defined(BOOST_ASIO_HAS_CLANG_LIBCXX)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_CSTDINT 1
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# endif // !defined(BOOST_ASIO_DISABLE_CSTDINT)
#endif // !defined(BOOST_ASIO_HAS_CSTDINT)
// Windows target.
#if !defined(BOOST_ASIO_WINDOWS)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_WINDOWS)
# define BOOST_ASIO_WINDOWS 1
# elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define BOOST_ASIO_WINDOWS 1
# endif // defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_WINDOWS)
#endif // !defined(BOOST_ASIO_WINDOWS)
// Windows: target OS version.
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
# if defined(_MSC_VER) || defined(__BORLANDC__)
# pragma message( \
@ -231,55 +393,63 @@
# error You must add -D__USE_W32_SOCKETS to your compiler options.
# endif // !defined(__USE_W32_SOCKETS)
# endif // defined(__CYGWIN__)
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
// Windows: minimise header inclusion.
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
# if !defined(WIN32_LEAN_AND_MEAN)
# define WIN32_LEAN_AND_MEAN
# endif // !defined(WIN32_LEAN_AND_MEAN)
# endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
// Windows: suppress definition of "min" and "max" macros.
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# if !defined(BOOST_ASIO_NO_NOMINMAX)
# if !defined(NOMINMAX)
# define NOMINMAX 1
# endif // !defined(NOMINMAX)
# endif // !defined(BOOST_ASIO_NO_NOMINMAX)
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
// Windows: IO Completion Ports.
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
# if !defined(UNDER_CE)
# if !defined(BOOST_ASIO_DISABLE_IOCP)
# define BOOST_ASIO_HAS_IOCP 1
# endif // !defined(BOOST_ASIO_DISABLE_IOCP)
# endif // !defined(UNDER_CE)
# endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#if !defined(BOOST_ASIO_HAS_IOCP)
# if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
# if !defined(UNDER_CE)
# if !defined(BOOST_ASIO_DISABLE_IOCP)
# define BOOST_ASIO_HAS_IOCP 1
# endif // !defined(BOOST_ASIO_DISABLE_IOCP)
# endif // !defined(UNDER_CE)
# endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400)
# endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_HAS_IOCP)
// Linux: epoll, eventfd and timerfd.
#if defined(__linux__)
# include <linux/version.h>
# if !defined(BOOST_ASIO_DISABLE_EPOLL)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
# define BOOST_ASIO_HAS_EPOLL 1
# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
# endif // !defined(BOOST_ASIO_DISABLE_EVENTFD)
# if !defined(BOOST_ASIO_DISABLE_EVENTFD)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# define BOOST_ASIO_HAS_EVENTFD 1
# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# endif // !defined(BOOST_ASIO_DISABLE_EVENTFD)
# if defined(BOOST_ASIO_HAS_EPOLL)
# if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
# define BOOST_ASIO_HAS_TIMERFD 1
# endif // (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
# endif // defined(BOOST_ASIO_HAS_EPOLL)
# if !defined(BOOST_ASIO_HAS_EPOLL)
# if !defined(BOOST_ASIO_DISABLE_EPOLL)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
# define BOOST_ASIO_HAS_EPOLL 1
# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
# endif // !defined(BOOST_ASIO_DISABLE_EPOLL)
# endif // !defined(BOOST_ASIO_HAS_EPOLL)
# if !defined(BOOST_ASIO_HAS_EVENTFD)
# if !defined(BOOST_ASIO_DISABLE_EVENTFD)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# define BOOST_ASIO_HAS_EVENTFD 1
# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# endif // !defined(BOOST_ASIO_DISABLE_EVENTFD)
# endif // !defined(BOOST_ASIO_HAS_EVENTFD)
# if !defined(BOOST_ASIO_HAS_TIMERFD)
# if defined(BOOST_ASIO_HAS_EPOLL)
# if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
# define BOOST_ASIO_HAS_TIMERFD 1
# endif // (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
# endif // defined(BOOST_ASIO_HAS_EPOLL)
# endif // !defined(BOOST_ASIO_HAS_TIMERFD)
#endif // defined(__linux__)
// Mac OS X, FreeBSD, NetBSD, OpenBSD: kqueue.
@ -287,9 +457,11 @@
|| defined(__FreeBSD__) \
|| defined(__NetBSD__) \
|| defined(__OpenBSD__)
# if !defined(BOOST_ASIO_DISABLE_KQUEUE)
# define BOOST_ASIO_HAS_KQUEUE 1
# endif // !defined(BOOST_ASIO_DISABLE_KQUEUE)
# if !defined(BOOST_ASIO_HAS_KQUEUE)
# if !defined(BOOST_ASIO_DISABLE_KQUEUE)
# define BOOST_ASIO_HAS_KQUEUE 1
# endif // !defined(BOOST_ASIO_DISABLE_KQUEUE)
# endif // !defined(BOOST_ASIO_HAS_KQUEUE)
#endif // (defined(__MACH__) && defined(__APPLE__))
// || defined(__FreeBSD__)
// || defined(__NetBSD__)
@ -297,79 +469,257 @@
// Solaris: /dev/poll.
#if defined(__sun)
# if !defined(BOOST_ASIO_DISABLE_DEV_POLL)
# define BOOST_ASIO_HAS_DEV_POLL 1
# endif // !defined(BOOST_ASIO_DISABLE_DEV_POLL)
# if !defined(BOOST_ASIO_HAS_DEV_POLL)
# if !defined(BOOST_ASIO_DISABLE_DEV_POLL)
# define BOOST_ASIO_HAS_DEV_POLL 1
# endif // !defined(BOOST_ASIO_DISABLE_DEV_POLL)
# endif // !defined(BOOST_ASIO_HAS_DEV_POLL)
#endif // defined(__sun)
// Serial ports.
#if defined(BOOST_ASIO_HAS_IOCP) \
|| !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
# if !defined(__SYMBIAN32__)
# if !defined(BOOST_ASIO_DISABLE_SERIAL_PORT)
# define BOOST_ASIO_HAS_SERIAL_PORT 1
# endif // !defined(BOOST_ASIO_DISABLE_SERIAL_PORT)
# endif // !defined(__SYMBIAN32__)
#endif // defined(BOOST_ASIO_HAS_IOCP)
// || !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
#if !defined(BOOST_ASIO_HAS_SERIAL_PORT)
# if defined(BOOST_ASIO_HAS_IOCP) \
|| !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# if !defined(__SYMBIAN32__)
# if !defined(BOOST_ASIO_DISABLE_SERIAL_PORT)
# define BOOST_ASIO_HAS_SERIAL_PORT 1
# endif // !defined(BOOST_ASIO_DISABLE_SERIAL_PORT)
# endif // !defined(__SYMBIAN32__)
# endif // defined(BOOST_ASIO_HAS_IOCP)
// || !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_HAS_SERIAL_PORT)
// Windows: stream handles.
#if !defined(BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
# if defined(BOOST_ASIO_HAS_IOCP)
# define BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE 1
# endif // defined(BOOST_ASIO_HAS_IOCP)
#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
#if !defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
# if !defined(BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
# if defined(BOOST_ASIO_HAS_IOCP)
# define BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE 1
# endif // defined(BOOST_ASIO_HAS_IOCP)
# endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
#endif // !defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE)
// Windows: random access handles.
#if !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
# if defined(BOOST_ASIO_HAS_IOCP)
# define BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE 1
# endif // defined(BOOST_ASIO_HAS_IOCP)
#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
#if !defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
# if !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
# if defined(BOOST_ASIO_HAS_IOCP)
# define BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE 1
# endif // defined(BOOST_ASIO_HAS_IOCP)
# endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
#endif // !defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
// Windows: object handles.
#if !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
# if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
# if !defined(UNDER_CE)
# define BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE 1
# endif // !defined(UNDER_CE)
# endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
#if !defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
# if !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
# if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# if !defined(UNDER_CE)
# define BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE 1
# endif // !defined(UNDER_CE)
# endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
#endif // !defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)
// Windows: OVERLAPPED wrapper.
#if !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
# if defined(BOOST_ASIO_HAS_IOCP)
# define BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR 1
# endif // defined(BOOST_ASIO_HAS_IOCP)
#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
#if !defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
# if !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
# if defined(BOOST_ASIO_HAS_IOCP)
# define BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR 1
# endif // defined(BOOST_ASIO_HAS_IOCP)
# endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
#endif // !defined(BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
// POSIX: stream-oriented file descriptors.
#if !defined(BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
# if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
# define BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR 1
# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
#if !defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
# if !defined(BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
# if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# define BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR 1
# endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# endif // !defined(BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR)
#endif // !defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
// UNIX domain sockets.
#if !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
# if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
# define BOOST_ASIO_HAS_LOCAL_SOCKETS 1
# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
#if !defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
# if !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
# if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# define BOOST_ASIO_HAS_LOCAL_SOCKETS 1
# endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# endif // !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
#endif // !defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
// Can use sigaction() instead of signal().
#if !defined(BOOST_ASIO_DISABLE_SIGACTION)
# if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
# define BOOST_ASIO_HAS_SIGACTION 1
# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
#endif // !defined(BOOST_ASIO_DISABLE_SIGACTION)
#if !defined(BOOST_ASIO_HAS_SIGACTION)
# if !defined(BOOST_ASIO_DISABLE_SIGACTION)
# if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# define BOOST_ASIO_HAS_SIGACTION 1
# endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
# endif // !defined(BOOST_ASIO_DISABLE_SIGACTION)
#endif // !defined(BOOST_ASIO_HAS_SIGACTION)
// Can use signal().
#if !defined(BOOST_ASIO_DISABLE_SIGNAL)
# if !defined(UNDER_CE)
# define BOOST_ASIO_HAS_SIGNAL 1
# endif // !defined(UNDER_CE)
#endif // !defined(BOOST_ASIO_DISABLE_SIGNAL)
#if !defined(BOOST_ASIO_HAS_SIGNAL)
# if !defined(BOOST_ASIO_DISABLE_SIGNAL)
# if !defined(UNDER_CE)
# define BOOST_ASIO_HAS_SIGNAL 1
# endif // !defined(UNDER_CE)
# endif // !defined(BOOST_ASIO_DISABLE_SIGNAL)
#endif // !defined(BOOST_ASIO_HAS_SIGNAL)
// Whether standard iostreams are disabled.
#if !defined(BOOST_ASIO_NO_IOSTREAM)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_NO_IOSTREAM)
# define BOOST_ASIO_NO_IOSTREAM 1
# endif // !defined(BOOST_NO_IOSTREAM)
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
// Whether exception handling is disabled.
#if !defined(BOOST_ASIO_NO_EXCEPTIONS)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_NO_EXCEPTIONS)
# define BOOST_ASIO_NO_EXCEPTIONS 1
# endif // !defined(BOOST_NO_EXCEPTIONS)
#endif // !defined(BOOST_ASIO_NO_EXCEPTIONS)
// Whether the typeid operator is supported.
#if !defined(BOOST_ASIO_NO_TYPEID)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_NO_TYPEID)
# define BOOST_ASIO_NO_TYPEID 1
# endif // !defined(BOOST_NO_TYPEID)
#endif // !defined(BOOST_ASIO_NO_TYPEID)
// On POSIX (and POSIX-like) platforms we need to include unistd.h in order to
// get access to the various platform feature macros, e.g. to be able to test
// for threads support.
#if !defined(BOOST_ASIO_HAS_UNISTD_H)
# if !defined(BOOST_ASIO_HAS_BOOST_CONFIG)
# if defined(unix) \
|| defined(__unix) \
|| defined(_XOPEN_SOURCE) \
|| defined(_POSIX_SOURCE) \
|| (defined(__MACH__) && defined(__APPLE__)) \
|| defined(__FreeBSD__) \
|| defined(__NetBSD__) \
|| defined(__OpenBSD__) \
|| defined(__linux__)
# define BOOST_ASIO_HAS_UNISTD_H 1
# endif
# endif // !defined(BOOST_ASIO_HAS_BOOST_CONFIG)
#endif // !defined(BOOST_ASIO_HAS_UNISTD_H)
#if defined(BOOST_ASIO_HAS_UNISTD_H)
# include <unistd.h>
#endif // defined(BOOST_ASIO_HAS_UNISTD_H)
// Threads.
#if !defined(BOOST_ASIO_HAS_THREADS)
# if !defined(BOOST_ASIO_DISABLE_THREADS)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_THREADS)
# define BOOST_ASIO_HAS_THREADS 1
# elif defined(_MSC_VER) && defined(_MT)
# define BOOST_ASIO_HAS_THREADS 1
# elif defined(__BORLANDC__) && defined(__MT__)
# define BOOST_ASIO_HAS_THREADS 1
# elif defined(_POSIX_THREADS)
# define BOOST_ASIO_HAS_THREADS 1
# endif // defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_THREADS)
# endif // !defined(BOOST_ASIO_DISABLE_THREADS)
#endif // !defined(BOOST_ASIO_HAS_THREADS)
// POSIX threads.
#if !defined(BOOST_ASIO_HAS_PTHREADS)
# if defined(BOOST_ASIO_HAS_THREADS)
# if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_PTHREADS)
# define BOOST_ASIO_HAS_PTHREADS 1
# elif defined(_POSIX_THREADS)
# define BOOST_ASIO_HAS_PTHREADS 1
# endif // defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_PTHREADS)
# endif // defined(BOOST_ASIO_HAS_THREADS)
#endif // !defined(BOOST_ASIO_HAS_PTHREADS)
// Helper to prevent macro expansion.
#define BOOST_ASIO_PREVENT_MACRO_SUBSTITUTION
// Helper to define in-class constants.
#if !defined(BOOST_ASIO_STATIC_CONSTANT)
# if !defined(BOOST_ASIO_DISABLE_BOOST_STATIC_CONSTANT)
# define BOOST_ASIO_STATIC_CONSTANT(type, assignment) \
BOOST_STATIC_CONSTANT(type, assignment)
# else // !defined(BOOST_ASIO_DISABLE_BOOST_STATIC_CONSTANT)
# define BOOST_ASIO_STATIC_CONSTANT(type, assignment) \
static const type assignment
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_STATIC_CONSTANT)
#endif // !defined(BOOST_ASIO_STATIC_CONSTANT)
// Boost array library.
#if !defined(BOOST_ASIO_HAS_BOOST_ARRAY)
# if !defined(BOOST_ASIO_DISABLE_BOOST_ARRAY)
# define BOOST_ASIO_HAS_BOOST_ARRAY 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_ARRAY)
#endif // !defined(BOOST_ASIO_HAS_BOOST_ARRAY)
// Boost assert macro.
#if !defined(BOOST_ASIO_HAS_BOOST_ASSERT)
# if !defined(BOOST_ASIO_DISABLE_BOOST_ASSERT)
# define BOOST_ASIO_HAS_BOOST_ASSERT 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_ASSERT)
#endif // !defined(BOOST_ASIO_HAS_BOOST_ASSERT)
// Boost limits header.
#if !defined(BOOST_ASIO_HAS_BOOST_LIMITS)
# if !defined(BOOST_ASIO_DISABLE_BOOST_LIMITS)
# define BOOST_ASIO_HAS_BOOST_LIMITS 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_LIMITS)
#endif // !defined(BOOST_ASIO_HAS_BOOST_LIMITS)
// Boost throw_exception function.
#if !defined(BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION)
# if !defined(BOOST_ASIO_DISABLE_BOOST_THROW_EXCEPTION)
# define BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_THROW_EXCEPTION)
#endif // !defined(BOOST_ASIO_HAS_BOOST_THROW_EXCEPTION)
// Boost regex library.
#if !defined(BOOST_ASIO_HAS_BOOST_REGEX)
# if !defined(BOOST_ASIO_DISABLE_BOOST_REGEX)
# define BOOST_ASIO_HAS_BOOST_REGEX 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_REGEX)
#endif // !defined(BOOST_ASIO_HAS_BOOST_REGEX)
// Boost bind function.
#if !defined(BOOST_ASIO_HAS_BOOST_BIND)
# if !defined(BOOST_ASIO_DISABLE_BOOST_BIND)
# define BOOST_ASIO_HAS_BOOST_BIND 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_BIND)
#endif // !defined(BOOST_ASIO_HAS_BOOST_BIND)
// Boost's BOOST_WORKAROUND macro.
#if !defined(BOOST_ASIO_HAS_BOOST_WORKAROUND)
# if !defined(BOOST_ASIO_DISABLE_BOOST_WORKAROUND)
# define BOOST_ASIO_HAS_BOOST_WORKAROUND 1
# endif // !defined(BOOST_ASIO_DISABLE_BOOST_WORKAROUND)
#endif // !defined(BOOST_ASIO_HAS_BOOST_WORKAROUND)
// Microsoft Visual C++'s secure C runtime library.
#if !defined(BOOST_ASIO_HAS_SECURE_RTL)
# if !defined(BOOST_ASIO_DISABLE_SECURE_RTL)
# if defined(BOOST_ASIO_MSVC) \
&& (BOOST_ASIO_MSVC >= 1400) \
&& !defined(UNDER_CE)
# define BOOST_ASIO_HAS_SECURE_RTL 1
# endif // defined(BOOST_ASIO_MSVC)
// && (BOOST_ASIO_MSVC >= 1400)
// && !defined(UNDER_CE)
# endif // !defined(BOOST_ASIO_DISABLE_SECURE_RTL)
#endif // !defined(BOOST_ASIO_HAS_SECURE_RTL)
// Handler hooking. Disabled for ancient Borland C++ and gcc compilers.
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
# if !defined(BOOST_ASIO_DISABLE_HANDLER_HOOKS)
# if defined(__GNUC__)
# if (__GNUC__ >= 3)
# define BOOST_ASIO_HAS_HANDLER_HOOKS 1
# endif // (__GNUC__ >= 3)
# elif !defined(__BORLANDC__)
# define BOOST_ASIO_HAS_HANDLER_HOOKS 1
# endif // !defined(__BORLANDC__)
# endif // !defined(BOOST_ASIO_DISABLE_HANDLER_HOOKS)
#endif // !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
// Support for the __thread keyword extension.
#if !defined(BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
@ -386,4 +736,13 @@
# endif // defined(__linux__)
#endif // !defined(BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
// Support for POSIX ssize_t typedef.
#if !defined(BOOST_ASIO_DISABLE_SSIZE_T)
# if defined(__linux__) \
|| (defined(__MACH__) && defined(__APPLE__))
# define BOOST_ASIO_HAS_SSIZE_T 1
# endif // defined(__linux__)
// || (defined(__MACH__) && defined(__APPLE__))
#endif // !defined(BOOST_ASIO_DISABLE_SSIZE_T)
#endif // BOOST_ASIO_DETAIL_CONFIG_HPP

View file

@ -2,7 +2,7 @@
// detail/consuming_buffers.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
@ -17,9 +17,9 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/iterator.hpp>
#include <boost/limits.hpp>
#include <iterator>
#include <boost/asio/buffer.hpp>
#include <boost/asio/detail/limits.hpp>
#include <boost/asio/detail/push_options.hpp>
@ -30,9 +30,23 @@ namespace detail {
// A proxy iterator for a sub-range in a list of buffers.
template <typename Buffer, typename Buffer_Iterator>
class consuming_buffers_iterator
: public boost::iterator<std::forward_iterator_tag, const Buffer>
{
public:
/// The type used for the distance between two iterators.
typedef std::ptrdiff_t difference_type;
/// The type of the value pointed to by the iterator.
typedef Buffer value_type;
/// The type of the result of applying operator->() to the iterator.
typedef const Buffer* pointer;
/// The type of the result of applying operator*() to the iterator.
typedef const Buffer& reference;
/// The iterator category.
typedef std::forward_iterator_tag iterator_category;
// Default constructor creates an end iterator.
consuming_buffers_iterator()
: at_end_(true)

View file

@ -0,0 +1,48 @@
//
// detail/cstdint.hpp
// ~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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_ASIO_DETAIL_CSTDINT_HPP
#define BOOST_ASIO_DETAIL_CSTDINT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#if defined(BOOST_ASIO_HAS_CSTDINT)
# include <cstdint>
#else // defined(BOOST_ASIO_HAS_CSTDINT)
# include <boost/cstdint.hpp>
#endif // defined(BOOST_ASIO_HAS_CSTDINT)
namespace boost {
namespace asio {
#if defined(BOOST_ASIO_HAS_CSTDINT)
using std::int16_t;
using std::uint16_t;
using std::int32_t;
using std::uint32_t;
using std::int64_t;
using std::uint64_t;
#else // defined(BOOST_ASIO_HAS_CSTDINT)
using boost::int16_t;
using boost::uint16_t;
using boost::int32_t;
using boost::uint32_t;
using boost::int64_t;
using boost::uint64_t;
#endif // defined(BOOST_ASIO_HAS_CSTDINT)
} // namespace asio
} // namespace boost
#endif // BOOST_ASIO_DETAIL_CSTDINT_HPP

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