From: Amelia Coutard Date: Mon, 25 Dec 2023 00:40:21 +0000 (+0100) Subject: Ajout de declval X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=afbd82992ce0a2a9825a3c422b5f74cad91fa87a;p=voyage-au-centre-des-fichiers.git Ajout de declval --- diff --git a/libcpp/memory.hpp b/libcpp/memory.hpp index 40c38d5..2c01f93 100644 --- a/libcpp/memory.hpp +++ b/libcpp/memory.hpp @@ -17,7 +17,7 @@ // See the C++ documentation for documentation. -// Placement new and delete (taken from glibcxx, should be fine copyright-wise): +// Implementation for placement new and delete taken from glibcxx. [[nodiscard]] inline void* operator new(unsigned long, void* p) noexcept { return p; } @@ -29,7 +29,7 @@ inline void operator delete[](void*, void*) noexcept {} namespace amy { -// "Launder" taken from glibcxx, should be fine copyright-wise: +// Implementation for launder taken from glibcxx. template [[nodiscard]] constexpr T* launder(T* p) noexcept { return __builtin_launder(p); @@ -42,5 +42,9 @@ template constexpr size byte_size() { template constexpr size byte_align() { return alignof(T); } +// Implementation based on https://en.cppreference.com/w/cpp/utility/declval +template constexpr T&& declval() noexcept { + static_assert(false, "amy::declval cannot be used in an evaluated context."); +} } // namespace amy