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
4 changes: 3 additions & 1 deletion .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ CompileFlags:
- "-Wno-unknown-cuda-version"
- "--cuda-host-only"
- "--cuda-path=/usr/local/cuda-12"
Remove:
- "-x"
- "c++-header"

---

Expand All @@ -54,7 +57,6 @@ CompileFlags:
- "-ftemplate-backtrace-limit=0"
- "-std=c++20"
- "-DSTDEXEC_CLANGD_INVOKED"
- "-stdlib=libc++"
- "-Wno-unused-local-typedef"
Remove:
- "-stdpar*"
Expand Down
13 changes: 13 additions & 0 deletions include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,19 @@ namespace STDEXEC
# define STDEXEC_NO_STDCPP_EXPLICIT_THIS_PARAMETER() 1
#endif

#if defined(__cpp_rtti) && __cpp_rtti >= 1997'11L
# define STDEXEC_NO_STDCPP_RTTI() 0
#else
# define STDEXEC_NO_STDCPP_RTTI() 1
#endif

// MSVC always has typeid support, even when RTTI is disabled
#if STDEXEC_NO_STDCPP_RTTI() && !STDEXEC_MSVC()
# define STDEXEC_NO_STDCPP_TYPEID() 1
#else
# define STDEXEC_NO_STDCPP_TYPEID() 0
#endif

// Perhaps the stdlib lacks support for concepts
#if __has_include(<concepts>) && __cpp_lib_concepts >= 2020'02L
# define STDEXEC_NO_STDCPP_CONCEPTS_HEADER() 0
Expand Down
1 change: 1 addition & 0 deletions include/stdexec/__detail/__parallel_scheduler_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "__any_allocator.hpp"
#include "__optional.hpp"
#include "__queries.hpp"
#include "__schedulers.hpp"
#include "__typeinfo.hpp"

#include <exception>
Expand Down
55 changes: 49 additions & 6 deletions include/stdexec/__detail/__typeinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

#include <compare>
#include <string_view>
#include <typeinfo>

STDEXEC_PRAGMA_PUSH()
STDEXEC_PRAGMA_IGNORE_GNU("-Wunused-private-field")

//////////////////////////////////////////////////////////////////////////////////////////
// __type_info, __mtypeid, and __mtypeof
Expand All @@ -36,12 +40,14 @@ namespace STDEXEC
constexpr __type_info(__type_info &&) = delete;
constexpr __type_info &operator=(__type_info &&) = delete;

constexpr explicit __type_info(std::string_view __name) noexcept
constexpr explicit __type_info(std::string_view __name,
std::type_info const *__type = nullptr) noexcept
: __name_(__name)
, __type_(__type)
{}

[[nodiscard]]
constexpr std::string_view name() const noexcept
constexpr auto name() const noexcept -> std::string_view
{
return __name_;
}
Expand All @@ -52,17 +58,38 @@ namespace STDEXEC
return this == &__other || __name_ == __other.__name_;
}

constexpr auto
operator<=>(__type_info const &) const noexcept -> std::strong_ordering = default;
constexpr auto operator<=>(__type_info const &__other) const noexcept -> std::strong_ordering
{
return __name_ <=> __other.__name_;
}

#if !STDEXEC_NO_STDCPP_TYPEID()
[[nodiscard]]
constexpr auto type() const noexcept -> std::type_info const &
{
return *__type_;
}

[[nodiscard]]
constexpr operator std::type_info const &() const noexcept
{
return *__type_;
}
#endif

private:
std::string_view __name_;
std::string_view const __name_;
std::type_info const *const __type_ = nullptr; // used only if !STDEXEC_NO_STDCPP_TYPEID()
void const *const __reserved_ = nullptr; // reserved for future use
};

namespace __detail
{
template <class _Ty>
inline constexpr __type_info __mtypeid_v{__mnameof<_Ty>};
inline constexpr __type_info __mtypeid_v{
__mnameof<_Ty> //
STDEXEC_PP_WHEN(STDEXEC_PP_NOT(STDEXEC_NO_STDCPP_TYPEID()), , &typeid(_Ty)) //
};

template <class _Ty>
inline constexpr __type_info const &__mtypeid_v<_Ty const> = __mtypeid_v<_Ty>;
Expand Down Expand Up @@ -94,6 +121,20 @@ namespace STDEXEC
return *__info_ <=> *other.__info_;
}

#if !STDEXEC_NO_STDCPP_TYPEID()
[[nodiscard]]
constexpr auto type() const noexcept -> std::type_info const &
{
return (*__info_).type();
}

[[nodiscard]]
constexpr operator std::type_info const &() const noexcept
{
return (*__info_).type();
}
#endif

__type_info const *__info_;
};

Expand Down Expand Up @@ -139,3 +180,5 @@ namespace STDEXEC
// Sanity check:
static_assert(STDEXEC_IS_SAME(void, __mtypeof<__mtypeid<void>>));
} // namespace STDEXEC

STDEXEC_PRAGMA_POP()
2 changes: 1 addition & 1 deletion include/stdexec/__detail/__utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ namespace STDEXEC
static_assert(std::derived_from<__value_type, _CvInterface>,
"__polymorphic_downcast requires From to be a base class of To");

#if defined(__cpp_rtti) && __cpp_rtti >= 1997'11L
#if !STDEXEC_NO_STDCPP_RTTI()
STDEXEC_IF_NOT_CONSTEVAL
{
STDEXEC_ASSERT(dynamic_cast<__value_type*>(__from_ptr) != nullptr);
Expand Down
Loading