14
14
#include < sstream>
15
15
16
16
#if defined(CATCH_CONFIG_NEW_CAPTURE)
17
+ #include < catch2/internal/catch_move_and_forward.hpp>
17
18
#include < system_error>
18
19
#if defined(_MSC_VER)
19
20
#include < fcntl.h> // _O_TEXT
@@ -67,7 +68,7 @@ inline void close_or_throw(int descriptor)
67
68
{
68
69
if (close (descriptor))
69
70
{
70
- throw std::system_error{ errno, std::generic_category () } ;
71
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
71
72
}
72
73
}
73
74
@@ -77,7 +78,7 @@ inline int dup_or_throw(int descriptor)
77
78
78
79
if (result == -1 )
79
80
{
80
- throw std::system_error{ errno, std::generic_category () } ;
81
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
81
82
}
82
83
83
84
return result;
@@ -89,7 +90,7 @@ inline int dup2_or_throw(int sourceDescriptor, int destinationDescriptor)
89
90
90
91
if (result == -1 )
91
92
{
92
- throw std::system_error{ errno, std::generic_category () } ;
93
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
93
94
}
94
95
95
96
return result;
@@ -101,7 +102,7 @@ inline int fileno_or_throw(std::FILE* file)
101
102
102
103
if (result == -1 )
103
104
{
104
- throw std::system_error{ errno, std::generic_category () } ;
105
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
105
106
}
106
107
107
108
return result;
@@ -119,7 +120,7 @@ inline void pipe_or_throw(int descriptors[2])
119
120
120
121
if (result)
121
122
{
122
- throw std::system_error{ errno, std::generic_category () } ;
123
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
123
124
}
124
125
}
125
126
@@ -133,7 +134,7 @@ inline size_t read_or_throw(int descriptor, void* buffer, size_t size)
133
134
134
135
if (result == -1 )
135
136
{
136
- throw std::system_error{ errno, std::generic_category () } ;
137
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
137
138
}
138
139
139
140
return static_cast <size_t >(result);
@@ -143,14 +144,14 @@ inline void fflush_or_throw(std::FILE* file)
143
144
{
144
145
if (std::fflush (file))
145
146
{
146
- throw std::system_error{ errno, std::generic_category () } ;
147
+ CATCH_SYSTEM_ERROR ( errno, std::generic_category ()) ;
147
148
}
148
149
}
149
150
150
151
jthread::jthread () noexcept : m_thread{} {}
151
152
152
153
template <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)... } {}
154
155
155
156
// Not exactly like std::jthread, but close enough for the code below.
156
157
jthread::~jthread () noexcept
@@ -237,8 +238,8 @@ OutputFileRedirector::OutputFileRedirector(FILE* file, std::string& result) :
237
238
238
239
// Anonymous pipes have a limited buffer and require an active reader to ensure the writer does not become blocked.
239
240
// 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); } };
242
243
243
244
dup2_or_throw (writeDescriptor.get (), m_fd);
244
245
}
0 commit comments