Use `_Abs` and `_Copysign` instead of branching on `x < 0`, correctly treating negative zero as a negative number. This matters when branch cuts of a complex function lies on the real or the imaginary axis, where the results for positive zero and negative zero are different.
For negative real number `x`, `pow(x - 0i, y)` and `pow(x + 0i, y)` are different:
```
pow(x - 0i, y) = exp(y * log(x - 0i)) = exp(y * (log(|x|) - πi))
pow(x + 0i, y) = exp(y * log(x + 0i)) = exp(y * (log(|x|) + πi))
```
Thus `pow(complex, real)` can't simply return `_Pow(real, real)` when the imaginary part of the base is negative zero.
Also modifies `pow(complex, complex)` to be consistent with `pow(real, complex)` when the base is a positive real number.
* Library support for C++20 coroutines
Implements most of <coroutine>. Usefulness of this header is dependent
on a compatible compiler (e.g. Visual Studio 2019 16.8 Preview 1 or
later) that defines `__cpp_impl_coroutine`. With such a compiler
this header exposes the coroutine library support in the `std` namespace
without the need for an `/await` switch.
This implementation is not yet complete:
- noop coroutines are not yet implemented
- symmetric transfer is not yet implemented
The value of `__cpp_lib_coroutine` is defined to a value less than the
Standard-mandated value to represent the incomplete feature.
Co-authored-by: Daniel Marshall <xandan@gmail.com>
* Rework test_range/test_iterator Ranges test machinery
These were previously compile-only tools intended for instantiation tests, but they can now adapt a contiguous sequence of elements into a range with specified properties for runtime testing. Nest in namespace `test` as `test::range` and `test::iterator`. Add `test::sentinel` to use with `test::iterator` to make non-`common_range`s. `test::iterator` and `test::range` now enforce valid combinations of parameters instead of silently ignoring inconsistencies. `test::iterator`/`test::sentinel` now have "wrapped" and "unwrapped" variations to test use of unwrapping machinery in the Range algorithms. `move_only_range` is now a special case of `test::range`. Adds new test `std/P0896R4_ranges_test_machinery` for this stuff since it's getting complicated.
* Unnest test::proxy_iterator so wrapped and unwrapped proxy iterators can have the same reference type
* More refinement:
* flesh out `proxy_reference`
* make element type configurable in instantiation machinery
* give `test::iterator` proper moves
* tiny bit of test coverage
* Name some bools
Resolves#539.
Co-authored-by: Alex Guteniev <gutenev@gmail.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Per [readable.traits], `indirectly_readable_traits<T>::value_type` is the same type as `remove_cv_t<T::value_type>` if it denotes an object type, or `remove_cv_t<T::element_type>` if it denotes an object type. If both `T::value_type` and `T::element_type` denote types, `indirectly_readable_traits<T>::value_type` is ill-formed. This was perhaps not the best design, given that there are iterators in the wild (Boost's unordered containers) that define both nested types. `indirectly_readable_traits` should tolerate iterators that define both nested types consistently.
Fixes VSO-1121031.