-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
Does the feature exist in the most recent commit?
AFAICT this feature is not contained in 85087857ad10bd407cd6ed2f52f7ea9752db621f which is currently the most recent commit.
Why do we need this feature?
Currently, StrEq(std::string_view{}) compiles but StrEq(std::wstring_view{}) does not. (note that the second call uses wstring_view)
Example on Compiler Explorer
Strictly speaking, this is rather a nuisance than a must-have feature, but the inconsistency is annoying at the very least.
Describe the proposal.
The simple fix would be to convert all wide string matchers to accept std::wstring_view instead of the current const std::wstring& str. This will support the aforementioned case and should also accept all cases that bound to const std::wstring &.
However, for narrow strings the implementation is more elaborate, allowing any single argument that can be used to construct a std::string:
gtest-matchers.h:808
template <typename T, typename = typename std::enable_if<
std::is_constructible<std::string, T>::value>::type>
using StringLike = T;
template <typename T = std::string>
PolymorphicMatcher<internal::StrEqualityMatcher<std::string>> StrEq(
const internal::StringLike<T>& str) {
return MakePolymorphicMatcher(
internal::StrEqualityMatcher<std::string>(std::string(str), true, true));
}
So probably, an anlogous implementation introducing a WStringLike type would be desired.
Is the feature specific to an operating system, compiler, or build system version?
This is standard C++17, but obviously, wstring is way more common on Windows.