update boost on linux
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
@@ -46,16 +47,19 @@ namespace boost { namespace spirit { namespace x3
|
||||
|
||||
// This will catch all nodes except those inheriting from position_tagged
|
||||
template <typename AST>
|
||||
boost::iterator_range<iterator_type>
|
||||
position_of(AST const& ast) const
|
||||
typename boost::enable_if_c<
|
||||
(!is_base_of<position_tagged, AST>::value)
|
||||
, boost::iterator_range<iterator_type>
|
||||
>::type
|
||||
position_of(AST const& /* ast */) const
|
||||
{
|
||||
// returns an empty position
|
||||
return boost::iterator_range<iterator_type>();
|
||||
}
|
||||
|
||||
|
||||
// This will catch all nodes except those inheriting from position_tagged
|
||||
template <typename AST>
|
||||
void annotate(AST& ast, iterator_type first, iterator_type last, mpl::false_)
|
||||
void annotate(AST& /* ast */, iterator_type /* first */, iterator_type /* last */, mpl::false_)
|
||||
{
|
||||
// (no-op) no need for tags
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
#if !defined(BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM)
|
||||
#define BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -29,7 +30,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
forward_ast(forward_ast const& operand)
|
||||
: p_(new T(operand.get())) {}
|
||||
|
||||
forward_ast(forward_ast&& operand)
|
||||
forward_ast(forward_ast&& operand) BOOST_NOEXCEPT
|
||||
: p_(operand.p_)
|
||||
{
|
||||
operand.p_ = 0;
|
||||
@@ -46,7 +47,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
boost::checked_delete(p_);
|
||||
}
|
||||
|
||||
forward_ast& operator=(forward_ast const& rhs)
|
||||
forward_ast& operator=(forward_ast const& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_copy_assignable<T>::value)
|
||||
{
|
||||
assign(rhs.get());
|
||||
return *this;
|
||||
@@ -59,7 +60,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
p_ = temp;
|
||||
}
|
||||
|
||||
forward_ast& operator=(T const& rhs)
|
||||
forward_ast& operator=(T const& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_copy_assignable<T>::value)
|
||||
{
|
||||
assign(rhs);
|
||||
return *this;
|
||||
@@ -71,24 +72,24 @@ namespace boost { namespace spirit { namespace x3
|
||||
return *this;
|
||||
}
|
||||
|
||||
forward_ast& operator=(T&& rhs)
|
||||
forward_ast& operator=(T&& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_move_assignable<T>::value)
|
||||
{
|
||||
get() = std::move(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& get() { return *get_pointer(); }
|
||||
const T& get() const { return *get_pointer(); }
|
||||
T& get() BOOST_NOEXCEPT { return *get_pointer(); }
|
||||
const T& get() const BOOST_NOEXCEPT { return *get_pointer(); }
|
||||
|
||||
T* get_pointer() { return p_; }
|
||||
const T* get_pointer() const { return p_; }
|
||||
T* get_pointer() BOOST_NOEXCEPT { return p_; }
|
||||
const T* get_pointer() const BOOST_NOEXCEPT { return p_; }
|
||||
|
||||
operator T const&() const { return this->get(); }
|
||||
operator T&() { return this->get(); }
|
||||
operator T const&() const BOOST_NOEXCEPT { return this->get(); }
|
||||
operator T&() BOOST_NOEXCEPT { return this->get(); }
|
||||
|
||||
private:
|
||||
|
||||
void assign(const T& rhs)
|
||||
void assign(const T& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_copy_assignable<T>::value)
|
||||
{
|
||||
this->get() = rhs;
|
||||
}
|
||||
@@ -117,6 +118,10 @@ namespace boost { namespace spirit { namespace x3
|
||||
{};
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4521) // multiple copy constructors specified
|
||||
#endif
|
||||
template <typename ...Types>
|
||||
struct variant
|
||||
{
|
||||
@@ -135,46 +140,46 @@ namespace boost { namespace spirit { namespace x3
|
||||
::value)
|
||||
>;
|
||||
|
||||
variant() : var() {}
|
||||
variant() BOOST_NOEXCEPT_IF(std::is_nothrow_default_constructible<variant_type>::value) : var() {}
|
||||
|
||||
template <typename T, class = non_self_t<T>>
|
||||
explicit variant(T const& rhs)
|
||||
explicit variant(T const& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_constructible<variant_type, T const&>::value))
|
||||
: var(rhs) {}
|
||||
|
||||
template <typename T, class = non_self_t<T>>
|
||||
explicit variant(T&& rhs)
|
||||
explicit variant(T&& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_constructible<variant_type, T&&>::value))
|
||||
: var(std::forward<T>(rhs)) {}
|
||||
|
||||
variant(variant const& rhs)
|
||||
variant(variant const& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_copy_constructible<variant_type>::value)
|
||||
: var(rhs.var) {}
|
||||
|
||||
variant(variant& rhs)
|
||||
variant(variant& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_constructible<variant_type, variant_type&>::value))
|
||||
: var(rhs.var) {}
|
||||
|
||||
variant(variant&& rhs)
|
||||
: var(std::forward<variant_type>(rhs.var)) {}
|
||||
variant(variant&& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_move_constructible<variant_type>::value)
|
||||
: var(std::move(rhs.var)) {}
|
||||
|
||||
variant& operator=(variant const& rhs)
|
||||
variant& operator=(variant const& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_copy_assignable<variant_type>::value)
|
||||
{
|
||||
var = rhs.get();
|
||||
return *this;
|
||||
}
|
||||
|
||||
variant& operator=(variant&& rhs)
|
||||
variant& operator=(variant&& rhs) BOOST_NOEXCEPT_IF(std::is_nothrow_move_assignable<variant_type>::value)
|
||||
{
|
||||
var = std::forward<variant_type>(rhs.get());
|
||||
var = std::move(rhs.get());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class = non_self_t<T>>
|
||||
variant& operator=(T const& rhs)
|
||||
variant& operator=(T const& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_assignable<variant_type, T const&>::value))
|
||||
{
|
||||
var = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class = non_self_t<T>>
|
||||
variant& operator=(T&& rhs)
|
||||
variant& operator=(T&& rhs) BOOST_NOEXCEPT_IF((std::is_nothrow_assignable<variant_type, T&&>::value))
|
||||
{
|
||||
var = std::forward<T>(rhs);
|
||||
return *this;
|
||||
@@ -204,12 +209,12 @@ namespace boost { namespace spirit { namespace x3
|
||||
return var.apply_visitor(v);
|
||||
}
|
||||
|
||||
variant_type const& get() const
|
||||
variant_type const& get() const BOOST_NOEXCEPT
|
||||
{
|
||||
return var;
|
||||
}
|
||||
|
||||
variant_type& get()
|
||||
variant_type& get() BOOST_NOEXCEPT
|
||||
{
|
||||
return var;
|
||||
}
|
||||
@@ -221,34 +226,37 @@ namespace boost { namespace spirit { namespace x3
|
||||
|
||||
variant_type var;
|
||||
};
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}}}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template <typename T, typename ...Types>
|
||||
inline T const&
|
||||
get(boost::spirit::x3::variant<Types...> const& x)
|
||||
get(boost::spirit::x3::variant<Types...> const& x) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::get<T>(x.get());
|
||||
}
|
||||
|
||||
template <typename T, typename ...Types>
|
||||
inline T&
|
||||
get(boost::spirit::x3::variant<Types...>& x)
|
||||
get(boost::spirit::x3::variant<Types...>& x) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::get<T>(x.get());
|
||||
}
|
||||
|
||||
template <typename T, typename ...Types>
|
||||
inline T const*
|
||||
get(boost::spirit::x3::variant<Types...> const* x)
|
||||
get(boost::spirit::x3::variant<Types...> const* x) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::get<T>(&x->get());
|
||||
}
|
||||
|
||||
template <typename T, typename ...Types>
|
||||
inline T*
|
||||
get(boost::spirit::x3::variant<Types...>* x)
|
||||
get(boost::spirit::x3::variant<Types...>* x) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::get<T>(&x->get());
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
return { val };
|
||||
}
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename ID, typename T, typename Next, typename FoundVal>
|
||||
inline Next const&
|
||||
make_unique_context(T& val, Next const& next, FoundVal&)
|
||||
make_unique_context(T& /* val */, Next const& next, FoundVal&)
|
||||
{
|
||||
return next;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
return { val, next };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename ID, typename T, typename Next>
|
||||
inline auto
|
||||
make_unique_context(T& val, Next const& next)
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/seq/elem.hpp>
|
||||
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
@@ -34,6 +33,8 @@
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
#include <iterator> // for std::iterator_traits
|
||||
|
||||
#if !defined(SPIRIT_NUMERICS_LOOP_UNROLL)
|
||||
# define SPIRIT_NUMERICS_LOOP_UNROLL 3
|
||||
#endif
|
||||
@@ -52,6 +53,9 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
template <typename T, unsigned Radix>
|
||||
struct digits_traits;
|
||||
|
||||
template <int Digits, unsigned Radix>
|
||||
struct digits2_to_n;
|
||||
|
||||
// lookup table for log2(x) : 2 <= x <= 36
|
||||
#define BOOST_SPIRIT_X3_LOG2 (#error)(#error) \
|
||||
(1000000)(1584960)(2000000)(2321920)(2584960)(2807350) \
|
||||
@@ -63,11 +67,10 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
/***/
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(Radix) \
|
||||
template <typename T> struct digits_traits<T, Radix> \
|
||||
template <int Digits> struct digits2_to_n<Digits, Radix> \
|
||||
{ \
|
||||
typedef std::numeric_limits<T> numeric_limits_type; \
|
||||
BOOST_STATIC_CONSTANT(int, value = static_cast<int>( \
|
||||
(numeric_limits_type::digits * 1000000) / \
|
||||
(Digits * 1000000) / \
|
||||
BOOST_PP_SEQ_ELEM(Radix, BOOST_SPIRIT_X3_LOG2))); \
|
||||
}; \
|
||||
/***/
|
||||
@@ -77,6 +80,18 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
|
||||
#undef BOOST_SPIRIT_X3_LOG2
|
||||
|
||||
template <typename T, unsigned Radix>
|
||||
struct digits_traits : digits2_to_n<std::numeric_limits<T>::digits, Radix>
|
||||
{
|
||||
static_assert(std::numeric_limits<T>::radix == 2, "");
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct digits_traits<T, 10>
|
||||
{
|
||||
static int constexpr value = std::numeric_limits<T>::digits10;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Traits class for radix specific number conversion
|
||||
@@ -132,19 +147,19 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
inline static bool add(T& n, Char ch, mpl::true_) // checked add
|
||||
{
|
||||
// Ensure n *= Radix will not overflow
|
||||
static T const max = (std::numeric_limits<T>::max)();
|
||||
static T const val = max / Radix;
|
||||
T const max = (std::numeric_limits<T>::max)();
|
||||
T const val = max / Radix;
|
||||
if (n > val)
|
||||
return false;
|
||||
|
||||
n *= Radix;
|
||||
T tmp = n * Radix;
|
||||
|
||||
// Ensure n += digit will not overflow
|
||||
const int digit = radix_traits<Radix>::digit(ch);
|
||||
if (n > max - digit)
|
||||
if (tmp > max - digit)
|
||||
return false;
|
||||
|
||||
n += static_cast<T>(digit);
|
||||
n = tmp + static_cast<T>(digit);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -163,19 +178,19 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
inline static bool add(T& n, Char ch, mpl::true_) // checked subtract
|
||||
{
|
||||
// Ensure n *= Radix will not underflow
|
||||
static T const min = (std::numeric_limits<T>::min)();
|
||||
static T const val = (min + 1) / T(Radix);
|
||||
T const min = (std::numeric_limits<T>::min)();
|
||||
T const val = min / T(Radix);
|
||||
if (n < val)
|
||||
return false;
|
||||
|
||||
n *= Radix;
|
||||
T tmp = n * Radix;
|
||||
|
||||
// Ensure n -= digit will not underflow
|
||||
int const digit = radix_traits<Radix>::digit(ch);
|
||||
if (n < min + digit)
|
||||
if (tmp < min + digit)
|
||||
return false;
|
||||
|
||||
n -= static_cast<T>(digit);
|
||||
n = tmp - static_cast<T>(digit);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -190,7 +205,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
inline static bool
|
||||
call(Char ch, std::size_t count, T& n, mpl::true_)
|
||||
{
|
||||
static std::size_t const
|
||||
std::size_t constexpr
|
||||
overflow_free = digits_traits<T, Radix>::value - 1;
|
||||
|
||||
if (count < overflow_free)
|
||||
@@ -296,7 +311,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
typedef radix_traits<Radix> radix_check;
|
||||
typedef int_extractor<Radix, Accumulator, MaxDigits> extractor;
|
||||
typedef typename
|
||||
boost::detail::iterator_traits<Iterator>::value_type
|
||||
std::iterator_traits<Iterator>::value_type
|
||||
char_type;
|
||||
|
||||
Iterator it = first;
|
||||
@@ -394,7 +409,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
typedef radix_traits<Radix> radix_check;
|
||||
typedef int_extractor<Radix, Accumulator, -1> extractor;
|
||||
typedef typename
|
||||
boost::detail::iterator_traits<Iterator>::value_type
|
||||
std::iterator_traits<Iterator>::value_type
|
||||
char_type;
|
||||
|
||||
Iterator it = first;
|
||||
@@ -474,35 +489,6 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
};
|
||||
|
||||
#undef SPIRIT_NUMERIC_INNER_LOOP
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Cast an signed integer to an unsigned integer
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T,
|
||||
bool force_unsigned
|
||||
= mpl::and_<is_integral<T>, is_signed<T> >::value>
|
||||
struct cast_unsigned;
|
||||
|
||||
template <typename T>
|
||||
struct cast_unsigned<T, true>
|
||||
{
|
||||
typedef typename make_unsigned<T>::type unsigned_type;
|
||||
typedef typename make_unsigned<T>::type& unsigned_type_ref;
|
||||
|
||||
inline static unsigned_type_ref call(T& n)
|
||||
{
|
||||
return unsigned_type_ref(n);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct cast_unsigned<T, false>
|
||||
{
|
||||
inline static T& call(T& n)
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -62,8 +62,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
extract_type;
|
||||
|
||||
Iterator save = first;
|
||||
if (!extract_type::parse(first, last,
|
||||
detail::cast_unsigned<T>::call(attr)))
|
||||
if (!extract_type::parse(first, last, attr))
|
||||
{
|
||||
first = save;
|
||||
return false;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
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)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_EXTRACT_REAL_APRIL_18_2006_0901AM)
|
||||
#define SPIRIT_EXTRACT_REAL_APRIL_18_2006_0901AM
|
||||
#if !defined(BOOST_SPIRIT_X3_EXTRACT_REAL_APRIL_18_2006_0901AM)
|
||||
#define BOOST_SPIRIT_X3_EXTRACT_REAL_APRIL_18_2006_0901AM
|
||||
|
||||
#include <cmath>
|
||||
#include <boost/limits.hpp>
|
||||
@@ -103,20 +103,6 @@ namespace boost { namespace spirit { namespace x3 { namespace extension
|
||||
// no-op for unused_type
|
||||
return n;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool
|
||||
is_equal_to_one(T const& value)
|
||||
{
|
||||
return value == 1.0;
|
||||
}
|
||||
|
||||
inline bool
|
||||
is_equal_to_one(unused_type)
|
||||
{
|
||||
// no-op for unused_type
|
||||
return false;
|
||||
}
|
||||
}}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
@@ -180,6 +166,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
if (!is_same<T, unused_type>::value)
|
||||
frac_digits =
|
||||
static_cast<int>(std::distance(savef, first));
|
||||
BOOST_ASSERT(frac_digits >= 0);
|
||||
}
|
||||
else if (!got_a_number || !p.allow_trailing_dot)
|
||||
{
|
||||
@@ -235,20 +222,6 @@ namespace boost { namespace spirit { namespace x3
|
||||
// No exponent found. Scale the number by -frac_digits.
|
||||
extension::scale(-frac_digits, n);
|
||||
}
|
||||
else if (extension::is_equal_to_one(n))
|
||||
{
|
||||
// There is a chance of having to parse one of the 1.0#...
|
||||
// styles some implementations use for representing NaN or Inf.
|
||||
|
||||
// Check whether the number to parse is a NaN or Inf
|
||||
if (p.parse_nan(first, last, n) ||
|
||||
p.parse_inf(first, last, n))
|
||||
{
|
||||
// If we got a negative sign, negate the number
|
||||
traits::move_to(extension::negate(neg, n), attr);
|
||||
return true; // got a NaN or Inf, return immediately
|
||||
}
|
||||
}
|
||||
|
||||
// If we got a negative sign, negate the number
|
||||
traits::move_to(extension::negate(neg, n), attr);
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
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)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_SIGN_MAR_11_2009_0734PM)
|
||||
#define SPIRIT_SIGN_MAR_11_2009_0734PM
|
||||
#if !defined(BOOST_SPIRIT_X3_SIGN_MAR_11_2009_0734PM)
|
||||
#define BOOST_SPIRIT_X3_SIGN_MAR_11_2009_0734PM
|
||||
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/math/special_functions/sign.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
@@ -21,22 +19,10 @@ namespace boost { namespace spirit { namespace x3
|
||||
return (boost::math::signbit)(x) ? true : false;
|
||||
}
|
||||
|
||||
// This routine has been taken and adapted from Johan Rade's fp_traits
|
||||
// library
|
||||
template<typename T>
|
||||
inline T (changesign)(T x)
|
||||
{
|
||||
#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)
|
||||
return -x;
|
||||
#else
|
||||
typedef typename math::detail::fp_traits<T>::type traits_type;
|
||||
|
||||
typename traits_type::bits a;
|
||||
traits_type::get_bits(x, a);
|
||||
a ^= traits_type::sign;
|
||||
traits_type::set_bits(x, a);
|
||||
return x;
|
||||
#endif
|
||||
return (boost::math::changesign)(x);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#if !defined(BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM)
|
||||
#define BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM
|
||||
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/logical.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/fusion/include/copy.hpp>
|
||||
#include <boost/fusion/include/is_sequence.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/is_variant.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/is_range.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/optional_traits.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
@@ -31,6 +32,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
struct associative_attribute {};
|
||||
struct variant_attribute {};
|
||||
struct optional_attribute {};
|
||||
struct range_attribute {};
|
||||
|
||||
template <typename T, typename Enable = void>
|
||||
struct attribute_category
|
||||
@@ -46,21 +48,21 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
|
||||
template <typename T>
|
||||
struct attribute_category< T
|
||||
, typename enable_if<
|
||||
typename mpl::eval_if<
|
||||
fusion::traits::is_sequence<T>
|
||||
, fusion::traits::is_associative<T>
|
||||
, mpl::false_
|
||||
>::type >::type >
|
||||
, typename enable_if<
|
||||
typename mpl::eval_if<
|
||||
fusion::traits::is_sequence<T>
|
||||
, fusion::traits::is_associative<T>
|
||||
, mpl::false_
|
||||
>::type >::type >
|
||||
: mpl::identity<associative_attribute> {};
|
||||
|
||||
template <typename T>
|
||||
struct attribute_category< T
|
||||
, typename enable_if<
|
||||
mpl::and_<
|
||||
fusion::traits::is_sequence<T>
|
||||
, mpl::not_<fusion::traits::is_associative<T> >
|
||||
> >::type >
|
||||
, typename enable_if<
|
||||
mpl::and_<
|
||||
fusion::traits::is_sequence<T>
|
||||
, mpl::not_<fusion::traits::is_associative<T> >
|
||||
> >::type >
|
||||
: mpl::identity<tuple_attribute> {};
|
||||
|
||||
template <typename T>
|
||||
@@ -70,7 +72,22 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
|
||||
template <typename T>
|
||||
struct attribute_category<T,
|
||||
typename enable_if<traits::is_container<T>>::type>
|
||||
typename enable_if<traits::is_optional<T>>::type>
|
||||
: mpl::identity<optional_attribute> {};
|
||||
|
||||
template <typename T>
|
||||
struct attribute_category<T,
|
||||
typename enable_if<traits::is_range<T>>::type>
|
||||
: mpl::identity<range_attribute> {};
|
||||
|
||||
template <typename T>
|
||||
struct attribute_category< T
|
||||
, typename enable_if<
|
||||
mpl::and_<
|
||||
traits::is_container<T>
|
||||
, mpl::not_<fusion::traits::is_sequence<T> >
|
||||
, mpl::not_<traits::is_range<T> >
|
||||
> >::type >
|
||||
: mpl::identity<container_attribute> {};
|
||||
|
||||
}}}}
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/fusion/include/deque.hpp>
|
||||
#include <boost/tti/has_type.hpp>
|
||||
#include <boost/tti/has_member_function.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <vector>
|
||||
@@ -35,7 +33,6 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
BOOST_TTI_HAS_TYPE(size_type)
|
||||
BOOST_TTI_HAS_TYPE(reference)
|
||||
BOOST_TTI_HAS_TYPE(key_type)
|
||||
BOOST_TTI_HAS_MEMBER_FUNCTION(reserve)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -49,9 +46,12 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
using is_associative = mpl::bool_<
|
||||
detail::has_type_key_type<T>::value>;
|
||||
|
||||
template <typename T>
|
||||
using is_reservable = mpl::bool_<
|
||||
detail::has_member_function_reserve<T, void, mpl::vector<size_t>>::value>;
|
||||
template<typename T, typename Enable = void>
|
||||
struct is_reservable : mpl::false_ {};
|
||||
|
||||
template<typename T>
|
||||
struct is_reservable<T, decltype(std::declval<T&>().reserve(0))>
|
||||
: mpl::true_ {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace detail
|
||||
@@ -122,7 +122,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
template <typename T>
|
||||
static bool call(Container& c, T&& val)
|
||||
{
|
||||
c.insert(c.end(), std::move(val));
|
||||
c.insert(c.end(), static_cast<T&&>(val));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -130,7 +130,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
template <typename Container, typename T>
|
||||
inline bool push_back(Container& c, T&& val)
|
||||
{
|
||||
return push_back_container<Container>::call(c, std::move(val));
|
||||
return push_back_container<Container>::call(c, static_cast<T&&>(val));
|
||||
}
|
||||
|
||||
template <typename Container>
|
||||
@@ -159,7 +159,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
private:
|
||||
template <typename Iterator>
|
||||
static void reserve(Container& c, Iterator first, Iterator last, mpl::false_)
|
||||
static void reserve(Container& /* c */, Iterator /* first */, Iterator /* last */, mpl::false_)
|
||||
{
|
||||
// Not all containers have "reserve"
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline bool append(unused_type, Iterator first, Iterator last)
|
||||
inline bool append(unused_type, Iterator /* first */, Iterator /* last */)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
template <typename Iterator, typename Enable = void>
|
||||
struct deref_iterator
|
||||
{
|
||||
typedef typename boost::detail::iterator_traits<Iterator>::reference type;
|
||||
typedef typename std::iterator_traits<Iterator>::reference type;
|
||||
static type call(Iterator& it)
|
||||
{
|
||||
return *it;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
http://spirit.sourceforge.net/
|
||||
|
||||
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)
|
||||
=============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_X3_IS_RANGE_DEC_06_2017_1900PM)
|
||||
#define BOOST_SPIRIT_X3_IS_RANGE_DEC_06_2017_1900PM
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
template <typename T, typename Enable = void>
|
||||
struct is_range
|
||||
: mpl::false_
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
struct is_range<boost::iterator_range<T>>
|
||||
: mpl::true_
|
||||
{};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
@@ -1,82 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
Copyright (c) 2001-2012 Hartmut Kaiser
|
||||
http://spirit.sourceforge.net/
|
||||
|
||||
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)
|
||||
=============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM)
|
||||
#define BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
template <typename Attribute>
|
||||
struct make_attribute_base
|
||||
{
|
||||
static Attribute call(unused_type)
|
||||
{
|
||||
// synthesize the attribute/parameter
|
||||
return Attribute();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T& call(T& value)
|
||||
{
|
||||
return value; // just pass the one provided
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Attribute, typename ActualAttribute>
|
||||
struct make_attribute : make_attribute_base<Attribute>
|
||||
{
|
||||
typedef ActualAttribute& type;
|
||||
typedef ActualAttribute value_type;
|
||||
};
|
||||
|
||||
template <typename Attribute>
|
||||
struct make_attribute<Attribute, unused_type>
|
||||
: make_attribute_base<Attribute>
|
||||
{
|
||||
typedef typename remove_const<Attribute>::type attribute_type;
|
||||
typedef attribute_type type;
|
||||
typedef attribute_type value_type;
|
||||
};
|
||||
|
||||
template <typename Attribute, typename ActualAttribute>
|
||||
struct make_attribute<Attribute&, ActualAttribute>
|
||||
: make_attribute<Attribute, ActualAttribute> {};
|
||||
|
||||
template <typename Attribute, typename ActualAttribute>
|
||||
struct make_attribute<Attribute const&, ActualAttribute>
|
||||
: make_attribute<Attribute const, ActualAttribute> {};
|
||||
|
||||
template <typename ActualAttribute>
|
||||
struct make_attribute<unused_type, ActualAttribute>
|
||||
{
|
||||
typedef unused_type type;
|
||||
typedef unused_type value_type;
|
||||
static unused_type call(unused_type)
|
||||
{
|
||||
return unused;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_attribute<unused_type, unused_type>
|
||||
{
|
||||
typedef unused_type type;
|
||||
typedef unused_type value_type;
|
||||
static unused_type call(unused_type)
|
||||
{
|
||||
return unused;
|
||||
}
|
||||
};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
@@ -14,10 +14,8 @@
|
||||
#include <boost/spirit/home/x3/support/traits/variant_has_substitute.hpp>
|
||||
#include <boost/fusion/include/is_sequence.hpp>
|
||||
#include <boost/fusion/include/front.hpp>
|
||||
#include <boost/fusion/include/size.hpp>
|
||||
#include <boost/fusion/include/move.hpp>
|
||||
#include <boost/fusion/include/is_sequence.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
@@ -152,6 +150,13 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
move_to(src, dest, tag, is_size_one_sequence<Source>());
|
||||
}
|
||||
|
||||
template <typename Source, typename Dest>
|
||||
inline void
|
||||
move_to(Source&& src, Dest& dest, optional_attribute)
|
||||
{
|
||||
dest = std::move(src);
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline void
|
||||
move_to(Iterator, Iterator, unused_type, unused_attribute) {}
|
||||
@@ -165,10 +170,19 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
else
|
||||
append(dest, first, last);
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Dest>
|
||||
inline typename enable_if<
|
||||
is_size_one_sequence<Dest>
|
||||
>::type
|
||||
move_to(Iterator first, Iterator last, Dest& dest, tuple_attribute)
|
||||
{
|
||||
traits::move_to(first, last, fusion::front(dest));
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline void
|
||||
move_to(Iterator first, Iterator last, boost::iterator_range<Iterator>& rng, container_attribute)
|
||||
move_to(Iterator first, Iterator last, boost::iterator_range<Iterator>& rng, range_attribute)
|
||||
{
|
||||
rng = {first, last};
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
#define BOOST_SPIRIT_X3_NUMERIC_TRAITS_JAN_07_2011_0722AM
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <limits>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
@@ -112,13 +111,9 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
|
||||
template <typename T, typename Enable = void>
|
||||
struct is_infinite;
|
||||
|
||||
|
||||
template <typename T, typename Enable = void>
|
||||
struct check_overflow : mpl::false_ {};
|
||||
|
||||
template <typename T>
|
||||
struct check_overflow<T, typename enable_if_c<integer_traits<T>::is_integral>::type>
|
||||
: mpl::true_ {};
|
||||
struct check_overflow : mpl::bool_<std::numeric_limits<T>::is_bounded> {};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,21 +24,6 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
template <typename Exposed, typename Transformed, typename Tag
|
||||
, typename Enable = void>
|
||||
struct transform_attribute;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Tag, typename Transformed, typename Exposed>
|
||||
typename transform_attribute<Exposed, Transformed, Tag>::type
|
||||
pre_transform(Exposed& attr)
|
||||
{
|
||||
return transform_attribute<Exposed, Transformed, Tag>::pre(attr);
|
||||
}
|
||||
|
||||
template <typename Tag, typename Transformed, typename Exposed>
|
||||
typename transform_attribute<Exposed, Transformed, Tag>::type
|
||||
pre_transform(Exposed const& attr)
|
||||
{
|
||||
return transform_attribute<Exposed const, Transformed, Tag>::pre(attr);
|
||||
}
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define BOOST_SPIRIT_X3_TUPLE_TRAITS_JANUARY_2012_1132PM
|
||||
|
||||
#include <boost/fusion/include/is_sequence.hpp>
|
||||
#include <boost/fusion/include/is_view.hpp>
|
||||
#include <boost/fusion/include/size.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
@@ -43,6 +44,14 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
, has_size<Seq, 1>
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename View>
|
||||
struct is_size_one_view
|
||||
: mpl::and_<
|
||||
fusion::traits::is_view<View>
|
||||
, has_size<View, 1>
|
||||
>
|
||||
{};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#if !defined(BOOST_SPIRIT_X3_VALUE_TRAITS_MAY_07_2013_0203PM)
|
||||
#define BOOST_SPIRIT_X3_VALUE_TRAITS_MAY_07_2013_0203PM
|
||||
|
||||
#include <boost/utility/value_init.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
template <typename T, typename Enable = void>
|
||||
@@ -18,7 +16,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
static T call()
|
||||
{
|
||||
return boost::value_initialized<T>();
|
||||
return {};
|
||||
}
|
||||
};
|
||||
}}}}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM
|
||||
|
||||
#include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
|
||||
#include <boost/mpl/find.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
@@ -22,9 +23,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
typedef typename variant_type::types types;
|
||||
typedef typename mpl::end<types>::type end;
|
||||
|
||||
typedef typename
|
||||
mpl::find_if<types, is_same<mpl::_1, Attribute> >::type
|
||||
iter_1;
|
||||
typedef typename mpl::find<types, Attribute>::type iter_1;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define BOOST_SPIRIT_X3_VARIANT_HAS_SUBSTITUTE_APR_18_2014_925AM
|
||||
|
||||
#include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
|
||||
#include <boost/mpl/find.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
@@ -22,9 +23,7 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
typedef typename variant_type::types types;
|
||||
typedef typename mpl::end<types>::type end;
|
||||
|
||||
typedef typename
|
||||
mpl::find_if<types, is_same<mpl::_1, Attribute>>::type
|
||||
iter_1;
|
||||
typedef typename mpl::find<types, Attribute>::type iter_1;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
#if !defined(BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM)
|
||||
#define BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM
|
||||
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
|
||||
@@ -58,6 +58,11 @@ namespace boost { namespace spirit { namespace x3
|
||||
return pos_cache.position_of(pos);
|
||||
}
|
||||
|
||||
position_cache<std::vector<Iterator>> const& get_position_cache() const
|
||||
{
|
||||
return pos_cache;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void print_file_line(std::size_t line) const;
|
||||
@@ -178,7 +183,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
if (prev != '\r') ++line;
|
||||
break;
|
||||
case '\r':
|
||||
if (prev != '\n') ++line;
|
||||
++line;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace boost { namespace spirit { namespace x3 { namespace testing
|
||||
std::string output = f(load(input_path), input_path);
|
||||
std::string expected = load(expect_path);
|
||||
|
||||
auto result = compare(output, expected);
|
||||
auto result = compare(output, expected, re_prefix, re_suffix);
|
||||
if (!result.full_match)
|
||||
{
|
||||
std::cout << "=============================================" << std::endl;
|
||||
|
||||
@@ -62,6 +62,44 @@ namespace boost { namespace spirit { namespace x3
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Assume wchar_t content is UTF-16 on Windows and UCS-4 on Unix
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
inline utf8_string to_utf8(wchar_t value)
|
||||
{
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
|
||||
u16_to_u32_iterator<wchar_t const*, ucs4_char> ucs4_iter(&value);
|
||||
*utf8_iter++ = *ucs4_iter;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline utf8_string to_utf8(wchar_t const* str)
|
||||
{
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
|
||||
u16_to_u32_iterator<wchar_t const*, ucs4_char> ucs4_iter(str);
|
||||
for (ucs4_char c; (c = *ucs4_iter) != ucs4_char(); ++ucs4_iter) {
|
||||
*utf8_iter++ = c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Traits, typename Allocator>
|
||||
inline utf8_string
|
||||
to_utf8(std::basic_string<wchar_t, Traits, Allocator> const& str)
|
||||
{
|
||||
return to_utf8(str.c_str());
|
||||
}
|
||||
#endif
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user