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

Adopting bsoncxx::stdx polyfills into mongocxx::stdx namespace is confusing

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0-rc0
    • Affects Version/s: None
    • Component/s: API
    • Labels:
      None

      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 {
                ^
      

            Assignee:
            isabella.siu@mongodb.com Isabella Siu (Inactive)
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: