system/FileDescriptor: use std::exchange()

This commit is contained in:
Max Kellermann 2017-08-10 09:55:11 +02:00
parent 31bad5f7af
commit 8c832f4c50
1 changed files with 3 additions and 5 deletions

View File

@ -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 {