[CXX-2790] Replace inline namespace with using-declarations Created: 10/Nov/23  Updated: 19/Jan/24  Resolved: 04/Jan/24

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 3.10.0

Type: Task Priority: Unknown
Reporter: Ezra Chung Assignee: Ezra Chung
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-2745 Move interfaces into the ABI-stable n... Blocked
Epic Link: CXX ABI
Quarter: FY24Q3, FY24Q4

 Description   

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.



 Comments   
Comment by Githook User [ 19/Jan/24 ]

Author:

{'name': 'Ezra Chung', 'email': '88335979+eramongodb@users.noreply.github.com', 'username': 'eramongodb'}

Message: CXX-2790 Add changelog entry for inline namespace -> using-declaration refactor (#1084)
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/330fd8471a937ddcccb38d116e455449edccafc6

Comment by Githook User [ 04/Jan/24 ]

Author:

{'name': 'Ezra Chung', 'email': '88335979+eramongodb@users.noreply.github.com', 'username': 'eramongodb'}

Message: CXX-2790 Redeclare mongocxx::v_noabi as a non-inline namespace (#1070)

  • Redeclare mongocxx::v_noabi as a non-inline namespace
  • Fix additional root namespace references missing ABI namespace qualifier
Comment by Githook User [ 12/Dec/23 ]

Author:

{'name': 'Ezra Chung', 'email': '88335979+eramongodb@users.noreply.github.com', 'username': 'eramongodb'}

Message: CXX-2790 Redeclare bsoncxx::v_noabi as a non-inline namespace (#1066)

  • Remove reference to ABI namespace in examples
  • Refactor bsoncxx::v_noabi as a non-inline namespace
  • Add using-declarations to redeclare entities in root namespace
Generated at Wed Feb 07 22:07:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.