C++ Logo

std-proposals

Advanced search

Re: [std-proposals] attribute [[unevaluated]]

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 20 May 2025 15:13:14 +0100
On Tue, May 20, 2025 at 1:16 PM Frederick Virchanza Gotham wrote:
>
> declval<T >() - PRvalue
> declval<T&&>() - Xvalue
> delcval<T& >() - Lvalue
>
> Would that not have been better? Then we'd be able to use 'declval' to
> return an unmovable type -- that's if the compiler doesn't refuse to
> compile it.


On second though, I think we should have "std::prvalue" as follows. I
actually think it's worth writing a "micropaper" for std::prvalue.


    #include <type_traits> // remove_reference

    namespace std {
        template<typename T>
        consteval std::remove_reference_t<T> prvalue(void) noexcept; // no body
    }

    template<typename T>
    consteval decltype(auto) Func(void) noexcept
    {
        return std::prvalue<T>();
    }

    #include <mutex> // mutex

    int main(void)
    {
        typedef decltype(Func<std::mutex>()) MyMutexType;
    }

Received on 2025-05-20 14:13:27