Skip to content

Commit

Permalink
tagged rework (#110)
Browse files Browse the repository at this point in the history
* Implement ericniebler/stl2#299
* Implement ericniebler/stl2#363
* Implement ericniebler/stl2#364
* Implement ericniebler/stl2#418
* Remove tuple_find that was dropped from variant ages ago
* Implement extension 'structible object concepts
* tighten up constrains in the tagged impl
  • Loading branch information
CaseyCarter authored Jul 2, 2017
1 parent 05911a9 commit 0ea9903
Show file tree
Hide file tree
Showing 17 changed files with 221 additions and 211 deletions.
18 changes: 18 additions & 0 deletions include/stl2/detail/concepts/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ STL2_OPEN_NAMESPACE {


namespace ext {
///////////////////////////////////////////////////////////////////////////
// 'structible object concepts
//
template <class T>
concept bool DestructibleObject = Object<T> && Destructible<T>;

template <class T, class... Args>
concept bool ConstructibleObject = Object<T> && Constructible<T, Args...>;

template <class T>
concept bool DefaultConstructibleObject = Object<T> && DefaultConstructible<T>;

template <class T>
concept bool MoveConstructibleObject = Object<T> && MoveConstructible<T>;

template <class T>
concept bool CopyConstructibleObject = Object<T> && CopyConstructible<T>;

///////////////////////////////////////////////////////////////////////////
// TriviallyFoo concepts
//
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/concepts/object/movable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ STL2_OPEN_NAMESPACE {
// https://github.com/ericniebler/stl2/issues/310
template <class T>
concept bool Movable =
_Is<T, is_object> &&
ext::Object<T> &&
MoveConstructible<T> &&
Assignable<T&, T&&> &&
Swappable<T>;
Expand All @@ -36,7 +36,7 @@ STL2_OPEN_NAMESPACE {
constexpr bool Movable = false;
__stl2::Movable{T}
constexpr bool Movable<T> = true;
}
} // namespace models
} STL2_CLOSE_NAMESPACE

#endif
17 changes: 16 additions & 1 deletion include/stl2/detail/concepts/object/move_constructible.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
#include <stl2/detail/concepts/core.hpp>

STL2_OPEN_NAMESPACE {
///////////////////////////////////////////////////////////////////////////
// Object [Extension]
//
namespace ext {
template <class T>
concept bool Object = _Is<T, std::is_object>;
} // namespace ext

namespace models {
template <class>
constexpr bool Object = false;
__stl2::ext::Object{T}
constexpr bool Object<T> = true;
} // namespace models

///////////////////////////////////////////////////////////////////////////
// Addressable [Extension]
//
Expand All @@ -34,7 +49,7 @@ STL2_OPEN_NAMESPACE {
namespace ext {
template <class T>
concept bool Addressable =
_Is<T, is_object> && __addressable<T>;
Object<T> && __addressable<T>;
}

namespace models {
Expand Down
8 changes: 3 additions & 5 deletions include/stl2/detail/ebo_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

STL2_OPEN_NAMESPACE {
namespace detail {
template <Destructible T, class Tag = void>
requires std::is_object<T>::value
template <ext::DestructibleObject T, class Tag = void>
struct ebo_box {
ebo_box() = default;
constexpr ebo_box(const T& t)
Expand Down Expand Up @@ -58,9 +57,8 @@ STL2_OPEN_NAMESPACE {
T item_;
};

template <Destructible T, class Tag>
requires std::is_object<T>::value &&
std::is_empty<T>::value && !std::is_final<T>::value
template <ext::DestructibleObject T, class Tag>
requires std::is_empty<T>::value && !std::is_final<T>::value
struct ebo_box<T, Tag> : private T {
ebo_box() = default;
constexpr ebo_box(const T& t)
Expand Down
5 changes: 3 additions & 2 deletions include/stl2/detail/functional/invoke.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stl2/detail/fwd.hpp>
#include <stl2/detail/meta.hpp>
#include <stl2/detail/concepts/core.hpp>
#include <stl2/detail/concepts/object.hpp>

STL2_OPEN_NAMESPACE {
///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -61,10 +62,10 @@ STL2_OPEN_NAMESPACE {
(coerce<T>(std::forward<T1>(t1)).*f)(std::forward<Args>(args)...)
)

template <_Is<is_object> D, class T, class T1>
template <ext::Object D, class T, class T1>
constexpr decltype(auto) impl(D (T::*f), T1&& t1) = delete;

template <_Is<is_object> D, class T, class T1>
template <ext::Object D, class T, class T1>
requires
requires(D (T::*f), T1&& t1) {
coerce<T>(std::forward<T1>(t1)).*f;
Expand Down
17 changes: 13 additions & 4 deletions include/stl2/detail/iterator/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ STL2_OPEN_NAMESPACE {
template <class>
struct value_type {};

template <class T>
struct value_type<T*> :
meta::lazy::if_<is_object<T>, remove_cv_t<T>> {};
template <ext::Object T>
struct value_type<T*> {
using type = std::remove_cv_t<T>;
};

template <_Is<is_array> T>
struct value_type<T> : value_type<decay_t<T>> {};
Expand All @@ -135,13 +136,21 @@ STL2_OPEN_NAMESPACE {
struct value_type<I const> : value_type<decay_t<I>> {};

template <detail::MemberValueType T>
struct value_type<T> {};

template <detail::MemberValueType T>
requires ext::Object<typename T::value_type>
struct value_type<T> {
using type = typename T::value_type;
};

template <detail::MemberElementType T>
struct value_type<T> {};

template <detail::MemberElementType T>
requires ext::Object<std::remove_cv_t<typename T::element_type>>
struct value_type<T> {
using type = typename T::element_type;
using type = std::remove_cv_t<typename T::element_type>;
};

///////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 4 additions & 3 deletions include/stl2/detail/iterator/increment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ STL2_OPEN_NAMESPACE {

template <class> struct difference_type {};

template <class T>
struct difference_type<T*>
: meta::lazy::if_<std::is_object<T>, std::ptrdiff_t> {};
template <ext::Object T>
struct difference_type<T*> {
using type = std::ptrdiff_t;
};

template <class T>
struct difference_type<const T>
Expand Down
3 changes: 1 addition & 2 deletions include/stl2/detail/semiregular_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

STL2_OPEN_NAMESPACE {
namespace detail {
template <Destructible T>
requires _Is<T, is_object>
template <ext::DestructibleObject T>
class semiregular_box {
public:
semiregular_box() = default;
Expand Down
Loading

0 comments on commit 0ea9903

Please sign in to comment.