Unified header for all C++20 concepts in common_system.
This header provides a single include point for all concepts defined in the common_system library. Including this header gives access to all concept definitions for compile-time type validation.
Available concept categories:
- Core concepts: Result/Optional type constraints (core.h)
- Callable concepts: Function and executor constraints (callable.h)
- Event concepts: Event bus type constraints (event.h)
- Service concepts: DI container constraints (service.h)
- Container concepts: Collection type constraints (container.h)
- Logger concepts: Logging interface constraints (logger.h)
- Monitoring concepts: Metric collection constraints (monitoring.h)
- Transport concepts: HTTP/UDP client constraints (transport.h)
Requirements:
- C++20 compiler with concepts support
- GCC 10+, Clang 10+, MSVC 2022+
Example usage:
template<Resultable R>
if (result.is_ok()) {
}
}
template<EventHandler<MyEvent> H>
uint64_t subscribe(H&& handler) {
return bus.subscribe<MyEvent>(std::forward<H>(handler));
}
Unified header for all C++20 concepts in common_system.
void process(const T &value)
C++20 concepts for compile-time type validation.
- See also
- core.h for Result/Optional concepts
-
callable.h for callable and executor concepts
-
event.h for event bus concepts
-
service.h for dependency injection concepts
-
container.h for container type concepts
-
logger.h for logging interface concepts
-
monitoring.h for metric collection concepts
-
transport.h for HTTP/UDP client concepts
Benefits of using concepts:
- Clearer error messages: Template errors are displayed as concept violations instead of hundreds of lines of SFINAE failures
- Self-documenting code: Concepts express type requirements explicitly
- Better IDE support: More accurate auto-completion and type hints
- Code simplification: Eliminates std::enable_if boilerplate
Migration from SFINAE:
template<typename F,
typename = std::enable_if_t<
std::is_invocable_v<F> &&
std::is_void_v<std::invoke_result_t<F>>>>
void execute_async(F&& func);
template<VoidCallable F>
void execute_async(F&& func);
Definition in file concepts.h.