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 { ^
- related to
-
CXX-3160 Remove mongocxx::stdx namespace in favor of bsoncxx::stdx
- Closed