Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
core.h File Reference

Core C++20 concepts for Result/Optional types. More...

#include <concepts>
#include <type_traits>
#include <functional>
Include dependency graph for core.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  kcenon
 
namespace  kcenon::common
 Core interfaces.
 
namespace  kcenon::common::concepts
 C++20 concepts for compile-time type validation.
 

Concepts

concept  kcenon::common::concepts::Resultable
 A type that can contain either a value or an error.
 
concept  kcenon::common::concepts::Unwrappable
 A type that supports value extraction (unwrapping).
 
concept  kcenon::common::concepts::Mappable
 A type that supports monadic map operations.
 
concept  kcenon::common::concepts::Chainable
 A type that supports monadic chaining (flatMap/and_then).
 
concept  kcenon::common::concepts::MonadicResult
 A complete Result-like type with all monadic operations.
 
concept  kcenon::common::concepts::OptionalLike
 A type that represents an optional value (present or absent).
 
concept  kcenon::common::concepts::ErrorInfo
 A type that contains error information.
 
concept  kcenon::common::concepts::ValueOrError
 A type that holds either a value or error information.
 

Detailed Description

Core C++20 concepts for Result/Optional types.

This header provides fundamental concepts for types that support error handling patterns similar to Rust's Result and Option types. These concepts enable compile-time validation with clear error messages.

Requirements:

  • C++20 compiler with concepts support
  • GCC 10+, Clang 10+, MSVC 2022+

Thread Safety:

  • Concepts are evaluated at compile-time only.
  • No runtime thread-safety considerations apply.
See also
result.h for Result<T> implementation
https://en.cppreference.com/w/cpp/language/constraints

Definition in file core.h.