Cast lambda to function pointer for boost::split().
authorPeter Griess <pgriess@fb.com>
Thu, 26 Sep 2013 15:05:57 +0000 (10:05 -0500)
committerPeter Griess <pgriess@fb.com>
Tue, 15 Oct 2013 01:47:25 +0000 (18:47 -0700)
Summary:
- For some reason, Boost's internals aren't considering this lambda a
type that's castable. Cast it to a function pointer before using it.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac
- _bin/folly/test/string_test --benchmark

Reviewed By: alandau@fb.com

FB internal diff: D998594

folly/test/StringTest.cpp

index aac79a8ac89a1877d209e133801e1d561cbfef66..c48c4059c8d65b6cfee1350c8bd23d73eb42eece 100644 (file)
@@ -965,9 +965,10 @@ BENCHMARK(splitStrFixed, iters) {
 
 BENCHMARK(boost_splitOnSingleChar, iters) {
   static const std::string line = "one:two:three:four";
+  bool(*pred)(char) = [] (char c) -> bool { return c == ':'; };
   for (int i = 0; i < iters << 4; ++i) {
     std::vector<boost::iterator_range<std::string::const_iterator> > pieces;
-    boost::split(pieces, line, [] (char c) { return c == ':'; });
+    boost::split(pieces, line, pred);
   }
 }