mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-28890 Workaround for upcoming /Zc:ternary
This workaround allows building MongoDB under Microsoft's upcoming compiler, with the `/Zc:ternary` option enabled. This option would be implied by the `/permissive-` option. The code fails to compile under this mode when using Microsoft's existing `std::list` implementation. This explicit cast can be removed once Microsoft's `std::list` stops using inheritance between const and modifiable iterators. The issue arises because the `?:` ternary operator requires an impossible conversion from a `const iterator &` to a `const_iterator &&` or a `const_iterator &`. This occurs because Microsoft's `std::list< ... >::iterator` inherits from `std::list< ... >::const_iterator`. Were the `const iterator &` non-constant (`iterator &`), this would work. Additionally, were the `const_iterator &` constant (`const const_iterator &`), this would also work. Closes #1147
This commit is contained in:
parent
57d1ad19ed
commit
918ac217df
@ -131,7 +131,10 @@ public:
|
||||
*/
|
||||
const_iterator cfind(const K& key) const {
|
||||
auto it = this->_map.find(key);
|
||||
return (it == this->_map.end()) ? this->end() : it->second;
|
||||
// TODO(SERVER-28890): Remove the function-style cast when MSVC's
|
||||
// `std::list< ... >::iterator` implementation doesn't conflict with their `/Zc:ternary`
|
||||
// flag support .
|
||||
return (it == this->_map.end()) ? this->end() : const_iterator(it->second);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user