Use decltype rather than typeof
authorChristopher Dykes <cdykes@fb.com>
Fri, 1 Jul 2016 01:20:26 +0000 (18:20 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Fri, 1 Jul 2016 01:24:14 +0000 (18:24 -0700)
Summary: Because `typeof` is a GCC specific extension whose standardized version is called `decltype`.

Reviewed By: yfeldblum

Differential Revision: D3506960

fbshipit-source-id: 0e7495028632b23f149bf8d0163d2000ebec2fcc

folly/test/FileUtilTest.cpp
folly/test/ThreadLocalTest.cpp

index 23a49f96faf1d4762bee91dc54f92a376f4c6bbf..d79dfd246d8f343bc24ca98ed334e234c32e9f6b 100644 (file)
@@ -159,7 +159,7 @@ TEST_F(FileUtilTest, read) {
   for (auto& p : readers_) {
     std::string out(in_.size(), '\0');
     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));
     }
   }
@@ -169,7 +169,7 @@ TEST_F(FileUtilTest, pread) {
   for (auto& p : readers_) {
     std::string out(in_.size(), '\0');
     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));
     }
   }
@@ -230,7 +230,7 @@ TEST_F(FileUtilTest, readv) {
 
     auto iov = buf.iov();
     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));
     }
   }
@@ -258,7 +258,7 @@ TEST_F(FileUtilTest, preadv) {
     auto iov = buf.iov();
     EXPECT_EQ(p.first,
               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));
     }
   }
index 230aaa3340119da0348712248465b8d7e8f1d5d0..aaa3794d452ab0f1523450a14219600a51a403b9 100644 (file)
@@ -85,7 +85,7 @@ TEST(ThreadLocalPtr, CustomDeleterOwnershipTransfer) {
     auto deleter = [](Widget* ptr) {
       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]() {
       w.reset(std::move(source));
       w.get()->val_ += 10;