You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The below code compiles on windows with MSVC 2019, it appears to be using the implicit conversion operator and doing the equality comparison as a standard pointer comparison. On linux using g++11, the following code fails to compile and generates an error:
I have tried various c++ versions with -std:c++14,17,20 and /permissive- and none of these options seem to make the MS compiler fail or the g++ compiler pass.
The provided equality operator only seems to be effective when both inputs are gsl::not_null - given this state, I am wondering if it would make sense to make the equality operator a class member so that it isn't considered for all of the equality comparisons that don't involve not_null.
#include"gsl/gsl"
#include<iostream>
#include<memory>classTest
{
};
intmain()
{
auto test = newTest();
auto notNull = gsl::not_null<Test*>(test);
if (notNull == test)
{
std::cout << "not_null == Test*" << std::endl;
}
else
{
std::cout << "not_null != Test*" << std::endl;
}
return0;
}
The text was updated successfully, but these errors were encountered:
I had changes to templatize the implicit conversion operator see: #1187
The templatized implicit conversion operator seems to work, but for this equality to work with g++, the non-templatized implicit conversion operator is also needed.
The below code compiles on windows with MSVC 2019, it appears to be using the implicit conversion operator and doing the equality comparison as a standard pointer comparison. On linux using g++11, the following code fails to compile and generates an error:
I have tried various c++ versions with -std:c++14,17,20 and /permissive- and none of these options seem to make the MS compiler fail or the g++ compiler pass.
The provided equality operator only seems to be effective when both inputs are gsl::not_null - given this state, I am wondering if it would make sense to make the equality operator a class member so that it isn't considered for all of the equality comparisons that don't involve not_null.
The text was updated successfully, but these errors were encountered: