Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-2790

Replace inline namespace with using-declarations

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.10.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Inline namespaces do not permit per-symbol migration from ABI version vX to vY. Inline namespaces cannot be (re)declared inline in one context and non-inline in another context. This means future source-breaking-but-binary-compatible upgrades would require transitioning the entire inline ABI namespace from vX to vY, even if only a small selection of entities may motivate the upgrade.

      To allow for incremental source-breaking-but-binary-compatible upgrades on a per-symbol basis (e.g. upgrading bsoncxx::foo from bsoncxx::vX::foo to bsoncxx::vY::foo), remove inline from the v_noabi namespace and instead use using-declarations to declare entities in the root library namespaces.

      Current:

      namespace bsoncxx {
      inline namespace vX {
      
      void foo(); // bsoncxx::foo CANNOT be upgraded to vY...
      void bar();  // ... without forcibly upgrading bsoncxx::bar.
      
      }  // namespace vX
      }  // namespace bsoncxx
      
      namespace bsoncxx {
      namespace vY {
      
      void foo(); // A newer ABI-incompatible interface.
      
      }  // namespace vY
      }  // namespace bsoncxx
      

      Proposed:

      namespace bsoncxx {
      namespace vX {
      
      void foo();
      void bar();
      
      }  // namespace vX
      }  // namespace bsoncxx
      
      namespace bsoncxx {
      namespace vY {
      
      void foo(); // A newer ABI-incompatible interface.
      
      }  // namespace vY
      }  // namespace bsoncxx
      
      namespace bsoncxx {
      
      using bsoncxx::vY::foo; // bsoncxx::foo CAN be upgraded to vX...
      using bsoncxx::vX::bar; // ... without forcibly upgrading bsoncxx::bar.
      
      }  // namespace bsoncxx
      

      Changing inline namespace v_noabi into namespace v_noabi + using-declarations is a source-and-binary-compatible refactor and should not require an API major version bump.

            Assignee:
            ezra.chung@mongodb.com Ezra Chung
            Reporter:
            ezra.chung@mongodb.com Ezra Chung
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: