1414#include < sstream>
1515
1616#if defined(CATCH_CONFIG_NEW_CAPTURE)
17+ #include < catch2/internal/catch_move_and_forward.hpp>
1718 #include < system_error>
1819 #if defined(_MSC_VER)
1920 #include < fcntl.h> // _O_TEXT
@@ -67,7 +68,7 @@ inline void close_or_throw(int descriptor)
6768{
6869 if (close (descriptor))
6970 {
70- throw std::system_error{ errno, std::generic_category () } ;
71+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
7172 }
7273}
7374
@@ -77,7 +78,7 @@ inline int dup_or_throw(int descriptor)
7778
7879 if (result == -1 )
7980 {
80- throw std::system_error{ errno, std::generic_category () } ;
81+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
8182 }
8283
8384 return result;
@@ -89,7 +90,7 @@ inline int dup2_or_throw(int sourceDescriptor, int destinationDescriptor)
8990
9091 if (result == -1 )
9192 {
92- throw std::system_error{ errno, std::generic_category () } ;
93+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
9394 }
9495
9596 return result;
@@ -101,7 +102,7 @@ inline int fileno_or_throw(std::FILE* file)
101102
102103 if (result == -1 )
103104 {
104- throw std::system_error{ errno, std::generic_category () } ;
105+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
105106 }
106107
107108 return result;
@@ -119,7 +120,7 @@ inline void pipe_or_throw(int descriptors[2])
119120
120121 if (result)
121122 {
122- throw std::system_error{ errno, std::generic_category () } ;
123+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
123124 }
124125}
125126
@@ -133,7 +134,7 @@ inline size_t read_or_throw(int descriptor, void* buffer, size_t size)
133134
134135 if (result == -1 )
135136 {
136- throw std::system_error{ errno, std::generic_category () } ;
137+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
137138 }
138139
139140 return static_cast <size_t >(result);
@@ -143,14 +144,14 @@ inline void fflush_or_throw(std::FILE* file)
143144{
144145 if (std::fflush (file))
145146 {
146- throw std::system_error{ errno, std::generic_category () } ;
147+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
147148 }
148149}
149150
150151jthread::jthread () noexcept : m_thread{} {}
151152
152153template <typename F, typename ... Args>
153- jthread::jthread (F&& f, Args&&... args) : m_thread{ std::forward <F>(f), std::forward <Args>(args)... } {}
154+ jthread::jthread (F&& f, Args&&... args) : m_thread{ CATCH_FORWARD <F>(f), CATCH_FORWARD <Args>(args)... } {}
154155
155156// Not exactly like std::jthread, but close enough for the code below.
156157jthread::~jthread () noexcept
@@ -237,8 +238,8 @@ OutputFileRedirector::OutputFileRedirector(FILE* file, std::string& result) :
237238
238239 // Anonymous pipes have a limited buffer and require an active reader to ensure the writer does not become blocked.
239240 // Use a separate thread to ensure the buffer does not get stuck full.
240- m_readThread = jthread{ [readDescriptor{ std::move (readDescriptor) }, &result] () mutable {
241- read_thread (std::move (readDescriptor), result); } };
241+ m_readThread = jthread{ [readDescriptor{ CATCH_MOVE (readDescriptor) }, &result] () mutable {
242+ read_thread (CATCH_MOVE (readDescriptor), result); } };
242243
243244 dup2_or_throw (writeDescriptor.get (), m_fd);
244245}
0 commit comments