]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Ajout de declval
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Mon, 25 Dec 2023 00:40:21 +0000 (01:40 +0100)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Mon, 25 Dec 2023 00:40:21 +0000 (01:40 +0100)
libcpp/memory.hpp

index 40c38d5853c3e696f07800448f9b5778de92068e..2c01f93eca61d81234130994e465ac0f35e9e83a 100644 (file)
@@ -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 <typename T>
 [[nodiscard]] constexpr T* launder(T* p) noexcept {
        return __builtin_launder(p);
@@ -42,5 +42,9 @@ template <typename T> constexpr size byte_size() {
 template <typename T> constexpr size byte_align() {
        return alignof(T);
 }
+// Implementation based on https://en.cppreference.com/w/cpp/utility/declval
+template <typename T> constexpr T&& declval() noexcept {
+       static_assert(false, "amy::declval cannot be used in an evaluated context.");
+}
 
 } // namespace amy