[vte] libc: glue: Implement swap for FD
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] libc: glue: Implement swap for FD
- Date: Wed, 27 May 2020 19:17:35 +0000 (UTC)
commit 18912ef4fee8179c9fd2340e8e072f88bc6eda94
Author: Christian Persch <chpe src gnome org>
Date: Wed May 27 21:17:04 2020 +0200
libc: glue: Implement swap for FD
src/libc-glue.hh | 7 +++++++
1 file changed, 7 insertions(+)
---
diff --git a/src/libc-glue.hh b/src/libc-glue.hh
index 1f4c46da..3e445513 100644
--- a/src/libc-glue.hh
+++ b/src/libc-glue.hh
@@ -92,6 +92,12 @@ public:
}
}
+ /* C++20 constexpr */ void swap(FD& other)
+ {
+ using std::swap;
+ swap(m_fd, other.m_fd);
+ }
+
private:
int m_fd{-1};
@@ -101,6 +107,7 @@ constexpr bool operator==(FD const& lhs, FD const& rhs) noexcept { return lhs.ge
constexpr bool operator==(FD const& lhs, int rhs) noexcept { return lhs.get() == rhs; }
constexpr bool operator!=(FD const& lhs, FD const& rhs) noexcept { return !(lhs == rhs); }
constexpr bool operator!=(FD const& lhs, int rhs) noexcept { return !(lhs == rhs); }
+/* C++20 constexpr */ inline void swap(FD& lhs, FD& rhs) noexcept { lhs.swap(rhs); }
/* FD convenience functions */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]