Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/header_graph.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ flowchart BT
concepts(<a href="https://github.com/intel/cpp-std-extensions/tree/main/include/stdx/concepts.hpp">concepts.hpp</a>)
concepts --> type_traits
udls(<a href="https://github.com/intel/cpp-std-extensions/tree/main/include/stdx/udls.hpp">udls.hpp</a>)
udls --> type_traits
function_traits(<a href="https://github.com/intel/cpp-std-extensions/tree/main/include/stdx/function_traits.hpp">function_traits.hpp</a>)
function_traits --> type_traits

Expand Down
1 change: 0 additions & 1 deletion docs/type_traits.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ contains a few things from the standard:
* https://en.cppreference.com/w/cpp/types/is_constant_evaluated[`is_constant_evaluated`] (from C++20)
* https://en.cppreference.com/w/cpp/types/is_function[`is_function_v`] (implemented with Walter Brown's method)
* https://en.cppreference.com/w/cpp/types/is_scoped_enum[`is_scoped_enum_v`] (from C++23)
* https://en.cppreference.com/w/cpp/types/remove_cvref[`remove_cvref_t`] (from C++20)
* https://en.cppreference.com/w/cpp/utility/to_underlying[`to_underlying`] (from C++23)
* https://en.cppreference.com/w/cpp/types/type_identity[`type_identity`] (from C++20)

Expand Down
4 changes: 2 additions & 2 deletions include/stdx/byterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ template <typename T> class byterator {
}

template <typename V>
requires std::is_trivially_copyable_v<remove_cvref_t<V>>
requires std::is_trivially_copyable_v<std::remove_cvref_t<V>>
auto write(V &&v) -> void {
using R = remove_cvref_t<V>;
using R = std::remove_cvref_t<V>;
std::memcpy(ptr, std::addressof(v), sizeof(R));
advance<R>();
}
Expand Down
3 changes: 1 addition & 2 deletions include/stdx/cached.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <stdx/compiler.hpp>
#include <stdx/latched.hpp>
#include <stdx/type_traits.hpp>

namespace stdx {
inline namespace v1 {
Expand All @@ -17,7 +16,7 @@ template <typename F> struct cached : latched<F> {
}
};

template <typename F> cached(F) -> cached<remove_cvref_t<F>>;
template <typename F> cached(F) -> cached<std::remove_cvref_t<F>>;

template <typename C> using cached_value_t = latched_value_t<C>;
} // namespace v1
Expand Down
4 changes: 2 additions & 2 deletions include/stdx/call_by_need.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ constexpr auto call_by_need(Fs &&fs, Args &&args) {
std::forward<Fs>(fs)))...>::
template compute_call_info<decltype(get<Js>(
std::forward<Args>(args)))...>();
}(std::make_index_sequence<tuple_size_v<remove_cvref_t<Fs>>>{},
std::make_index_sequence<tuple_size_v<remove_cvref_t<Args>>>{});
}(std::make_index_sequence<tuple_size_v<std::remove_cvref_t<Fs>>>{},
std::make_index_sequence<tuple_size_v<std::remove_cvref_t<Args>>>{});

auto new_fs = [&]<std::size_t... Is>(std::index_sequence<Is...>) {
return tuple{get<Is>(std::forward<Fs>(fs))...,
Expand Down
6 changes: 4 additions & 2 deletions include/stdx/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ template <typename T, typename... Us>
constexpr auto same_none = not same_any<T, Us...>;

template <typename T, typename U>
concept same_as_unqualified = same_as<remove_cvref_t<T>, remove_cvref_t<U>>;
concept same_as_unqualified =
same_as<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;

template <typename T>
concept equality_comparable = requires(T const &t) {
Expand Down Expand Up @@ -137,7 +138,8 @@ template <typename T, template <typename> typename TypeTrait>
concept has_trait = TypeTrait<T>::value;

template <typename T, typename U>
concept same_as_unqualified = same_as<remove_cvref_t<T>, remove_cvref_t<U>>;
concept same_as_unqualified =
same_as<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;

template <typename T>
concept structural = is_structural_v<T>;
Expand Down
4 changes: 2 additions & 2 deletions include/stdx/function_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ template <typename F, typename = void> struct detect_call_operator {
};
template <typename F>
struct detect_call_operator<
F, std::void_t<decltype(&remove_cvref_t<F>::operator())>>
: function_traits<decltype(&remove_cvref_t<F>::operator())> {};
F, std::void_t<decltype(&std::remove_cvref_t<F>::operator())>>
: function_traits<decltype(&std::remove_cvref_t<F>::operator())> {};

template <typename F> struct function_traits : detect_call_operator<F> {};
} // namespace detail
Expand Down
4 changes: 2 additions & 2 deletions include/stdx/functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct bind_front_t<F, std::index_sequence<Is...>, BoundArgs...> {

template <typename F, typename... Args>
constexpr auto bind_front(F &&f, Args &&...args) {
return detail::bind_front_t<stdx::remove_cvref_t<F>,
return detail::bind_front_t<std::remove_cvref_t<F>,
std::make_index_sequence<sizeof...(Args)>,
std::decay_t<Args>...>{
std::forward<F>(f), {std::forward<Args>(args)...}};
Expand Down Expand Up @@ -112,7 +112,7 @@ struct bind_back_t<F, std::index_sequence<Is...>, BoundArgs...> {

template <typename F, typename... Args>
constexpr auto bind_back(F &&f, Args &&...args) {
return detail::bind_back_t<stdx::remove_cvref_t<F>,
return detail::bind_back_t<std::remove_cvref_t<F>,
std::make_index_sequence<sizeof...(Args)>,
std::decay_t<Args>...>{
std::forward<F>(f), {std::forward<Args>(args)...}};
Expand Down
4 changes: 2 additions & 2 deletions include/stdx/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace stdx {
inline namespace v1 {
namespace detail {
template <typename T> struct ct_capacity_fail {
static_assert(always_false_v<stdx::remove_cvref_t<T>>,
static_assert(always_false_v<std::remove_cvref_t<T>>,
"Type does not support compile-time capacity");
};
} // namespace detail
Expand All @@ -31,7 +31,7 @@ template <typename T> constexpr auto ct_capacity_v<T const> = ct_capacity_v<T>;

template <typename T>
consteval auto ct_capacity([[maybe_unused]] T &&) -> std::size_t {
return ct_capacity_v<remove_cvref_t<T>>;
return ct_capacity_v<std::remove_cvref_t<T>>;
}

template <typename T = int, typename = std::enable_if_t<std::is_integral_v<T>>>
Expand Down
4 changes: 2 additions & 2 deletions include/stdx/latched.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace stdx {
inline namespace v1 {
template <typename F> struct latched {
using value_type = stdx::remove_cvref_t<std::invoke_result_t<F>>;
using value_type = std::remove_cvref_t<std::invoke_result_t<F>>;

constexpr explicit latched(F const &f) : lazy{f} {}
constexpr explicit latched(F &&f) : lazy{std::move(f)} {}
Expand Down Expand Up @@ -56,6 +56,6 @@ template <typename F> struct latched {
};

template <typename C>
using latched_value_t = typename stdx::remove_cvref_t<C>::value_type;
using latched_value_t = typename std::remove_cvref_t<C>::value_type;
} // namespace v1
} // namespace stdx
33 changes: 16 additions & 17 deletions include/stdx/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ struct unwrap_invoker<Func, L<Ts...>,

template <typename F, typename Arg>
constexpr auto unwrap_invoke(F &&f, Arg &&arg) {
return unwrap_invoker<stdx::remove_cvref_t<F>,
stdx::remove_cvref_t<Arg>>::invoke(std::forward<F>(f),
std::forward<Arg>(
arg));
return unwrap_invoker<std::remove_cvref_t<F>,
std::remove_cvref_t<Arg>>::invoke(std::forward<F>(f),
std::forward<Arg>(
arg));
}

template <typename F, typename Arg>
Expand All @@ -109,10 +109,9 @@ template <typename T, typename TS = tombstone_traits<T>> class optional {
: val{std::forward<Args>(args)...} {}

template <typename U = T>
requires(
std::is_constructible_v<T, U &&> and
not std::is_same_v<stdx::remove_cvref_t<U>, std::in_place_t> and
not std::is_same_v<stdx::remove_cvref_t<U>, optional>)
requires(std::is_constructible_v<T, U &&> and
not std::is_same_v<std::remove_cvref_t<U>, std::in_place_t> and
not std::is_same_v<std::remove_cvref_t<U>, optional>)
constexpr explicit optional(U &&u) : val{std::forward<U>(u)} {}

constexpr auto operator=(std::nullopt_t) -> optional & {
Expand All @@ -123,7 +122,7 @@ template <typename T, typename TS = tombstone_traits<T>> class optional {
template <typename U = T>
requires(std::is_constructible_v<T, U> and
std::is_assignable_v<T &, U> and
not std::is_same_v<stdx::remove_cvref_t<U>, optional> and
not std::is_same_v<std::remove_cvref_t<U>, optional> and
(std::is_scalar_v<T> or
not std::is_same_v<std::decay_t<U>, T>))
constexpr auto operator=(U &&u) -> optional & {
Expand Down Expand Up @@ -310,27 +309,27 @@ template <typename T> optional(T) -> optional<T>;
namespace detail {
template <typename T>
concept optional_like =
stdx::is_specialization_of_v<stdx::remove_cvref_t<T>, optional> or
stdx::is_specialization_of_v<stdx::remove_cvref_t<T>, std::optional>;
stdx::is_specialization_of_v<std::remove_cvref_t<T>, optional> or
stdx::is_specialization_of_v<std::remove_cvref_t<T>, std::optional>;

template <typename R, typename... Ts,
typename = std::enable_if_t<
(... and stdx::is_specialization_of_v<stdx::remove_cvref_t<Ts>,
optional>)>>
typename = std::enable_if_t<(
... and
stdx::is_specialization_of_v<std::remove_cvref_t<Ts>, optional>)>>
auto convert_optional(Ts const &...) -> optional<R>;
template <typename R, typename... Ts,
typename = std::enable_if_t<
(... and stdx::is_specialization_of_v<stdx::remove_cvref_t<Ts>,
(... and stdx::is_specialization_of_v<std::remove_cvref_t<Ts>,
std::optional>)>>
auto convert_optional(Ts const &...) -> std::optional<R>;
} // namespace detail

template <typename F, detail::optional_like... Ts>
constexpr auto transform(F &&f, Ts &&...ts) {
using func_t = stdx::remove_cvref_t<F>;
using func_t = std::remove_cvref_t<F>;
using R = std::invoke_result_t<
func_t,
forward_like_t<Ts, typename stdx::remove_cvref_t<Ts>::value_type>...>;
forward_like_t<Ts, typename std::remove_cvref_t<Ts>::value_type>...>;
using O = decltype(detail::convert_optional<R>(ts...));
if ((... and ts.has_value())) {
return O{with_result_of{[&] {
Expand Down
2 changes: 1 addition & 1 deletion include/stdx/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class span : public detail::span_base<T, Extent> {

public:
using element_type = T;
using value_type = stdx::remove_cvref_t<T>;
using value_type = std::remove_cvref_t<T>;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using pointer = T *;
Expand Down
2 changes: 1 addition & 1 deletion include/stdx/tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ template <typename T>
concept tuple_comparable = requires { typename T::common_tuple_comparable; };

template <typename T>
concept tuplelike = requires { typename remove_cvref_t<T>::is_tuple; };
concept tuplelike = requires { typename std::remove_cvref_t<T>::is_tuple; };

template <std::size_t I, typename T> struct tuple_element;

Expand Down
6 changes: 3 additions & 3 deletions include/stdx/tuple_algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ constexpr auto contains_type =
template <template <typename> typename Proj = std::type_identity_t,
tuplelike Tuple>
[[nodiscard]] constexpr auto sort(Tuple &&t) {
using T = stdx::remove_cvref_t<Tuple>;
using T = std::remove_cvref_t<Tuple>;
constexpr auto indices = detail::sorted_indices<T, Proj>();
return [&]<std::size_t... Is>(std::index_sequence<Is...>) {
return stdx::tuple<tuple_element_t<indices[Is], T>...>{
Expand Down Expand Up @@ -344,7 +344,7 @@ template <template <typename> typename Proj = std::type_identity_t,
[&]<std::size_t... Js>(std::index_sequence<Js...>) {
constexpr auto offset = chunks[Is].offset;
return stdx::tuple<tuple_element_t<
offset + Js, stdx::remove_cvref_t<Tuple>>...>{
offset + Js, std::remove_cvref_t<Tuple>>...>{
std::forward<Tuple>(t)[index<offset + Js>]...};
}(std::make_index_sequence<chunks[Is].size>{})...);
}(std::make_index_sequence<chunks.size()>{});
Expand Down Expand Up @@ -409,7 +409,7 @@ template <tuplelike T> constexpr auto to_sorted_set(T &&t) {
}

template <tuplelike Tuple> constexpr auto to_unsorted_set(Tuple &&t) {
using T = stdx::remove_cvref_t<Tuple>;
using T = std::remove_cvref_t<Tuple>;
using U = boost::mp11::mp_unique<T>;
return [&]<std::size_t... Is>(std::index_sequence<Is...>) {
return U{get<boost::mp11::mp_find<T, tuple_element_t<Is, U>>::value>(
Expand Down
9 changes: 2 additions & 7 deletions include/stdx/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ template <typename E> constexpr auto to_underlying(E e) noexcept {
template <typename E>
using underlying_type_t = decltype(to_underlying(std::declval<E>()));

template <typename T> struct remove_cvref {
using type = std::remove_cv_t<std::remove_reference_t<T>>;
};
template <typename T> using remove_cvref_t = typename remove_cvref<T>::type;

namespace detail {
template <bool> struct conditional;

Expand Down Expand Up @@ -54,7 +49,7 @@ struct call_base {

template <typename, bool> struct callable_test : call_base {};
template <typename F>
struct callable_test<F, true> : remove_cvref_t<F>, call_base {};
struct callable_test<F, true> : std::remove_cvref_t<F>, call_base {};

template <typename F, typename = void> constexpr auto is_func_obj = true;
template <typename F>
Expand Down Expand Up @@ -189,7 +184,7 @@ constexpr static auto apply_sequence = detail::apply_sequence_t<L>{};

template <typename T, typename U>
constexpr bool is_same_unqualified_v =
std::is_same_v<remove_cvref_t<T>, remove_cvref_t<U>>;
std::is_same_v<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;

namespace detail {
template <typename T> struct any_t;
Expand Down
6 changes: 1 addition & 5 deletions include/stdx/udls.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once

#include <stdx/compiler.hpp>
#include <stdx/type_traits.hpp>

#include <cstddef>
#include <cstdint>
#include <type_traits>
Expand Down Expand Up @@ -41,8 +38,7 @@ consteval auto maybe_add_digit(Sum s) {

template <auto Base, char... Cs> struct raw_parser {
template <typename T> consteval static auto parse() {
using U = decltype(stdx::to_underlying(std::declval<T>()));
auto x = U{};
auto x = T{};
Comment thread
mjcaisse-intel marked this conversation as resolved.
((x = maybe_add_digit<Base, Cs>(x)), ...);
return T{x};
}
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ add_tests(
pp_map
priority
ranges
remove_cvref
rollover
span
to_underlying
Expand Down
4 changes: 2 additions & 2 deletions test/call_by_need.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ template <auto V> constexpr auto arg = arg_t<V>{};

template <auto V1, auto V2>
constexpr auto operator==(arg_t<V1>, arg_t<V2>) -> bool {
if constexpr (std::is_same_v<stdx::remove_cvref_t<decltype(V1)>,
stdx::remove_cvref_t<decltype(V2)>>) {
if constexpr (std::is_same_v<std::remove_cvref_t<decltype(V1)>,
std::remove_cvref_t<decltype(V2)>>) {
return V1 == V2;
}
return false;
Expand Down
14 changes: 0 additions & 14 deletions test/remove_cvref.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion test/span.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEMPLATE_TEST_CASE("span exposes types", "[span]", std::uint8_t,
using S = stdx::span<TestType>;
STATIC_REQUIRE(std::is_same_v<typename S::element_type, TestType>);
STATIC_REQUIRE(
std::is_same_v<typename S::value_type, stdx::remove_cvref_t<TestType>>);
std::is_same_v<typename S::value_type, std::remove_cvref_t<TestType>>);
STATIC_REQUIRE(std::is_same_v<typename S::size_type, std::size_t>);
STATIC_REQUIRE(std::is_same_v<typename S::difference_type, std::ptrdiff_t>);
STATIC_REQUIRE(std::is_same_v<typename S::pointer, TestType *>);
Expand Down