Retire BOOST_STATIC_ASSERT in favor of static_assert
authorYedidya Feldblum <yfeldblum@fb.com>
Tue, 26 Apr 2016 07:56:27 +0000 (00:56 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Tue, 26 Apr 2016 08:05:36 +0000 (01:05 -0700)
Summary:
Retire `BOOST_STATIC_ASSERT` in favor of `static_assert`.

`static_assert` is part of C++ now, so we don't need workarounds like `BOOST_STATIC_ASSERT` anymore.

Partially automated:

    hg grep -lw BOOST_STATIC_ASSERT | xargs perl -pi -e 's~\bBOOST_STATIC_ASSERT\(([^;]*)\);~static_assert(\1, "");~g'
    hg grep -lw 'boost/static_assert.hpp' | xargs perl -pi -e 's,^#include <boost/static_assert\.hpp>\n,,gm'

Caught most instances. Formatting and remaining instances addressed manually.

Reviewed By: meyering

Differential Revision: D3215944

fb-gh-sync-id: f4552d5d9bfc416ce283923abe880437a4d0cba5
fbshipit-source-id: f4552d5d9bfc416ce283923abe880437a4d0cba5

folly/SocketAddress.cpp
folly/docs/FBVector.md
folly/docs/Traits.md
folly/io/async/EventBase.cpp
folly/stats/TimeseriesHistogram.h

index e9a9043b0daa61c5732d6c228db4f17263554bef..5f63d8e0420f83ad512bcd33dee95f7a0746301c 100644 (file)
@@ -23,7 +23,6 @@
 #include <folly/Hash.h>
 
 #include <boost/functional/hash.hpp>
-#include <boost/static_assert.hpp>
 #include <string.h>
 #include <stdio.h>
 #include <errno.h>
index 21edbe8f378c7ab86cca89a9c44aff8b99283ed6..3d1d4c10e791fb1f0db05f53de3030b40055ebf1 100644 (file)
@@ -202,7 +202,7 @@ after `Widget`'s definition and write this:
     }
 
 If you don't do this, `fbvector<Widget>` will fail to compile
-with a `BOOST_STATIC_ASSERT`.
+with a `static_assert`.
 
 #### Additional Constraints
 
@@ -215,9 +215,11 @@ already present in the C++ standard (well, currently in Boost).
 To summarize, in order to work with `fbvector`, a type `Widget`
 must pass:
 
-    BOOST_STATIC_ASSERT(
+    static_assert(
       IsRelocatable<Widget>::value &&
-      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
+      (boost::has_trivial_assign<T>::value ||
+       boost::has_nothrow_constructor<T>::value),
+      "");
 
 These traits go hand in hand; for example, it would be very
 difficult to design a class that satisfies one branch of the
index 8d1a0b296e42fffbc715bf76f3e0e913c81e8374..18359b1786d1573080a3304345117d26d9d8acbd 100644 (file)
@@ -127,9 +127,7 @@ explicitly, `fbvector<MySimpleType>` or `fbvector<MyParameterizedType>`
 will fail to compile due to assertion below:
 
 ```Cpp
-BOOST_STATIC_ASSERT(
-  IsRelocatable<My*Type>::value
-);
+static_assert(IsRelocatable<My*Type>::value, "");
 ```
 
 FOLLY_ASSUME_FBVECTOR_COMPATIBLE*(type) macros can be used to state that type 
index 4c11511d03896459097d3cd9cd789023ad018d9f..7f2d923952ae02db21121c92cddcff7aa2799f6d 100644 (file)
@@ -23,7 +23,6 @@
 #include <folly/ThreadName.h>
 #include <folly/io/async/NotificationQueue.h>
 
-#include <boost/static_assert.hpp>
 #include <condition_variable>
 #include <fcntl.h>
 #include <mutex>
index 2f3cc75f5bbbf6f9b72e832abef53ea772bf9545..4e7056a59777248e215cd7dbf6a7cd0e45137153 100644 (file)
@@ -17,7 +17,6 @@
 #pragma once
 
 #include <string>
-#include <boost/static_assert.hpp>
 #include <folly/stats/Histogram.h>
 #include <folly/stats/MultiLevelTimeSeries.h>
 
@@ -53,7 +52,7 @@ template <class T, class TT=std::chrono::seconds,
 class TimeseriesHistogram {
  private:
    // NOTE: T must be equivalent to _signed_ numeric type for our math.
-   BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_signed);
+   static_assert(std::numeric_limits<T>::is_signed, "");
 
  public:
   // values to be inserted into container