Skip to content

Add modern API based on C++26 features #159

Description

@soroshsabz

ITNOA

There have been significant changes from C++03 to C++26 that fundamentally affect API design in C++.

Consequently, I propose designing a new API for program_options based on C++26 best practices.

Key modern C++ features we can leverage include:

  • Modules: For faster build times and cleaner library exposure.
  • Concepts: For improved template metaprogramming and clearer constraints.
  • Contracts: For more robust code and runtime/compile-time assertions.
  • std::optional: For a more declarative API when handling optional values.
  • std::variant & std::any: For type-safe, flexible option storage.
  • Structured Bindings: For a cleaner, more intuitive API when unpacking values.
  • std::span & std::string_view: For zero-copy, high-performance string and array views.
  • std::expected: For modern, expressive error handling instead of exceptions or return codes.
  • Compile-Time Reflection: For smarter, automatic type inference and a significantly cleaner API footprint.

To achieve this, we should redesign the public API in a C++26-native way and modernize the underlying codebase.

To make this actionable, I suggest the following roadmap:

  • Design the V2 API: Create a new, modern API namespace/module separate from the legacy API to maintain backward compatibility.
  • Modernize the Codebase: Migrate the internal implementation details to C++26.
  • Expose the C++26 API: Provide the new public-facing API for modern users.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions