Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
concepts.h File Reference

C++20 concepts for database_system type validation. More...

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

Go to the source code of this file.

Namespaces

namespace  database
 
namespace  database::core
 
namespace  database::concepts
 

Concepts

concept  database::concepts::Invocable
 A callable type that can be invoked with given arguments.
 
concept  database::concepts::VoidCallable
 A callable type that returns void when invoked.
 
concept  database::concepts::ReturnsResult
 A callable type that returns a value convertible to the specified type.
 
concept  database::concepts::Predicate
 A callable type that returns a boolean value.
 
concept  database::concepts::NoexceptCallable
 A callable type that is marked noexcept.
 
concept  database::concepts::DelayedCallable
 A callable suitable for delayed execution.
 
concept  database::concepts::AsyncCallable
 A callable suitable for async execution.
 
concept  database::concepts::QueryCallback
 A callable that handles query results.
 
concept  database::concepts::ErrorHandler
 A callable that handles database errors.
 
concept  database::concepts::ConnectionFactory
 A callable that creates database connections.
 
concept  database::concepts::BackendFactory
 A callable that creates database backends.
 
concept  database::concepts::StreamEventHandler
 A callable that handles stream events.
 
concept  database::concepts::StreamEventFilter
 A callable that filters stream events.
 
concept  database::concepts::TransactionAction
 A callable that represents a transaction action.
 
concept  database::concepts::CompensationAction
 A callable that represents a compensation (rollback) action.
 
concept  database::concepts::PooledResource
 A type that can be managed by a pool.
 
concept  database::concepts::ConnectionWrapper
 A type that wraps a database connection.
 
concept  database::concepts::SubmittableTask
 A callable suitable for submission to an async executor.
 
concept  database::concepts::VoidTask
 A callable that returns void, suitable for fire-and-forget execution.
 

Detailed Description

C++20 concepts for database_system type validation.

This header provides C++20 concepts for compile-time type validation specific to database operations. It re-exports common_system concepts and adds database-specific concepts.

Available concept categories:

  • Callable concepts: From common_system (Invocable, VoidCallable, etc.)
  • Database concepts: QueryCallback, ConnectionFactory, etc.

Requirements:

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

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

Example usage:

using namespace database::concepts;
// Use callable concepts for async operations
template<Invocable F>
auto submit_task(F&& func) {
return executor.submit(std::forward<F>(func));
}
// Use database-specific concepts
template<QueryCallback<database_result> F>
void on_query_complete(F&& callback) {
// callback will be invoked with database_result
}
C++20 concepts for database_system type validation.

Definition in file concepts.h.