diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
commit | b8cf34c691623e4ec329053cbbf68522a855882d (patch) | |
tree | 34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/spirit/home/support | |
parent | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff) | |
download | boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2 boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip |
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/spirit/home/support')
-rw-r--r-- | boost/spirit/home/support/algorithm/any_if_ns_so.hpp | 92 | ||||
-rw-r--r-- | boost/spirit/home/support/algorithm/any_ns_so.hpp | 106 | ||||
-rw-r--r-- | boost/spirit/home/support/attributes.hpp | 15 | ||||
-rw-r--r-- | boost/spirit/home/support/detail/hold_any.hpp | 37 | ||||
-rw-r--r-- | boost/spirit/home/support/iterators/detail/multi_pass.hpp | 1 | ||||
-rw-r--r-- | boost/spirit/home/support/iterators/line_pos_iterator.hpp | 34 | ||||
-rw-r--r-- | boost/spirit/home/support/utree/detail/utree_detail2.hpp | 2 |
7 files changed, 254 insertions, 33 deletions
diff --git a/boost/spirit/home/support/algorithm/any_if_ns_so.hpp b/boost/spirit/home/support/algorithm/any_if_ns_so.hpp new file mode 100644 index 0000000000..d0279cf037 --- /dev/null +++ b/boost/spirit/home/support/algorithm/any_if_ns_so.hpp @@ -0,0 +1,92 @@ +/*============================================================================= + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2001-2011 Joel de Guzman + + 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_ANY_IF_NS_SO_DECEMBER_03_2017_0826PM) +#define BOOST_SPIRIT_ANY_IF_NS_SO_DECEMBER_03_2017_0826PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/support/algorithm/any_ns_so.hpp> + +namespace boost { namespace spirit +{ + /////////////////////////////////////////////////////////////////////////// + // This is a special version for a binary fusion::any. The predicate + // is used to decide whether to advance the second iterator or not. + // This is needed for sequences containing components with unused + // attributes. The second iterator is advanced only if the attribute + // of the corresponding component iterator is not unused. + // + // This is a non-short circuiting (ns) strict order (so) version of the + // any_if algorithm. + /////////////////////////////////////////////////////////////////////////// + namespace detail + { + template < + typename Pred, typename First1, typename Last1, typename First2 + , typename Last2, typename F + > + inline bool + any_if_ns_so(First1 const&, First2 const&, Last1 const&, Last2 const& + , F const&, mpl::true_) + { + return false; + } + + template < + typename Pred, typename First1, typename Last1, typename First2 + , typename Last2, typename F + > + inline bool + any_if_ns_so(First1 const& first1, First2 const& first2 + , Last1 const& last1, Last2 const& last2, F& f, mpl::false_) + { + bool head = f(*first1, spirit::detail::attribute_value<Pred, First1, Last2>(first2)); + bool tail = + detail::any_if_ns_so<Pred>( + fusion::next(first1) + , attribute_next<Pred, First1, Last2>(first2) + , last1, last2 + , f + , fusion::result_of::equal_to< + typename fusion::result_of::next<First1>::type, Last1>()); + return head || tail; + } + } + + template <typename Pred, typename Sequence1, typename Sequence2, typename F> + inline bool + any_if_ns_so(Sequence1 const& seq1, Sequence2& seq2, F f, Pred) + { + return detail::any_if_ns_so<Pred>( + fusion::begin(seq1), fusion::begin(seq2) + , fusion::end(seq1), fusion::end(seq2) + , f + , fusion::result_of::equal_to< + typename fusion::result_of::begin<Sequence1>::type + , typename fusion::result_of::end<Sequence1>::type>()); + } + + template <typename Pred, typename Sequence, typename F> + inline bool + any_if_ns_so(Sequence const& seq, unused_type const, F f, Pred) + { + return detail::any_ns_so( + fusion::begin(seq) + , fusion::end(seq) + , f + , fusion::result_of::equal_to< + typename fusion::result_of::begin<Sequence>::type + , typename fusion::result_of::end<Sequence>::type>()); + } + +}} + +#endif + diff --git a/boost/spirit/home/support/algorithm/any_ns_so.hpp b/boost/spirit/home/support/algorithm/any_ns_so.hpp new file mode 100644 index 0000000000..e0b0e495a2 --- /dev/null +++ b/boost/spirit/home/support/algorithm/any_ns_so.hpp @@ -0,0 +1,106 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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_ANY_NS_SO_DECEMBER_03_2017_0826PM) +#define BOOST_SPIRIT_ANY_NS_SO_DECEMBER_03_2017_0826PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/bool.hpp> +#include <boost/fusion/include/equal_to.hpp> +#include <boost/fusion/include/next.hpp> +#include <boost/fusion/include/deref.hpp> +#include <boost/fusion/include/begin.hpp> +#include <boost/fusion/include/end.hpp> +#include <boost/fusion/include/any.hpp> +#include <boost/spirit/home/support/unused.hpp> + +namespace boost { namespace spirit +{ + // A non-short circuiting (ns) strict order (so) version of the any + // algorithm + + namespace detail + { + template <typename First1, typename Last, typename First2, typename F> + inline bool + any_ns_so(First1 const&, First2 const&, Last const&, F const&, mpl::true_) + { + return false; + } + + template <typename First1, typename Last, typename First2, typename F> + inline bool + any_ns_so(First1 const& first1, First2 const& first2, Last const& last, F& f, mpl::false_) + { + bool head = f(*first1, *first2); + bool tail = + detail::any_ns_so( + fusion::next(first1) + , fusion::next(first2) + , last + , f + , fusion::result_of::equal_to< + typename fusion::result_of::next<First1>::type, Last>()); + return head || tail; + } + + template <typename First, typename Last, typename F> + inline bool + any_ns_so(First const&, Last const&, F const&, mpl::true_) + { + return false; + } + + template <typename First, typename Last, typename F> + inline bool + any_ns_so(First const& first, Last const& last, F& f, mpl::false_) + { + bool head = f(*first); + bool tail = + detail::any_ns_so( + fusion::next(first) + , last + , f + , fusion::result_of::equal_to< + typename fusion::result_of::next<First>::type, Last>()); + return head || tail; + } + } + + template <typename Sequence1, typename Sequence2, typename F> + inline bool + any_ns_so(Sequence1 const& seq1, Sequence2& seq2, F f) + { + return detail::any_ns_so( + fusion::begin(seq1) + , fusion::begin(seq2) + , fusion::end(seq1) + , f + , fusion::result_of::equal_to< + typename fusion::result_of::begin<Sequence1>::type + , typename fusion::result_of::end<Sequence1>::type>()); + } + + template <typename Sequence, typename F> + inline bool + any_ns_so(Sequence const& seq, unused_type, F f) + { + return detail::any_ns_so( + fusion::begin(seq) + , fusion::end(seq) + , f + , fusion::result_of::equal_to< + typename fusion::result_of::begin<Sequence>::type + , typename fusion::result_of::end<Sequence>::type>()); + } + +}} + +#endif + diff --git a/boost/spirit/home/support/attributes.hpp b/boost/spirit/home/support/attributes.hpp index dd89521404..ceba157fcf 100644 --- a/boost/spirit/home/support/attributes.hpp +++ b/boost/spirit/home/support/attributes.hpp @@ -28,7 +28,6 @@ #include <boost/fusion/include/for_each.hpp> #include <boost/fusion/include/is_view.hpp> #include <boost/fusion/include/mpl.hpp> -#include <boost/foreach.hpp> #include <boost/utility/value_init.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_convertible.hpp> @@ -279,11 +278,6 @@ namespace boost { namespace spirit { namespace traits : mpl::false_ {}; - template <typename T, typename Domain> - struct not_is_variant<boost::optional<T>, Domain> - : not_is_variant<T, Domain> - {}; - // we treat every type as if it where the variant (as this meta function is // invoked for variant types only) template <typename T> @@ -296,6 +290,11 @@ namespace boost { namespace spirit { namespace traits : variant_type<T> {}; + template <typename T, typename Domain> + struct not_is_variant_or_variant_in_optional + : not_is_variant<typename variant_type<T>::type, Domain> + {}; + /////////////////////////////////////////////////////////////////////////// // The compute_compatible_component_variant /////////////////////////////////////////////////////////////////////////// @@ -339,7 +338,7 @@ namespace boost { namespace spirit { namespace traits template <typename Variant, typename Expected> struct compute_compatible_component_variant<Variant, Expected, mpl::false_ - , typename enable_if<detail::has_types<Variant> >::type> + , typename enable_if<detail::has_types<typename variant_type<Variant>::type> >::type> { typedef typename traits::variant_type<Variant>::type variant_type; typedef typename variant_type::types types; @@ -372,7 +371,7 @@ namespace boost { namespace spirit { namespace traits template <typename Expected, typename Attribute, typename Domain> struct compute_compatible_component : compute_compatible_component_variant<Attribute, Expected - , typename spirit::traits::not_is_variant<Attribute, Domain>::type> {}; + , typename not_is_variant_or_variant_in_optional<Attribute, Domain>::type> {}; template <typename Expected, typename Domain> struct compute_compatible_component<Expected, unused_type, Domain> diff --git a/boost/spirit/home/support/detail/hold_any.hpp b/boost/spirit/home/support/detail/hold_any.hpp index f9a3ff1bfa..e03e3f1731 100644 --- a/boost/spirit/home/support/detail/hold_any.hpp +++ b/boost/spirit/home/support/detail/hold_any.hpp @@ -101,13 +101,13 @@ namespace boost { namespace spirit *reinterpret_cast<T*>(dest) = *reinterpret_cast<T const*>(src); } - static std::basic_istream<Char>& + static std::basic_istream<Char>& stream_in (std::basic_istream<Char>& i, void** obj) { i >> *reinterpret_cast<T*>(obj); return i; } - static std::basic_ostream<Char>& + static std::basic_ostream<Char>& stream_out(std::basic_ostream<Char>& o, void* const* obj) { o << *reinterpret_cast<T const*>(obj); @@ -146,13 +146,13 @@ namespace boost { namespace spirit **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src); } - static std::basic_istream<Char>& + static std::basic_istream<Char>& stream_in(std::basic_istream<Char>& i, void** obj) { i >> **reinterpret_cast<T**>(obj); return i; } - static std::basic_ostream<Char>& + static std::basic_ostream<Char>& stream_out(std::basic_ostream<Char>& o, void* const* obj) { o << **reinterpret_cast<T* const*>(obj); @@ -198,7 +198,7 @@ namespace boost { namespace spirit // value of the required type to the hold_any instance you want to // stream to. This assignment has to be executed before the actual // call to the operator>>(). - BOOST_ASSERT(false && + BOOST_ASSERT(false && "Tried to insert from a std istream into an empty " "hold_any instance"); return i; @@ -222,10 +222,8 @@ namespace boost { namespace spirit explicit basic_hold_any(T const& x) : table(spirit::detail::get_table<T>::template get<Char>()), object(0) { - if (spirit::detail::get_table<T>::is_small::value) - new (&object) T(x); - else - object = new T(x); + new_object(object, x, + typename spirit::detail::get_table<T>::is_small()); } basic_hold_any() @@ -297,6 +295,18 @@ namespace boost { namespace spirit return *this; } + template <typename T> + static void new_object(void*& object, T const& x, mpl::true_) + { + new (&object) T(x); + } + + template <typename T> + static void new_object(void*& object, T const& x, mpl::false_) + { + object = new T(x); + } + // assignment operator #ifdef BOOST_HAS_RVALUE_REFS template <typename T> @@ -317,6 +327,11 @@ namespace boost { namespace spirit return assign(x); } #endif + // copy assignment operator + basic_hold_any& operator=(basic_hold_any const& x) + { + return assign(x); + } // utility functions basic_hold_any& swap(basic_hold_any& x) @@ -369,14 +384,14 @@ namespace boost { namespace spirit // because spirit::hold_any is used only in contexts where these operators // do exist template <typename Char_> - friend inline std::basic_istream<Char_>& + friend inline std::basic_istream<Char_>& operator>> (std::basic_istream<Char_>& i, basic_hold_any<Char_>& obj) { return obj.table->stream_in(i, &obj.object); } template <typename Char_> - friend inline std::basic_ostream<Char_>& + friend inline std::basic_ostream<Char_>& operator<< (std::basic_ostream<Char_>& o, basic_hold_any<Char_> const& obj) { return obj.table->stream_out(o, &obj.object); diff --git a/boost/spirit/home/support/iterators/detail/multi_pass.hpp b/boost/spirit/home/support/iterators/detail/multi_pass.hpp index 8f8e6c71d3..124100a6b4 100644 --- a/boost/spirit/home/support/iterators/detail/multi_pass.hpp +++ b/boost/spirit/home/support/iterators/detail/multi_pass.hpp @@ -9,7 +9,6 @@ #include <boost/config.hpp> #include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> -#include <boost/iterator.hpp> #include <boost/mpl/bool.hpp> #include <iterator> #include <algorithm> diff --git a/boost/spirit/home/support/iterators/line_pos_iterator.hpp b/boost/spirit/home/support/iterators/line_pos_iterator.hpp index 0b2aec8ce9..558fdca5d5 100644 --- a/boost/spirit/home/support/iterators/line_pos_iterator.hpp +++ b/boost/spirit/home/support/iterators/line_pos_iterator.hpp @@ -1,6 +1,7 @@ /*============================================================================== Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2010 Bryce Lelbach + Copyright (c) 2014 Tomoki Imai 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) @@ -126,17 +127,30 @@ namespace boost { namespace spirit inline Iterator get_line_start(Iterator lower_bound, Iterator current) { Iterator latest = lower_bound; - + bool prev_was_newline = false; for (Iterator i = lower_bound; i != current; ++i) { - switch (*i) { - case '\r': - case '\n': - latest = i; - } + if (prev_was_newline) { + latest = i; + } + prev_was_newline = (*i == '\r') || (*i == '\n'); + } + if (prev_was_newline) { + latest = current; } - return latest; } + + template <class Iterator> + inline Iterator get_line_end(Iterator current, Iterator upper_bound) + { + for (Iterator i = current; i != upper_bound; ++i) { + if ((*i == '\n') || (*i == '\r')) { + return i; + } + } + return upper_bound; + } + template <class Iterator> inline iterator_range<Iterator> @@ -145,11 +159,7 @@ namespace boost { namespace spirit Iterator upper_bound) { Iterator first = get_line_start(lower_bound, current); - Iterator last = get_line_start(current, upper_bound); - - if (last == current) - last = upper_bound; - + Iterator last = get_line_end(current, upper_bound); return iterator_range<Iterator>(first, last); } diff --git a/boost/spirit/home/support/utree/detail/utree_detail2.hpp b/boost/spirit/home/support/utree/detail/utree_detail2.hpp index d4be2c5bde..cc3cb2fd43 100644 --- a/boost/spirit/home/support/utree/detail/utree_detail2.hpp +++ b/boost/spirit/home/support/utree/detail/utree_detail2.hpp @@ -77,7 +77,7 @@ namespace boost { namespace spirit { namespace detail template <typename Iterator> inline void fast_string::construct(Iterator f, Iterator l) { - unsigned const size = l-f; + std::size_t const size = static_cast<std::size_t>(l-f); char* str; if (size < max_string_len) { |