system/FileDescriptor: use std::exchange()
This commit is contained in:
parent
31bad5f7af
commit
8c832f4c50
|
@ -33,6 +33,8 @@
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -75,11 +77,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int Steal() noexcept {
|
int Steal() noexcept {
|
||||||
assert(IsDefined());
|
return std::exchange(fd, -1);
|
||||||
|
|
||||||
int _fd = fd;
|
|
||||||
fd = -1;
|
|
||||||
return _fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUndefined() noexcept {
|
void SetUndefined() noexcept {
|
||||||
|
|
Loading…
Reference in New Issue