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

Consolidated core types for Result<T> pattern. More...

#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <variant>
#include <kcenon/common/utils/source_location.h>
#include <kcenon/common/error/error_category.h>
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.

Classes

struct  kcenon::common::error_info
 Standard error information used by Result<T>. More...
 
class  kcenon::common::Result< T >
 Result type for error handling with member function support. More...
 
class  kcenon::common::Optional< T >
 Optional type similar to std::optional with Rust-like API. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::common
 Core interfaces.
 

Typedefs

using kcenon::common::VoidResult = Result<std::monostate>
 Specialized Result for void operations.
 

Enumerations

enum class  kcenon::common::result_state {
  kcenon::common::uninitialized , kcenon::common::ok , kcenon::common::error , kcenon::common::uninitialized ,
  kcenon::common::ok , kcenon::common::error
}
 Result state enum for tracking initialization. More...
 

Functions

template<typename T >
Optional< T > kcenon::common::Some (T value)
 Create an Optional with value.
 
template<typename T >
Optional< T > kcenon::common::None ()
 Create an empty Optional.
 

Detailed Description

Consolidated core types for Result<T> pattern.

This header consolidates the core Result pattern types:

  • Forward declarations and common types
  • error_info struct for error representation
  • Result<T> class for exception-free error handling
  • Optional<T> class with Rust-like API

This consolidation reduces header count from 4 to 1, preparing for C++20 module migration while following Kent Beck's "Fewest Elements" principle.

Thread Safety:

  • Result<T> objects are NOT thread-safe for concurrent modification.
  • Multiple threads may safely read the same Result<T> if no thread modifies it.
  • If sharing Result<T> across threads, users must provide synchronization.
  • Best practice: Use Result<T> as return values; avoid shared mutable access.

Definition in file core.h.