| Issue |
169973
|
| Summary |
[libc++] Member types `argument_type`, `first_argument_type`, and `second_argument_type` of `reference_wrapper` are not correctly provided
|
| Labels |
libc++
|
| Assignees |
|
| Reporter |
frederick-vs-ja
|
It seems that libc++ hasn't implemented the rules in [N4659 [depr.func.adaptor.typedefs]/4.3](https://timsong-cpp.github.io/cppwp/n4659/depr.func.adaptor.typedefs#4.3) and [N4659 [depr.func.adaptor.typedefs]/5.3](https://timsong-cpp.github.io/cppwp/n4659/depr.func.adaptor.typedefs#5.3) at all.
Sometimes `argument_type`, `first_argument_type`, or `second_argument_type` are incorrectly provided due to inheritance form some base classes (`unary_function` and its friends) even if these names are shadowed in the derived class.
For some "normal" cases, these member types are basically missing when they were required to be provided.
Example ([link](https://godbolt.org/z/7o5fvh8va))
```C++
#include <functional>
#include <type_traits>
struct S1 {
using argument_type = void;
using first_argument_type = int() const;
using second_argument_type = char&&;
};
static_assert(std::is_same_v<std::reference_wrapper<S1>::argument_type, void>);
static_assert(std::is_same_v<std::reference_wrapper<S1>::first_argument_type, int() const>);
static_assert(std::is_same_v<std::reference_wrapper<S1>::second_argument_type, char&&>);
struct S2 : std::reference_wrapper<int(long)> {
static constexpr int argument_type = 1729;
};
template <class T, class = void>
constexpr bool has_no_argument_type = true;
template <class T>
constexpr bool has_no_argument_type<T, std::void_t<typename T::argument_type>> = false;
static_assert(has_no_argument_type<std::reference_wrapper<S2>>);
struct S3 : std::reference_wrapper<void(int&, int&&)> {
static constexpr int first_argument_type = 421;
static constexpr int second_argument_type = 729;
};
template <class T, class = void>
constexpr bool has_no_first_argument_type = true;
template <class T>
constexpr bool has_no_first_argument_type<T, std::void_t<typename T::first_argument_type>> = false;
template <class T, class = void>
constexpr bool has_no_second_argument_type = true;
template <class T>
constexpr bool has_no_second_argument_type<T, std::void_t<typename T::second_argument_type>> = false;
static_assert(has_no_first_argument_type<std::reference_wrapper<S3>>);
static_assert(has_no_second_argument_type<std::reference_wrapper<S3>>);
```
I'm not sure whether this is worth fixing because these member types were deprecated in C++17 and removed in C++20.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs