Skip to content

Commit ec82518

Browse files
Fix MSVC compilation error.
The order of the conditions in enable_if_t matters since, in some cases, the compiler uses short circuit evaluation of the compile-time constant expressions to simplify the enable_if condition so that it no longer depends on the inputs and only depends on the template parameters of the class being constructed, which, then, causes an error since that isn't allowed.
1 parent 4e6fa04 commit ec82518

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

dynd/include/utility_functions.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class py_ref_tmpl {
144144
* Then:
145145
* Require that conversions from the other py_ref_tmpl type to this type be explcit.
146146
*/
147-
template <bool other_owns, bool other_not_null, typename std::enable_if_t<not_null && !other_not_null> * = nullptr>
147+
template <bool other_owns, bool other_not_null, typename std::enable_if_t<!other_not_null && not_null> * = nullptr>
148148
explicit py_ref_tmpl(const py_ref_tmpl<other_owns, other_not_null> &other) noexcept
149149
{
150150
o = other.o;
@@ -161,7 +161,7 @@ class py_ref_tmpl {
161161
* Then:
162162
* a move operation can be implicitly performed.
163163
*/
164-
template <bool other_not_null, typename std::enable_if_t<owns_ref && (other_not_null || !not_null)> * = nullptr>
164+
template <bool other_not_null, typename std::enable_if_t<(other_not_null || !not_null) && owns_ref> * = nullptr>
165165
py_ref_tmpl(py_ref_tmpl<true, other_not_null> &&other) noexcept
166166
{
167167
o = other.o;
@@ -173,7 +173,7 @@ class py_ref_tmpl {
173173
* Then:
174174
* only an explicit move operation can be performed.
175175
*/
176-
template <bool other_not_null, typename std::enable_if_t<owns_ref && !other_not_null && not_null> * = nullptr>
176+
template <bool other_not_null, typename std::enable_if_t<!other_not_null && not_null && owns_ref> * = nullptr>
177177
explicit py_ref_tmpl(py_ref_tmpl<true, other_not_null> &&other) noexcept
178178
{
179179
o = other.o;
@@ -216,7 +216,7 @@ class py_ref_tmpl {
216216
* Allow assignment from the other py_ref_tmpl type to this type.
217217
*/
218218
template <bool other_owns, bool other_not_null,
219-
typename std::enable_if_t<!not_null || (not_null && other_not_null)> * = nullptr>
219+
typename std::enable_if_t<(other_not_null && not_null) || !not_null> * = nullptr>
220220
py_ref_tmpl<owns_ref, not_null> operator=(const py_ref_tmpl<other_owns, other_not_null> &other) noexcept
221221
{
222222
decref_if_owned<owns_ref, not_null>(o);

0 commit comments

Comments
 (0)