#pragma once #include #include namespace sdbusplus { namespace utility { /** has_const_iterator - Determine if type has const iterator * * @tparam T - Type to be tested. * * @value A value as to whether or not the type supports iteration */ template struct has_const_iterator { private: typedef char yes; typedef struct { char array[2]; } no; template static constexpr yes test(decltype(std::cbegin(std::declval()))*); template static constexpr no test(...); public: static constexpr bool value = sizeof(test(nullptr)) == sizeof(yes); }; template inline constexpr bool has_const_iterator_v = has_const_iterator::value; /** has_emplace_method - Determine if type has a method template named emplace * * @tparam T - Type to be tested. * * @value A value as to whether or not the type has an emplace method */ template struct has_emplace_method { private: struct dummy {}; template static constexpr auto test(P* p) -> decltype(std::declval().emplace(*p), std::true_type()); template static std::false_type test(...); public: static constexpr bool value = std::is_same_v(nullptr))>; }; template inline constexpr bool has_emplace_method_v = has_emplace_method::value; /** has_emplace_method - Determine if type has a method template named * emplace_back * * @tparam T - Type to be tested. * * @value A value as to whether or not the type has an emplace_back method */ template struct has_emplace_back_method { private: struct dummy {}; template static constexpr auto test(P* p) -> decltype(std::declval().emplace_back(*p), std::true_type()); template static std::false_type test(...); public: static constexpr bool value = std::is_same_v(nullptr))>; }; template inline constexpr bool has_emplace_back_method_v = has_emplace_back_method::value; } // namespace utility } // namespace sdbusplus