Skip to content

Commit

Permalink
Fully internalize Boost.STLInterfacecs headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzlaine committed Sep 20, 2020
1 parent 111efe1 commit f173196
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 2,610 deletions.
Expand Up @@ -3,24 +3,22 @@
// 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_STL_INTERFACES_CONFIG_HPP
#define BOOST_STL_INTERFACES_CONFIG_HPP

// Included for definition of __cpp_lib_concepts.
#include <iterator>
#ifndef BOOST_PARSER_DETAIL_STL_INTERFACES_CONFIG_HPP
#define BOOST_PARSER_DETAIL_STL_INTERFACES_CONFIG_HPP

#include <boost/parser/config.hpp>

// The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is
// inline for standards before C++20, and v2 is inline for C++20 and later.
// Note that this only applies to code for which a v2 namespace alternative
// exists. Some instances of the v1 namespace may still be inline, if there
// is no v2 version of its contents.
#if defined(__cpp_lib_concepts)
# define BOOST_STL_INTERFACES_NAMESPACE_V1 namespace v1
# define BOOST_STL_INTERFACES_NAMESPACE_V2 inline namespace v2
#if BOOST_PARSER_USE_CONCEPTS
# define BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
# define BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V2 inline namespace v2
#else
# define BOOST_STL_INTERFACES_NAMESPACE_V1 inline namespace v1
# define BOOST_STL_INTERFACES_NAMESPACE_V2 namespace v2
# define BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V1 inline namespace v1
# define BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
#endif

#endif
Expand Up @@ -3,35 +3,18 @@
// 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_STL_INTERFACES_FWD_HPP
#define BOOST_STL_INTERFACES_FWD_HPP
#ifndef BOOST_PARSER_DETAIL_STL_INTERFACES_FWD_HPP
#define BOOST_PARSER_DETAIL_STL_INTERFACES_FWD_HPP

#include <boost/stl_interfaces/config.hpp>
#include <boost/parser/detail/stl_interfaces/config.hpp>

#if defined(__cpp_lib_concepts)
#if BOOST_PARSER_USE_CONCEPTS
#include <ranges>
#endif
#if defined(__cpp_lib_three_way_comparison)
#include <compare>
#endif

#ifndef BOOST_STL_INTERFACES_DOXYGEN

#if defined(_MSC_VER) || defined(__GNUC__) && __GNUC__ < 8
#define BOOST_STL_INTERFACES_NO_HIDDEN_FRIEND_CONSTEXPR
#define BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR
#else
#define BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR constexpr
#endif

#if defined(__GNUC__) && __GNUC__ < 9
#define BOOST_STL_INTERFACES_CONCEPT concept bool
#else
#define BOOST_STL_INTERFACES_CONCEPT concept
#endif

#endif


namespace boost { namespace stl_interfaces {

Expand All @@ -43,7 +26,7 @@ namespace boost { namespace stl_interfaces {
contiguous = true
};

BOOST_STL_INTERFACES_NAMESPACE_V1 {
BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V1 {

namespace v1_dtl {
template<typename... T>
Expand Down
Expand Up @@ -3,10 +3,10 @@
// 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_STL_INTERFACES_ITERATOR_INTERFACE_HPP
#define BOOST_STL_INTERFACES_ITERATOR_INTERFACE_HPP
#ifndef BOOST_PARSER_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP
#define BOOST_PARSER_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP

#include <boost/stl_interfaces/fwd.hpp>
#include <boost/parser/detail/stl_interfaces/fwd.hpp>

#include <utility>
#include <type_traits>
Expand Down Expand Up @@ -46,7 +46,7 @@ namespace boost { namespace stl_interfaces {
this template implies a copy or move of the underlying object of type
`T`. */
template<typename T>
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || defined(__cpp_lib_concepts)
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
// clang-format off
requires std::is_object_v<T>
#endif
Expand Down Expand Up @@ -175,7 +175,7 @@ namespace boost { namespace stl_interfaces {

}}

namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
namespace boost { namespace stl_interfaces { BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V1 {

/** A CRTP template that one may derive from to make defining iterators
easier.
Expand Down Expand Up @@ -365,7 +365,7 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
retval += i;
return retval;
}
friend BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived
friend constexpr Derived
operator+(difference_type i, Derived it) noexcept
{
return it + i;
Expand Down Expand Up @@ -420,7 +420,7 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
return access::base(derived()) - access::base(other);
}

friend BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived
friend constexpr Derived
operator-(Derived it, difference_type i) noexcept
{
Derived retval = it;
Expand Down Expand Up @@ -546,9 +546,9 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {

}}}

#if defined(BOOST_STL_INTERFACES_DOXYGEN) || defined(__cpp_lib_concepts)
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS

namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V2 {
namespace boost { namespace stl_interfaces { BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V2 {

namespace v2_dtl {
template<typename Iterator>
Expand Down Expand Up @@ -833,83 +833,4 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V2 {

#endif

#ifdef BOOST_STL_INTERFACES_DOXYGEN

/** `static_asserts` that type `type` models concept `concept_name`. This is
useful for checking that an iterator, view, etc. that you write using one
of the *`_interface` templates models the right C++ concept.
For example: `BOOST_STL_INTERFACES_STATIC_ASSERT_CONCEPT(my_iter,
std::input_iterator)`.
\note This macro expands to nothing when `__cpp_lib_concepts` is not
defined. */
#define BOOST_STL_INTERFACES_STATIC_ASSERT_CONCEPT(type, concept_name)

/** `static_asserts` that the types of all typedefs in
`std::iterator_traits<iter>` match the remaining macro parameters. This
is useful for checking that an iterator you write using
`iterator_interface` has the correct iterator traits.
For example: `BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS(my_iter,
std::input_iterator_tag, std::input_iterator_tag, int, int &, int *, std::ptrdiff_t)`.
\note This macro ignores the `concept` parameter when `__cpp_lib_concepts`
is not defined. */
#define BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
iter, category, concept, value_type, reference, pointer, difference_type)

#else

#define BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL( \
type, concept_name) \
static_assert(concept_name<type>, "");

#define BOOST_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name)

#define BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
iter, category, value_t, ref, ptr, diff_t) \
static_assert( \
std::is_same< \
typename std::iterator_traits<iter>::iterator_category, \
category>::value, \
""); \
static_assert( \
std::is_same< \
typename std::iterator_traits<iter>::value_type, \
value_t>::value, \
""); \
static_assert( \
std::is_same<typename std::iterator_traits<iter>::reference, ref>:: \
value, \
""); \
static_assert( \
std::is_same<typename std::iterator_traits<iter>::pointer, ptr>:: \
value, \
""); \
static_assert( \
std::is_same< \
typename std::iterator_traits<iter>::difference_type, \
diff_t>::value, \
"");

#if defined(__cpp_lib_concepts)
#define BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
iter, category, concept, value_type, reference, pointer, difference_type) \
static_assert( \
std::is_same_v< \
boost::stl_interfaces::v2::v2_dtl::iter_concept_t<iter>, \
concept>, \
""); \
BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
iter, category, value_type, reference, pointer, difference_type)
#else
#define BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
iter, category, concept, value_type, reference, pointer, difference_type) \
BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
iter, category, value_type, reference, pointer, difference_type)
#endif

#endif

#endif
Expand Up @@ -3,13 +3,13 @@
// 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_STL_INTERFACES_REVERSE_ITERATOR_HPP
#define BOOST_STL_INTERFACES_REVERSE_ITERATOR_HPP
#ifndef BOOST_PARSER_DETAIL_STL_INTERFACES_REVERSE_ITERATOR_HPP
#define BOOST_PARSER_DETAIL_STL_INTERFACES_REVERSE_ITERATOR_HPP

#include <boost/stl_interfaces/iterator_interface.hpp>
#include <boost/parser/detail/stl_interfaces/iterator_interface.hpp>


namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
namespace boost { namespace stl_interfaces { BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V1 {

namespace v1_dtl {
template<typename Iter>
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
struct reverse_iterator
: iterator_interface<
reverse_iterator<BidiIter>,
#if defined(__cpp_lib_concepts)
#if BOOST_PARSER_USE_CONCEPTS
typename boost::stl_interfaces::v2::v2_dtl::iter_concept_t<
BidiIter>,
#else
Expand All @@ -86,7 +86,7 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
reverse_iterator(reverse_iterator<BidiIter2> const & it) : it_(it.it_)
{}

friend BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR auto
friend constexpr auto
operator-(reverse_iterator lhs, reverse_iterator rhs) noexcept(
noexcept(v1_dtl::ce_dist(
lhs.it_,
Expand Down Expand Up @@ -170,9 +170,9 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
}}}


#if defined(BOOST_STL_INTERFACES_DOXYGEN) || defined(__cpp_lib_concepts)
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS

namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V2 {
namespace boost { namespace stl_interfaces { BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V2 {

/** A template alias for `std::reverse_iterator`. This only exists to
make migration from Boost.STLInterfaces to C++20 easier; switch to the
Expand Down
Expand Up @@ -3,13 +3,13 @@
// 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_STL_INTERFACES_VIEW_INTERFACE_HPP
#define BOOST_STL_INTERFACES_VIEW_INTERFACE_HPP
#ifndef BOOST_PARSER_DETAIL_STL_INTERFACES_VIEW_INTERFACE_HPP
#define BOOST_PARSER_DETAIL_STL_INTERFACES_VIEW_INTERFACE_HPP

#include <boost/stl_interfaces/fwd.hpp>
#include <boost/parser/detail/stl_interfaces/fwd.hpp>


namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
namespace boost { namespace stl_interfaces { BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V1 {

/** A CRTP template that one may derive from to make it easier to define
`std::ranges::view`-like types with a container-like interface. This
Expand Down Expand Up @@ -201,9 +201,9 @@ namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V1 {
}}}


#if defined(BOOST_STL_INTERFACES_DOXYGEN) || defined(__cpp_lib_concepts)
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS

namespace boost { namespace stl_interfaces { BOOST_STL_INTERFACES_NAMESPACE_V2 {
namespace boost { namespace stl_interfaces { BOOST_PARSER_DETAIL_STL_INTERFACES_NAMESPACE_V2 {

/** A template alias for `std::ranges::view_interface`. This only exists
to make migration from Boost.STLInterfaces to C++20 easier; switch to
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/text/algorithm.hpp
Expand Up @@ -8,7 +8,7 @@

#include <boost/parser/detail/text/detail/sentinel_tag.hpp>

#include <boost/stl_interfaces/view_interface.hpp>
#include <boost/parser/detail/stl_interfaces/view_interface.hpp>

#include <cstddef>
#include <iterator>
Expand Down
4 changes: 1 addition & 3 deletions include/boost/parser/detail/text/config.hpp
Expand Up @@ -6,9 +6,7 @@
#ifndef BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP
#define BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP

// Included for definition of __cpp_lib_concepts.
#include <iterator>

#include <boost/parser/config.hpp>

// The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is
// inline for standards before C++20, and v2 is inline for C++20 and later.
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/text/detail/iterator.hpp
Expand Up @@ -7,7 +7,7 @@
#define BOOST_PARSER_DETAIL_TEXT_DETAIL_ITERATOR_HPP

#include <boost/parser/detail/text/config.hpp>
#include <boost/stl_interfaces/reverse_iterator.hpp>
#include <boost/parser/detail/stl_interfaces/reverse_iterator.hpp>

#include <iterator>

Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/text/transcode_iterator.hpp
Expand Up @@ -13,7 +13,7 @@
#include <boost/parser/detail/text/utf.hpp>
#include <boost/parser/detail/text/detail/algorithm.hpp>

#include <boost/stl_interfaces/iterator_interface.hpp>
#include <boost/parser/detail/stl_interfaces/iterator_interface.hpp>

#include <array>
#include <iterator>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/text/transcode_view.hpp
Expand Up @@ -11,7 +11,7 @@
#include <boost/parser/detail/text/dangling.hpp>
#include <boost/parser/detail/text/detail/unpack.hpp>

#include <boost/stl_interfaces/view_interface.hpp>
#include <boost/parser/detail/stl_interfaces/view_interface.hpp>


namespace boost { namespace text {
Expand Down

0 comments on commit f173196

Please sign in to comment.