File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/libpanda.x/i/panda/traits.h
Criterion Covered Total %
statement 2 2 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 2 2 100.0


line stmt bran cond sub pod time code
1             #pragma once
2             #include
3              
4             namespace panda {
5              
6             namespace detail {
7             template struct bool_pack {};
8             }
9              
10             /// bool_or returns its first argument converted to bool if it is possible, or default value (second arg) if type is not convertible to bool
11             template
12 13           inline bool bool_or (T&& val, decltype(bool(val))) {
13 13           return bool(val);
14             }
15              
16             template ::value>::type>
17             inline bool bool_or (T&&, bool default_val) {
18             return default_val;
19             }
20              
21             template ::value>
22             struct is_comparable {
23             static const bool value = true;
24             };
25              
26             template
27             struct is_comparable {
28             struct fallback { bool operator==(const fallback& oth); };
29             struct mixed_type: std::remove_reference::type, fallback {};
30             template < typename U, U > struct type_check {};
31              
32             template < typename U > static std::false_type test( type_check< bool (fallback::*)(const fallback&), &U::operator== >* = 0 );
33             template < typename U > static std::true_type test( ... );
34              
35             static const bool value = std::is_same(nullptr)), std::true_type>::value;
36             };
37              
38             template
39             struct has_call_operator {
40             private:
41             typedef std::true_type yes;
42             typedef std::false_type no;
43              
44             template static auto test(int) -> decltype(std::declval()(std::declval()...), yes());
45             template static no test(...);
46              
47             public:
48             static constexpr bool value = std::is_same(0)),yes>::value;
49             };
50              
51             template using enable_if_convertible_t = std::enable_if_t::value>;
52              
53             template using conjunction = std::is_same, detail::bool_pack>;
54             template using disjunction = std::integral_constant, detail::bool_pack>::value>;
55              
56             template using is_one_of = disjunction::value...>;
57             template using enable_if_one_of_t = std::enable_if_t::value, T>;
58             template using enable_if_one_of_vt = std::enable_if_t::value, void>;
59              
60             template using enable_if_arithmetic_t = std::enable_if_t::value, R>;
61             template using enable_if_signed_integral_t = std::enable_if_t::value && std::is_signed::value, R>;
62             template using enable_if_unsigned_integral_t = std::enable_if_t::value && std::is_unsigned::value, R>;
63             template using enable_if_floatp_t = std::enable_if_t::value, R>;
64              
65             template auto static_if(std::true_type, T t, F) { return t; }
66             template auto static_if(std::false_type, T, F f) { return f; }
67             template auto static_if(T t, F f) { return static_if(std::integral_constant{}, t, f); }
68             template auto static_if(T t) { return static_if(std::integral_constant{}, t, [](auto&&...){}); }
69              
70             }