Commit 5f78f71a authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 8

Use decltype rather than typeof

Summary: Because `typeof` is a GCC specific extension whose standardized version is called `decltype`.

Reviewed By: yfeldblum

Differential Revision: D3506960

fbshipit-source-id: 0e7495028632b23f149bf8d0163d2000ebec2fcc
parent ef12daa2
...@@ -159,7 +159,7 @@ TEST_F(FileUtilTest, read) { ...@@ -159,7 +159,7 @@ TEST_F(FileUtilTest, read) {
for (auto& p : readers_) { for (auto& p : readers_) {
std::string out(in_.size(), '\0'); std::string out(in_.size(), '\0');
EXPECT_EQ(p.first, wrapFull(p.second, 0, &out[0], out.size())); EXPECT_EQ(p.first, wrapFull(p.second, 0, &out[0], out.size()));
if (p.first != (typeof(p.first))(-1)) { if (p.first != (decltype(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), out.substr(0, p.first)); EXPECT_EQ(in_.substr(0, p.first), out.substr(0, p.first));
} }
} }
...@@ -169,7 +169,7 @@ TEST_F(FileUtilTest, pread) { ...@@ -169,7 +169,7 @@ TEST_F(FileUtilTest, pread) {
for (auto& p : readers_) { for (auto& p : readers_) {
std::string out(in_.size(), '\0'); std::string out(in_.size(), '\0');
EXPECT_EQ(p.first, wrapFull(p.second, 0, &out[0], out.size(), off_t(42))); EXPECT_EQ(p.first, wrapFull(p.second, 0, &out[0], out.size(), off_t(42)));
if (p.first != (typeof(p.first))(-1)) { if (p.first != (decltype(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), out.substr(0, p.first)); EXPECT_EQ(in_.substr(0, p.first), out.substr(0, p.first));
} }
} }
...@@ -230,7 +230,7 @@ TEST_F(FileUtilTest, readv) { ...@@ -230,7 +230,7 @@ TEST_F(FileUtilTest, readv) {
auto iov = buf.iov(); auto iov = buf.iov();
EXPECT_EQ(p.first, wrapvFull(p.second, 0, iov.data(), iov.size())); EXPECT_EQ(p.first, wrapvFull(p.second, 0, iov.data(), iov.size()));
if (p.first != (typeof(p.first))(-1)) { if (p.first != (decltype(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), buf.join().substr(0, p.first)); EXPECT_EQ(in_.substr(0, p.first), buf.join().substr(0, p.first));
} }
} }
...@@ -258,7 +258,7 @@ TEST_F(FileUtilTest, preadv) { ...@@ -258,7 +258,7 @@ TEST_F(FileUtilTest, preadv) {
auto iov = buf.iov(); auto iov = buf.iov();
EXPECT_EQ(p.first, EXPECT_EQ(p.first,
wrapvFull(p.second, 0, iov.data(), iov.size(), off_t(42))); wrapvFull(p.second, 0, iov.data(), iov.size(), off_t(42)));
if (p.first != (typeof(p.first))(-1)) { if (p.first != (decltype(p.first))(-1)) {
EXPECT_EQ(in_.substr(0, p.first), buf.join().substr(0, p.first)); EXPECT_EQ(in_.substr(0, p.first), buf.join().substr(0, p.first));
} }
} }
......
...@@ -85,7 +85,7 @@ TEST(ThreadLocalPtr, CustomDeleterOwnershipTransfer) { ...@@ -85,7 +85,7 @@ TEST(ThreadLocalPtr, CustomDeleterOwnershipTransfer) {
auto deleter = [](Widget* ptr) { auto deleter = [](Widget* ptr) {
Widget::customDeleter(ptr, TLPDestructionMode::THIS_THREAD); Widget::customDeleter(ptr, TLPDestructionMode::THIS_THREAD);
}; };
std::unique_ptr<Widget, typeof(deleter)> source(new Widget(), deleter); std::unique_ptr<Widget, decltype(deleter)> source(new Widget(), deleter);
std::thread([&w, &source]() { std::thread([&w, &source]() {
w.reset(std::move(source)); w.reset(std::move(source));
w.get()->val_ += 10; w.get()->val_ += 10;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment