Skip to content

Commit

Permalink
Rename namespace boost to beman::optional::detail for copied files in…
Browse files Browse the repository at this point in the history
… detail/stl_interfaces
  • Loading branch information
neatudarius committed Jun 23, 2024
1 parent a6c6fa3 commit f4eaa88
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 76 deletions.
10 changes: 5 additions & 5 deletions include/Beman/Optional26/detail/iterator.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// include/Beman/Optional26/detail/iterator.hpp -*-C++-*-
#ifndef BEMAN_OPTIONAL26_OPTIONAL_DETAIL_ITERATOR_HPP
#define BEMAN_OPTIONAL26_OPTIONAL_DETAIL_ITERATOR_HPP
#ifndef BEMAN_OPTIONAL26_DETAIL_ITERATOR_HPP
#define BEMAN_OPTIONAL26_DETAIL_ITERATOR_HPP

#include <Beman/Optional26/detail/stl_interfaces/iterator_interface.hpp>

Expand All @@ -17,8 +17,8 @@ namespace beman::optional::detail {
// @tparam Container - The type of the container the iterator points to. This parameter exists solely so that different
// containers using this template can instantiate different types, even if the T parameter is the same.
template <class T, class Container>
struct contiguous_iterator : boost::stl_interfaces::iterator_interface<
#if !BOOST_STL_INTERFACES_USE_DEDUCED_THIS
struct contiguous_iterator : stl_interfaces::iterator_interface<
#if !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
contiguous_iterator<T, Container>,
#endif
std::contiguous_iterator_tag,
Expand Down Expand Up @@ -51,4 +51,4 @@ struct contiguous_iterator : boost::stl_interfaces::iterator_interface<

} // namespace beman::optional::detail

#endif // BEMAN_OPTIONAL26_OPTIONAL_DETAIL_ITERATOR_HPP
#endif // BEMAN_OPTIONAL26_DETAIL_ITERATOR_HPP
43 changes: 23 additions & 20 deletions include/Beman/Optional26/detail/stl_interfaces/config.hpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
// include/Beman/Optional26/detail/stl_interfaces/config.hpp -*-C++-*-

// Copyright (C) 2020 T. Zachary Laine
//
// 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
#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONFIG_HPP
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONFIG_HPP

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

#if defined(__cpp_lib_concepts) && defined(__cpp_lib_ranges) && !defined(BOOST_STL_INTERFACES_DISABLE_CONCEPTS)
#define BOOST_STL_INTERFACES_USE_CONCEPTS 1
#if defined(__cpp_lib_concepts) && defined(__cpp_lib_ranges) && \
!defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DISABLE_CONCEPTS)
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS 1
#else
#define BOOST_STL_INTERFACES_USE_CONCEPTS 0
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS 0
#endif

#if defined(__cpp_explicit_this_parameter) && BOOST_STL_INTERFACES_USE_CONCEPTS && \
!defined(BOOST_STL_INTERFACES_DISABLE_DEDUCED_THIS)
#define BOOST_STL_INTERFACES_USE_DEDUCED_THIS 1
#if defined(__cpp_explicit_this_parameter) && BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS && \
!defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DISABLE_DEDUCED_THIS)
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS 1
#else
#define BOOST_STL_INTERFACES_USE_DEDUCED_THIS 0
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS 0
#endif

// The inline namespaces v1, v2, and v3 represent C++14, C++20, and C++23 and
Expand All @@ -28,18 +31,18 @@
// multiple vI namespace alternatives exist. For example, some instances of
// the v1 namespace may still be inline, if there is no v2 version of its
// contents.
#if !BOOST_STL_INTERFACES_USE_CONCEPTS && !BOOST_STL_INTERFACES_USE_DEDUCED_THIS
#define BOOST_STL_INTERFACES_NAMESPACE_V1 inline namespace v1
#define BOOST_STL_INTERFACES_NAMESPACE_V2 namespace v2
#define BOOST_STL_INTERFACES_NAMESPACE_V3 namespace v3
#elif BOOST_STL_INTERFACES_USE_CONCEPTS && !BOOST_STL_INTERFACES_USE_DEDUCED_THIS
#define BOOST_STL_INTERFACES_NAMESPACE_V1 namespace v1
#define BOOST_STL_INTERFACES_NAMESPACE_V2 inline namespace v2
#define BOOST_STL_INTERFACES_NAMESPACE_V3 namespace v3
#if !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS && !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 inline namespace v1
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 namespace v3
#elif BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS && !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 inline namespace v2
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 namespace v3
#else
#define BOOST_STL_INTERFACES_NAMESPACE_V1 namespace v1
#define BOOST_STL_INTERFACES_NAMESPACE_V2 namespace v2
#define BOOST_STL_INTERFACES_NAMESPACE_V3 inline namespace v3
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 inline namespace v3
#endif

#endif
26 changes: 14 additions & 12 deletions include/Beman/Optional26/detail/stl_interfaces/fwd.hpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
// include/Beman/Optional26/detail/stl_interfaces/fwd.hpp -*-C++-*-

// Copyright (C) 2019 T. Zachary Laine
//
// 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 BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_FWD_HPP
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_FWD_HPP

#include <Beman/Optional26/detail/stl_interfaces/config.hpp>

#if BOOST_STL_INTERFACES_USE_CONCEPTS
#if BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
#include <ranges>
#endif
#if defined(__cpp_lib_three_way_comparison)
#include <compare>
#endif

#ifndef BOOST_STL_INTERFACES_DOXYGEN
#ifndef BEMAN_OPTIONAL26_DETAIL_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
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NO_HIDDEN_FRIEND_CONSTEXPR
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR
#else
#define BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR constexpr
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR constexpr
#endif

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

#endif

namespace boost {
namespace beman::optional::detail {
namespace stl_interfaces {

/** An enumeration used to indicate whether the underlying data have a
contiguous or discontiguous layout when instantiating `view_interface`
and `sequence_container_interface`. */
enum class element_layout : bool { discontiguous = false, contiguous = true };

BOOST_STL_INTERFACES_NAMESPACE_V1 {
BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {

namespace v1_dtl {
template <typename... T>
Expand Down Expand Up @@ -80,6 +82,6 @@ BOOST_STL_INTERFACES_NAMESPACE_V1 {
} // namespace v1_dtl
}
} // namespace stl_interfaces
} // namespace boost
} // namespace beman::optional::detail

#endif
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// include/Beman/Optional26/detail/stl_interfaces/iterator_interface.hpp -*-C++-*-

// Copyright (C) 2019 T. Zachary Laine
//
// 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 BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP

#include <Beman/Optional26/detail/stl_interfaces/fwd.hpp>

Expand All @@ -14,13 +16,13 @@
#include <compare>
#endif

namespace boost {
namespace beman::optional::detail {
namespace stl_interfaces {

/** A type for granting access to the private members of an iterator
derived from `iterator_interface`. */
struct access {
#ifndef BOOST_STL_INTERFACES_DOXYGEN
#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN

template <typename D>
static constexpr auto base(D& d) noexcept -> decltype(d.base_reference()) {
Expand All @@ -41,7 +43,7 @@ struct access {
this template implies a copy or move of the underlying object of type
`T`. */
template <typename T>
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_STL_INTERFACES_USE_CONCEPTS
#if defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
// clang-format off
requires std::is_object_v<T>
#endif
Expand Down Expand Up @@ -124,11 +126,11 @@ common_diff(T lhs, U rhs) noexcept(noexcept(static_cast<common_t<T, U>>(lhs) - s
} // namespace detail

} // namespace stl_interfaces
} // namespace boost
} // namespace beman::optional::detail

namespace boost {
namespace beman::optional::detail {
namespace stl_interfaces {
BOOST_STL_INTERFACES_NAMESPACE_V1 {
BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {

/** A CRTP template that one may derive from to make defining iterators
easier.
Expand All @@ -144,7 +146,7 @@ BOOST_STL_INTERFACES_NAMESPACE_V1 {
typename Reference = ValueType&,
typename Pointer = ValueType*,
typename DifferenceType = std::ptrdiff_t
#ifndef BOOST_STL_INTERFACES_DOXYGEN
#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
,
typename E = std::enable_if_t<std::is_class<Derived>::value &&
std::is_same<Derived, std::remove_cv_t<Derived>>::value>
Expand Down Expand Up @@ -184,13 +186,13 @@ BOOST_STL_INTERFACES_NAMESPACE_V1 {
typename Reference,
typename Pointer,
typename DifferenceType
#ifndef BOOST_STL_INTERFACES_DOXYGEN
#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
,
typename E
#endif
>
struct iterator_interface {
#ifndef BOOST_STL_INTERFACES_DOXYGEN
#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
private:
constexpr Derived& derived() noexcept { return static_cast<Derived&>(*this); }
constexpr const Derived& derived() const noexcept { return static_cast<const Derived&>(*this); }
Expand Down Expand Up @@ -276,7 +278,8 @@ BOOST_STL_INTERFACES_NAMESPACE_V1 {
retval += i;
return retval;
}
friend BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived operator+(difference_type i, Derived it) noexcept {
friend BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived operator+(difference_type i,
Derived it) noexcept {
return it + i;
}

Expand Down Expand Up @@ -316,7 +319,8 @@ BOOST_STL_INTERFACES_NAMESPACE_V1 {
return access::base(derived()) - access::base(other);
}

friend BOOST_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived operator-(Derived it, difference_type i) noexcept {
friend BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived
operator-(Derived it, difference_type i) noexcept {
Derived retval = it;
retval += -i;
return retval;
Expand Down Expand Up @@ -411,13 +415,13 @@ BOOST_STL_INTERFACES_NAMESPACE_V1 {
DifferenceType>;
}
} // namespace stl_interfaces
} // namespace boost
} // namespace beman::optional::detail

#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_STL_INTERFACES_USE_CONCEPTS
#if defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS

namespace boost {
namespace beman::optional::detail {
namespace stl_interfaces {
BOOST_STL_INTERFACES_NAMESPACE_V2 {
BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 {

namespace v2_dtl {
template <typename Iterator>
Expand Down Expand Up @@ -734,15 +738,15 @@ BOOST_STL_INTERFACES_NAMESPACE_V2 {
DifferenceType>;
}
} // namespace stl_interfaces
} // namespace boost
} // namespace beman::optional::detail

#endif

#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_STL_INTERFACES_USE_DEDUCED_THIS
#if defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS

namespace boost {
namespace beman::optional::detail {
namespace stl_interfaces {
BOOST_STL_INTERFACES_NAMESPACE_V3 {
BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 {

// clang-format off

Expand Down Expand Up @@ -923,57 +927,58 @@ BOOST_STL_INTERFACES_NAMESPACE_V3 {
iterator_interface<IteratorConcept, ValueType, Reference, proxy_arrow_result<Reference>, DifferenceType>;
}
} // namespace stl_interfaces
} // namespace boost
} // namespace beman::optional::detail

#endif

#ifdef BOOST_STL_INTERFACES_DOXYGEN
#ifdef BEMAN_OPTIONAL26_DETAIL_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,
For example: `BEMAN_OPTIONAL26_DETAIL_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)
#define BEMAN_OPTIONAL26_DETAIL_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,
For example: `BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS(my_iter,
std::input_iterator_tag, std::input_iterator, 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( \
#define BEMAN_OPTIONAL26_DETAIL_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) \
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(type, concept_name) \
static_assert(concept_name<type>, "");

#if BOOST_STL_INTERFACES_USE_CONCEPTS
#define BOOST_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name) \
BOOST_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(iter, concept_name)
#if BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name) \
BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(iter, concept_name)
#else
#define BOOST_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name)
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name)
#endif

#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>::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, ""); \
#define BEMAN_OPTIONAL26_DETAIL_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>::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, "");

#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( \
#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
iter, category, concept, value_type, reference, pointer, difference_type) \
BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
iter, category, value_type, reference, pointer, difference_type)
#endif

Expand Down

0 comments on commit f4eaa88

Please sign in to comment.