Skip to content

feat(concepts): add C++20 concepts for logger, monitoring, and transport interfaces#247

Merged
kcenon merged 1 commit into
mainfrom
feature/cpp20-concepts-244
Dec 28, 2025
Merged

feat(concepts): add C++20 concepts for logger, monitoring, and transport interfaces#247
kcenon merged 1 commit into
mainfrom
feature/cpp20-concepts-244

Conversation

@kcenon

@kcenon kcenon commented Dec 28, 2025

Copy link
Copy Markdown
Owner

Summary

  • Add new C++20 concept definitions for compile-time type constraints on logger, monitoring, and transport interfaces
  • Fix VoidResult forward declaration conflict in callable.h
  • Comprehensive unit tests with static_assert compile-time validation

Changes

New Concept Files

concepts/logger.h

  • BasicLogger: Types with basic log functionality
  • LevelAwareLogger: Types supporting log level filtering
  • FlushableLogger: Types supporting flush operation
  • StructuredLogger: Types supporting structured log entries
  • LoggerLike: Complete ILogger interface constraint
  • LoggerProviderLike, LoggerRegistryLike: DI support concepts

concepts/monitoring.h

  • CounterMetric: Types supporting increment operations
  • GaugeMetric: Types supporting gauge operations
  • HistogramMetric: Types supporting histogram observations
  • TimingMetric: Types supporting timing measurements
  • MetricCollectorLike: Complete IMetricCollector constraint
  • MetricCollectorProviderLike: DI support concept

concepts/transport.h

  • HttpSender, HttpAvailabilityChecker: HTTP client concepts
  • HttpClientLike: Complete IHttpClient interface constraint
  • UdpConnectable, UdpSender, UdpConnectionStatus: UDP client concepts
  • UdpClientLike: Complete IUdpClient interface constraint
  • TransportClient: Generic transport client constraint (HTTP or UDP)

Bug Fixes

  • Fixed VoidResult forward declaration conflict in callable.h by including fwd.h instead

Documentation

  • Updated concepts.h umbrella header with new concept categories
  • Updated CHANGELOG.md with feature description

Benefits

  • Clearer error messages: Template errors show concept violations instead of SFINAE failures
  • Self-documenting code: Concepts express type requirements explicitly
  • Zero runtime overhead: All validation happens at compile-time
  • Better IDE support: More accurate auto-completion and type hints

Test plan

  • Build passes with CMake
  • All 11 concept tests pass (including static_assert compile-time validation)
  • Negative tests verify non-conforming types are rejected
  • Existing code continues to work (backward compatible)

Resolves: #244

…ort interfaces

Add new C++20 concept definitions for compile-time type constraints:

- concepts/logger.h: LoggerLike, BasicLogger, LevelAwareLogger, FlushableLogger,
  StructuredLogger, LoggerProviderLike, LoggerRegistryLike
- concepts/monitoring.h: MetricCollectorLike, CounterMetric, GaugeMetric,
  HistogramMetric, TimingMetric, MetricCollectorProviderLike
- concepts/transport.h: HttpClientLike, UdpClientLike, HttpSender,
  HttpAvailabilityChecker, UdpConnectable, UdpSender, UdpConnectionStatus,
  TransportClient, provider concepts

Updates:
- Fix VoidResult forward declaration conflict in callable.h by including fwd.h
- Update concepts.h umbrella header with new concept categories and documentation
- Add comprehensive unit tests with static_assert compile-time validation

Benefits:
- Clearer error messages for template constraint violations
- Self-documenting interface requirements
- Zero runtime overhead (compile-time only)
- Better IDE support for auto-completion

Resolves: #244
@kcenon kcenon merged commit 749ca3a into main Dec 28, 2025
20 checks passed
@kcenon kcenon deleted the feature/cpp20-concepts-244 branch December 28, 2025 10:41
kcenon added a commit that referenced this pull request Apr 13, 2026
…ort interfaces (#247)

Add new C++20 concept definitions for compile-time type constraints:

- concepts/logger.h: LoggerLike, BasicLogger, LevelAwareLogger, FlushableLogger,
  StructuredLogger, LoggerProviderLike, LoggerRegistryLike
- concepts/monitoring.h: MetricCollectorLike, CounterMetric, GaugeMetric,
  HistogramMetric, TimingMetric, MetricCollectorProviderLike
- concepts/transport.h: HttpClientLike, UdpClientLike, HttpSender,
  HttpAvailabilityChecker, UdpConnectable, UdpSender, UdpConnectionStatus,
  TransportClient, provider concepts

Updates:
- Fix VoidResult forward declaration conflict in callable.h by including fwd.h
- Update concepts.h umbrella header with new concept categories and documentation
- Add comprehensive unit tests with static_assert compile-time validation

Benefits:
- Clearer error messages for template constraint violations
- Self-documenting interface requirements
- Zero runtime overhead (compile-time only)
- Better IDE support for auto-completion

Resolves: #244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Adopt C++20 Concepts for interface type constraints

1 participant