ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
concepts.hpp File Reference

C++20 concepts, type traits, and SFINAE helpers for the threading library. More...

#include <chrono>
#include <functional>
#include <set>
#include <thread>
#include <type_traits>
#include <vector>
Include dependency graph for concepts.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  threadschedule::is_duration_impl< T, typename >
 SFINAE trait that detects std::chrono::duration types. More...
struct  threadschedule::is_duration_impl< T, std::void_t< typename T::rep, typename T::period > >
 SFINAE trait that detects std::chrono::duration types. More...
struct  threadschedule::is_thread_like< T >
 Type trait that identifies thread-like types. More...
struct  threadschedule::is_thread_like< std::thread >
 std::thread is a thread-like type. More...

Typedefs

template<typename T>
using threadschedule::enable_if_thread_callable_t = std::enable_if_t<std::is_invocable_v<T>, int>
 Helper type traits for thread operations.
template<typename T>
using threadschedule::enable_if_duration_t = std::enable_if_t<is_duration_impl<T>::value, int>

Variables

template<typename F, typename... Args>
constexpr bool threadschedule::ThreadCallable = std::is_invocable_v<F, Args...>
 Pre-C++20 fallback for ThreadCallable (constexpr bool).
template<typename T>
constexpr bool threadschedule::ThreadIdentifiable = std::is_same_v<decltype(std::declval<T>().get_id()), std::thread::id>
 Pre-C++20 fallback for ThreadIdentifiable (constexpr bool).
template<typename T>
constexpr bool threadschedule::Duration = is_duration_impl<T>::value
 Pre-C++20 fallback for Duration (constexpr bool).
template<typename T>
constexpr bool threadschedule::PriorityType = std::is_integral_v<T>
 Pre-C++20 fallback for PriorityType (constexpr bool).
template<typename T>
constexpr bool threadschedule::CPUSetType = std::is_same_v<T, std::vector<int>> || std::is_same_v<T, std::set<int>>
 Pre-C++20 fallback for CPUSetType (constexpr bool).
template<typename T>
constexpr bool threadschedule::is_thread_like_v = is_thread_like<T>::value
 Convenience variable template for is_thread_like.

Detailed Description

C++20 concepts, type traits, and SFINAE helpers for the threading library.

Provides compile-time constraints (ThreadCallable, ThreadIdentifiable, Duration, PriorityType, CPUSetType) used throughout the library to enforce correct template arguments. When C++20 concepts are unavailable, equivalent constexpr bool variables are defined as fallbacks.

Also defines the is_thread_like<T> trait hierarchy for generic thread handle dispatch.

Definition in file concepts.hpp.

Typedef Documentation

◆ enable_if_duration_t

template<typename T>
using threadschedule::enable_if_duration_t = std::enable_if_t<is_duration_impl<T>::value, int>

Definition at line 173 of file concepts.hpp.

◆ enable_if_thread_callable_t

template<typename T>
using threadschedule::enable_if_thread_callable_t = std::enable_if_t<std::is_invocable_v<T>, int>

Helper type traits for thread operations.

Definition at line 170 of file concepts.hpp.

Variable Documentation

◆ CPUSetType

template<typename T>
bool threadschedule::CPUSetType = std::is_same_v<T, std::vector<int>> || std::is_same_v<T, std::set<int>>
constexpr

Pre-C++20 fallback for CPUSetType (constexpr bool).

Definition at line 123 of file concepts.hpp.

◆ Duration

template<typename T>
bool threadschedule::Duration = is_duration_impl<T>::value
constexpr

Pre-C++20 fallback for Duration (constexpr bool).

Definition at line 115 of file concepts.hpp.

◆ is_thread_like_v

template<typename T>
bool threadschedule::is_thread_like_v = is_thread_like<T>::value
inlineconstexpr

Convenience variable template for is_thread_like.

Definition at line 164 of file concepts.hpp.

◆ PriorityType

template<typename T>
bool threadschedule::PriorityType = std::is_integral_v<T>
constexpr

Pre-C++20 fallback for PriorityType (constexpr bool).

Definition at line 119 of file concepts.hpp.

◆ ThreadCallable

template<typename F, typename... Args>
bool threadschedule::ThreadCallable = std::is_invocable_v<F, Args...>
constexpr

Pre-C++20 fallback for ThreadCallable (constexpr bool).

See also
ThreadCallable concept above.

Definition at line 107 of file concepts.hpp.

◆ ThreadIdentifiable

template<typename T>
bool threadschedule::ThreadIdentifiable = std::is_same_v<decltype(std::declval<T>().get_id()), std::thread::id>
constexpr

Pre-C++20 fallback for ThreadIdentifiable (constexpr bool).

Definition at line 111 of file concepts.hpp.