diff --git a/src/util/nop.hpp b/src/util/nop.hpp index 8315e93fbb467c7c3393656be79d09f372a76f66..6ec568b9d5fe9bfe4904b23ea6babcdf8b4ca84e 100644 --- a/src/util/nop.hpp +++ b/src/util/nop.hpp @@ -12,7 +12,7 @@ namespace nest { namespace mc { namespace util { -static struct nop_function_t { +struct nop_function_t { template <typename R, typename... Args> operator std::function<R (Args...)>() const { return [](Args...) { return R{}; }; @@ -22,7 +22,13 @@ static struct nop_function_t { operator std::function<void (Args...)>() const { return [](Args...) { }; } -} nop_function; + + // keep clang happy: see CWG issue #253, + // http://open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253 + constexpr nop_function_t() {} +}; + +static constexpr nop_function_t nop_function; } // namespace util } // namespace mc diff --git a/tests/unit/test_nop.cpp b/tests/unit/test_nop.cpp index cf131d9e5484503f2de5c34a73673a579534f98c..e3571ad827555e23040658f3f7275f3bcf53d9d0 100644 --- a/tests/unit/test_nop.cpp +++ b/tests/unit/test_nop.cpp @@ -3,7 +3,7 @@ using namespace nest::mc::util; -TEST(nop,void_fn) { +TEST(nop, void_fn) { std::function<void ()> f{nop_function}; EXPECT_TRUE(f); @@ -42,7 +42,7 @@ struct check_default { explicit check_default(int n): value(n) {} }; -TEST(nop,default_return_fn) { +TEST(nop, default_return_fn) { std::function<check_default ()> f{nop_function}; EXPECT_TRUE(f);