I wanted to try writing a template wrapper that checks whether a class has a member function. and for this it was necessary to use std::declval
template<typename T>
struct has_member<T, void_t<decltype(std::declval<T>().push_back())>>:std::true_type{};
As I saw, the implementation of declval should be like this:
template<typename T>
T&& declval() noexcept;
And actually, it may be a odd question ,but why does declval have no return statement ?
If I understand correctly, it should return rvalue to the place of its call:
template<typename T>
struct has_member<T, void_t<decltype(T&&.push_back())>>:std::true_type{};
But we don't use return in the implementation . Maybe it's because we don't have a function body?I would like to understand why this is possible. I would be happy to help