Skip to content

Commit

Permalink
fix(*): fixing msvc compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
c0nstexpr committed Apr 16, 2024
1 parent 63cdc34 commit 799b173
Show file tree
Hide file tree
Showing 49 changed files with 379 additions and 310 deletions.
1 change: 1 addition & 0 deletions include/stdsharp/array/array.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "../macros.h"
#include "../namespace_alias.h"

#include <algorithm>
#include <array>
Expand Down
3 changes: 2 additions & 1 deletion include/stdsharp/concepts/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ namespace stdsharp
};

template<typename T, typename U>
concept decay_derived = std::is_base_of_v<std::remove_reference_t<U>, std::remove_reference_t<T>>;
concept decay_derived =
std::is_base_of_v<std::remove_reference_t<U>, std::remove_reference_t<T>>;

template<typename T, typename U>
concept not_decay_derived = !decay_derived<T, U>;
Expand Down
15 changes: 9 additions & 6 deletions include/stdsharp/containers/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,16 @@ namespace stdsharp::details
using size_t = std::size_t;

template<typename... Optional>
static constexpr bool value = std::constructible_from<Container, Args..., Optional...> &&
[]<size_t... I>(const std::index_sequence<I...>) consteval {
return value<type_at<I, Optional...>...>;
}(std::make_index_sequence<sizeof...(Optional) - 1>{});
static constexpr bool value =
[]<size_t... I>(this const auto self, const std::index_sequence<I...>) consteval
{
constexpr auto count = sizeof...(I);
auto res = std::constructible_from<Container, Args..., type_at<I, Optional...>...>;

template<>
static constexpr bool value<> = std::constructible_from<Container, Args...>;
if constexpr(count > 0) res = res && self(std::make_index_sequence<count - 1>{});

return res;
}(std::make_index_sequence<sizeof...(Optional)>{});
};
}

Expand Down
3 changes: 2 additions & 1 deletion include/stdsharp/default_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ namespace stdsharp::default_operator
struct subscript
{
#if __cpp_multidimensional_subscript >= 202110L
[[nodiscard]] constexpr decltype(auto) operator[](this auto&& t, auto&& first_arg, auto&&... args)
[[nodiscard]] constexpr decltype(auto
) operator[](this auto&& t, auto&& first_arg, auto&&... args)
noexcept(noexcept(cpp_forward(t)[cpp_forward(first_arg)][cpp_forward(args)...]))
requires requires {
requires sizeof...(args) > 0;
Expand Down
2 changes: 2 additions & 0 deletions include/stdsharp/exception/exception.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "../namespace_alias.h"

#include <array>
#include <concepts>
#include <exception>
Expand Down
1 change: 1 addition & 0 deletions include/stdsharp/functional/always_return.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "../macros.h"
#include "../namespace_alias.h"

#include <functional>

Expand Down
1 change: 1 addition & 0 deletions include/stdsharp/functional/bind_front.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "../macros.h"
#include "../namespace_alias.h"

#include <functional>

Expand Down
2 changes: 1 addition & 1 deletion include/stdsharp/functional/empty_invoke.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "stdsharp/type_traits/object.h"
#include "../type_traits/object.h"

namespace stdsharp
{
Expand Down
14 changes: 7 additions & 7 deletions include/stdsharp/functional/forward_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ namespace stdsharp::details
}

template<typename T, std::constructible_from<T> U = std::remove_cvref_t<T>>
requires std::move_constructible<U>
static constexpr auto forward(T&& t)
static constexpr std::move_constructible auto forward(T&& t)
noexcept(nothrow_constructible_from<U, T> && nothrow_move_constructible<U>)
{
return U{cpp_forward(t)};
Expand All @@ -27,7 +26,8 @@ namespace stdsharp::details
template<typename T, typename ForwardT>
static constexpr decltype(auto) get_forwarded(ForwardT&& t) noexcept
{
if constexpr(std::same_as<T, std::remove_cvref_t<ForwardT>>) return cpp_forward(t);
if constexpr(std::same_as<std::remove_cvref_t<T>, std::remove_cvref_t<ForwardT>>)
return cpp_forward(t);
else return cpp_forward(t).get();
}

Expand Down Expand Up @@ -60,10 +60,10 @@ namespace stdsharp::details
template<
typename Self,
typename Seq = args_t::index_sequence,
auto ForwardCast = forward_cast<Self, binder, Impl>>
constexpr auto operator()(this Self&& self, auto&&... args)
noexcept(noexcept(ForwardCast(self).invoke(Seq{}, cpp_forward(args)...))) //
-> decltype(ForwardCast(self).invoke(Seq{}, cpp_forward(args)...))
auto ForwardCast = forward_cast<Self, Impl>>
constexpr decltype(auto) operator()(this Self&& self, auto&&... args)
noexcept(noexcept(ForwardCast(self).invoke(Seq{}, cpp_forward(args)...)))
requires requires { ForwardCast(self).invoke(Seq{}, cpp_forward(args)...); }
{
return ForwardCast(self).invoke(Seq{}, cpp_forward(args)...);
}
Expand Down
1 change: 1 addition & 0 deletions include/stdsharp/functional/functional.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include "pipeable.h"
#include "stdsharp/functional/always_return.h"
#include "stdsharp/functional/bind_front.h"
Expand Down
8 changes: 4 additions & 4 deletions include/stdsharp/functional/invocables.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ namespace stdsharp::details
template<std::size_t J, typename Self>
constexpr decltype(auto) get(this Self&& self) noexcept
{
return forward_cast<Self, invocables, indexed_value<J, type<J>>>(self).get();
return forward_cast<Self, invocables, indexed_invocable<J, type<J>>>(self).get();
}

template<std::size_t J, typename Self, typename SelfT = const Self>
constexpr decltype(auto) cget(this const Self&& self) noexcept
{
return forward_cast<SelfT, invocables, indexed_value<J, type<J>>>(self).cget();
return forward_cast<SelfT, invocables, indexed_invocable<J, type<J>>>(self).cget();
}

template<std::size_t J, typename Self, typename SelfT = const Self&>
constexpr forward_cast_t<SelfT, type<J>> cget(this const Self& self) noexcept
{
return forward_cast<SelfT, invocables, indexed_value<J, type<J>>>(self).cget();
return forward_cast<SelfT, invocables, indexed_invocable<J, type<J>>>(self).cget();
}
};
}
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace std
template<std::size_t I, typename... T>
struct tuple_element<I, ::stdsharp::invocables<T...>>
{
using type = ::stdsharp::invocables<T...>::template type<I>;
using type = typename ::stdsharp::invocables<T...>::template type<I>;
};
}

Expand Down
11 changes: 5 additions & 6 deletions include/stdsharp/functional/invoke.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#pragma once

#include "../macros.h"
#include "../namespace_alias.h"
#include "../concepts/object.h"

#include <functional>

namespace stdsharp
{
inline constexpr struct invoke_fn
{
constexpr auto operator()(auto&&... args) const
noexcept(noexcept(std::invoke(cpp_forward(args)...))) //
-> decltype(std::invoke(cpp_forward(args)...))
template<typename... Args, std::invocable<Args...> Fn>
constexpr decltype(auto) operator()(Fn&& fn, Args&&... args) const
noexcept(nothrow_invocable<Fn, Args...>)
{
return std::invoke(cpp_forward(args)...);
return std::invoke(cpp_forward(fn), cpp_forward(args)...);
}
} invoke{};
}
1 change: 1 addition & 0 deletions include/stdsharp/functional/invoke_r.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "../macros.h"
#include "../namespace_alias.h"

#include <functional>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion include/stdsharp/functional/sequenced_invocables.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace std
template<std::size_t I, typename... T>
struct tuple_element<I, ::stdsharp::sequenced_invocables<T...>>
{
using type = ::stdsharp::sequenced_invocables<T...>::template type<I>;
using type = typename ::stdsharp::sequenced_invocables<T...>::template type<I>;
};
}

Expand Down
34 changes: 19 additions & 15 deletions include/stdsharp/iterator/basic_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace stdsharp
using subscript::operator[];
using increase::operator++;
using increase::operator--;
using arithmetic::operator+;
using arithmetic::operator-;

constexpr auto& operator++(this auto& t) noexcept(noexcept(++t.data()))
requires requires { ++t.data(); }
Expand All @@ -34,20 +34,6 @@ namespace stdsharp
return t;
}

[[nodiscard]] constexpr auto operator<=>(this const auto& left, const auto& right)
noexcept(noexcept(left.data() <=> right.data()))
requires requires { left.data() <=> right.data(); }
{
return left.data() <=> right.data();
}

[[nodiscard]] constexpr auto operator==(this const auto& left, const auto& right)
noexcept(noexcept(left.data() == right.data()))
requires requires { left.data() == right.data(); }
{
return left.data() == right.data();
}

constexpr auto& operator+=(this auto& t, const difference_type<decltype(t)>& diff) noexcept
requires requires { t.data() += diff; }
{
Expand All @@ -71,6 +57,24 @@ namespace stdsharp
return left.data() - right.data();
}

[[nodiscard]] constexpr decltype(auto) operator<=>( //
this const auto& left,
decltype(left) right
) noexcept(noexcept(left.data() <=> right.data()))
requires requires { left.data() <=> right.data(); }
{
return left.data() <=> right.data();
}

[[nodiscard]] constexpr decltype(auto) operator==( //
this const auto& left,
decltype(left) right
) noexcept(noexcept(left.data() == right.data()))
requires requires { left.data() == right.data(); }
{
return left.data() == right.data();
}

private:
static constexpr void not_null(const nullable_pointer auto& ptr) noexcept
{
Expand Down
14 changes: 10 additions & 4 deletions include/stdsharp/memory/allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ namespace stdsharp::details
using allocation_result_base =
std::ranges::subrange<pointer, const_pointer, std::ranges::subrange_kind::sized>;

struct basic_allocation_result
{
using allocator_type = Alloc;
};

// NOLINTBEGIN(*-equals-default)
struct callocation_result : callocation_result_base
struct callocation_result : callocation_result_base, basic_allocation_result
{
using callocation_result_base::callocation_result_base;

Expand All @@ -32,7 +37,7 @@ namespace stdsharp::details
}
};

struct allocation_result : allocation_result_base
struct allocation_result : allocation_result_base, basic_allocation_result
{
using allocation_result_base::allocation_result_base;

Expand Down Expand Up @@ -109,8 +114,9 @@ namespace stdsharp::details
};

template<typename T, typename Alloc>
concept allocation_common = requires(const T& t) {
requires nothrow_copyable<std::decay_t<T>>;
concept allocation_common = requires(const T& t, std::remove_cvref_t<T> decay_t) {
requires nothrow_copyable<decltype(decay_t)>;
requires std::same_as<typename decltype(decay_t)::allocator_type, Alloc>;
requires std::ranges::sized_range<T>;
{ std::ranges::size(t) } -> std::same_as<allocator_size_type<Alloc>>;
};
Expand Down
Loading

0 comments on commit 799b173

Please sign in to comment.