Commit d95f40d6 authored by Dominik Charousset's avatar Dominik Charousset

Add constexpr constructors where possible

parent 8f328ae5
...@@ -28,7 +28,9 @@ namespace caf { ...@@ -28,7 +28,9 @@ namespace caf {
* Acts as wildcard expression in patterns. * Acts as wildcard expression in patterns.
*/ */
struct anything { struct anything {
// no content constexpr anything() {
// nop
}
}; };
/** /**
......
...@@ -28,50 +28,51 @@ namespace detail { ...@@ -28,50 +28,51 @@ namespace detail {
template <class T> template <class T>
struct boxed { struct boxed {
constexpr boxed() {
// nop
}
using type = detail::wrapped<T>; using type = detail::wrapped<T>;
}; };
template <class T> template <class T>
struct boxed<detail::wrapped<T>> { struct boxed<detail::wrapped<T>> {
constexpr boxed() {
// nop
}
using type = detail::wrapped<T>; using type = detail::wrapped<T>;
}; };
template <> template <>
struct boxed<anything> { struct boxed<anything> {
constexpr boxed() {
// nop
}
using type = anything; using type = anything;
}; };
template <class T> template <class T>
struct is_boxed { struct is_boxed {
static constexpr bool value = false; static constexpr bool value = false;
}; };
template <class T> template <class T>
struct is_boxed<detail::wrapped<T>> { struct is_boxed<detail::wrapped<T>> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template <class T> template <class T>
struct is_boxed<detail::wrapped<T>()> { struct is_boxed<detail::wrapped<T>()> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template <class T> template <class T>
struct is_boxed<detail::wrapped<T>(&)()> { struct is_boxed<detail::wrapped<T>(&)()> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template <class T> template <class T>
struct is_boxed<detail::wrapped<T>(*)()> { struct is_boxed<detail::wrapped<T>(*)()> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
} // namespace detail } // namespace detail
......
...@@ -25,11 +25,17 @@ namespace detail { ...@@ -25,11 +25,17 @@ namespace detail {
template <class T> template <class T>
struct wrapped { struct wrapped {
constexpr wrapped() {
// nop
}
using type = T; using type = T;
}; };
template <class T> template <class T>
struct wrapped<wrapped<T>> { struct wrapped<wrapped<T>> {
constexpr wrapped() {
// nop
}
using type = typename wrapped<T>::type; using type = typename wrapped<T>::type;
}; };
......
...@@ -22,7 +22,14 @@ ...@@ -22,7 +22,14 @@
namespace caf { namespace caf {
struct none_t { inline explicit operator bool() const { return false; } }; struct none_t {
constexpr none_t() {
// nop
}
constexpr explicit operator bool() const {
return false;
}
};
static constexpr none_t none = none_t{}; static constexpr none_t none = none_t{};
......
...@@ -92,7 +92,7 @@ constexpr typename detail::boxed<T>::type val() { ...@@ -92,7 +92,7 @@ constexpr typename detail::boxed<T>::type val() {
* of a given callback, must be the last argument to `on()`. * of a given callback, must be the last argument to `on()`.
*/ */
constexpr auto arg_match = typename detail::boxed<detail::arg_match_t>::type(); constexpr auto arg_match = detail::boxed<detail::arg_match_t>::type();
/** /**
* Generates function objects from a binary predicate and a value. * Generates function objects from a binary predicate and a value.
......
...@@ -141,7 +141,7 @@ class work_stealing { ...@@ -141,7 +141,7 @@ class work_stealing {
size_t steal_interval; size_t steal_interval;
std::chrono::microseconds sleep_duration; std::chrono::microseconds sleep_duration;
}; };
constexpr poll_strategy strategies[3] = { poll_strategy strategies[3] = {
// aggressive polling (100x) without sleep interval // aggressive polling (100x) without sleep interval
{100, 1, 10, std::chrono::microseconds{0}}, {100, 1, 10, std::chrono::microseconds{0}},
// moderate polling (500x) with 50 us sleep interval // moderate polling (500x) with 50 us sleep interval
......
...@@ -671,8 +671,8 @@ class utim_impl : public uniform_type_info_map { ...@@ -671,8 +671,8 @@ class utim_impl : public uniform_type_info_map {
using strvec = std::vector<std::string>; using strvec = std::vector<std::string>;
using builtin_types = using builtin_types =
typename tl_apply< tl_apply<
typename tl_map< tl_map<
sorted_builtin_types, sorted_builtin_types,
get_uti_impl get_uti_impl
>::type, >::type,
......
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