[CXX-1060] Adopting bsoncxx::stdx polyfills into mongocxx::stdx namespace is confusing Created: 01/Oct/16  Updated: 11/Aug/17  Resolved: 26/Jun/17

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: None
Fix Version/s: 3.2.0-rc0

Type: New Feature Priority: Major - P3
Reporter: J Rassi Assignee: Isabella Siu (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The fact that all bsoncxx::stdx polyfills are adopted into the mongocxx::stdx namespace is confusing. Users shouldn't need to figure out that the types in these namespaces are aliases for each other.

Furthermore, when using-directives for both the mongocxx and bsoncxx namespaces are in scope, then all unqualified references to 'stdx' are ambiguous and create compiler errors. Unfortunately, our mongocxx tests frequently declare using-directives for both of these namespaces, so we're in the same boat as these users.

Example compiler error when attempting to resolve the ambiguous type name stdx::string_view in a test:

/Users/rassi/work/mongo-cxx-driver/src/mongocxx/test/options/modify_collection.cpp:104:45: error: 'stdx' is not a class, namespace, or scoped
      enumeration
        REQUIRE(view_on.get_utf8().value == stdx::string_view("foo"));
                                            ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:8918:46: note: expanded from macro 'REQUIRE'
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
                                             ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:1478:31: note: expanded from macro 'INTERNAL_CATCH_TEST'
            ( __catchResult->*expr ).endExpression(); \
                              ^
/Users/rassi/work/mongo-cxx-driver/src/mongocxx/test/options/modify_collection.cpp:104:45: error: reference to 'stdx' is ambiguous
        REQUIRE(view_on.get_utf8().value == stdx::string_view("foo"));
                                            ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:8918:46: note: expanded from macro 'REQUIRE'
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
                                             ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:1478:31: note: expanded from macro 'INTERNAL_CATCH_TEST'
            ( __catchResult->*expr ).endExpression(); \
                              ^
/Users/rassi/work/mongo-cxx-driver/src/bsoncxx/stdx/optional.hpp:29:11: note: candidate found by name lookup is 'bsoncxx::v_noabi::stdx'
namespace stdx {
          ^
/Users/rassi/work/mongo-cxx-driver/src/mongocxx/stdx.hpp:21:11: note: candidate found by name lookup is 'mongocxx::v_noabi::stdx'
namespace stdx {
          ^
/Users/rassi/work/mongo-cxx-driver/src/mongocxx/test/options/modify_collection.cpp:104:45: error: 'stdx' is not a class, namespace, or scoped
      enumeration
        REQUIRE(view_on.get_utf8().value == stdx::string_view("foo"));
                                            ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:8918:46: note: expanded from macro 'REQUIRE'
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
                                             ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:1484:39: note: expanded from macro 'INTERNAL_CATCH_TEST'
    } while( Catch::isTrue( false && (expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
                                      ^
/Users/rassi/work/mongo-cxx-driver/src/mongocxx/test/options/modify_collection.cpp:104:45: error: reference to 'stdx' is ambiguous
        REQUIRE(view_on.get_utf8().value == stdx::string_view("foo"));
                                            ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:8918:46: note: expanded from macro 'REQUIRE'
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
                                             ^
/Users/rassi/work/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:1484:39: note: expanded from macro 'INTERNAL_CATCH_TEST'
    } while( Catch::isTrue( false && (expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
                                      ^
/Users/rassi/work/mongo-cxx-driver/src/bsoncxx/stdx/optional.hpp:29:11: note: candidate found by name lookup is 'bsoncxx::v_noabi::stdx'
namespace stdx {
          ^
/Users/rassi/work/mongo-cxx-driver/src/mongocxx/stdx.hpp:21:11: note: candidate found by name lookup is 'mongocxx::v_noabi::stdx'
namespace stdx {
          ^



 Comments   
Comment by Githook User [ 26/Jun/17 ]

Author:

{u'username': u'iwysiu', u'name': u'Isabella Siu', u'email': u'sakurablossom@blueblueworld.com'}

Message: CXX-1060 change all mongocxx::stdx into bsoncxx::stdx
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/211559f7324884d7125d5ec50ec33bade2b8e0b6

Comment by David Golden [ 07/Oct/16 ]

Proposal: switch from mongocxx::stdx to bsoncxx::stdx everywhere. Consider keeping alias for end-user compatibility or just remove alias and tell users to do a search/replace to fix it.

Generated at Wed Feb 07 22:01:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.