libzypp 17.31.23
TypeTraits.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#ifndef ZYPP_TYPETRAITS_H
12#define ZYPP_TYPETRAITS_H
13
14#include <type_traits>
15
17namespace zypp
18{
20 namespace _detail
21 {
22 template<typename Tp>
24 {
25 private:
26 template<typename C> static std::true_type test( typename C::const_iterator * );
27 template<typename C> static std::false_type test(...);
28 public:
29 static constexpr bool value = decltype(test<Tp>(nullptr))::value;
30 };
31
32 template <typename Tp>
34 {
35 private:
36 template <typename C>
37 using Signature = typename C::const_iterator(C::*)() const;
38
39 template<typename C> static std::true_type testBeg( typename std::enable_if<std::is_same<decltype(static_cast<Signature<C>>(&C::begin)), Signature<C>>::value, void>::type* );
40 template<typename C> static std::false_type testBeg(...);
41
42 template<typename C> static std::true_type testEnd( typename std::enable_if<std::is_same<decltype(static_cast<Signature<C>>(&C::end)), Signature<C>>::value, void>::type* );
43 template<typename C> static std::false_type testEnd(...);
44
45 public:
46 static constexpr bool beg_value = decltype(testBeg<Tp>(nullptr))::value;
47 static constexpr bool end_value = decltype(testEnd<Tp>(nullptr))::value;
48 static constexpr bool value = beg_value && end_value;
49 };
50 } // namespace _detail
52
54 template<typename Tp>
56 : public std::integral_constant<bool, _detail::has_type_const_iterator<Tp>::value>
57 {};
58
60 template<typename Tp>
62 : public std::integral_constant<bool, _detail::_has_container_begin_end<Tp>::value>
63 {};
64
66 template<typename Tp>
68 : public std::integral_constant<bool, !std::is_same<Tp, std::string>::value && has_container_begin_end<Tp>::value>
69 {};
70
71
72} // namespace zypp
74#endif // ZYPP_TYPETRAITS_H
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
static std::false_type testBeg(...)
typename C::const_iterator(C::*)() const Signature
Definition: TypeTraits.h:37
static std::false_type testEnd(...)
static std::true_type testEnd(typename std::enable_if< std::is_same< decltype(static_cast< Signature< C > >(&C::end)), Signature< C > >::value, void >::type *)
static std::true_type testBeg(typename std::enable_if< std::is_same< decltype(static_cast< Signature< C > >(&C::begin)), Signature< C > >::value, void >::type *)
static std::false_type test(...)
static std::true_type test(typename C::const_iterator *)
Whether Tp defines methods Tp::const_iterator begin/end() const
Definition: TypeTraits.h:63
Whether Tp defines type Tp::const_iterator.
Definition: TypeTraits.h:57
Whether Tp is a container (begin/end iterabel, but not plain std::string)
Definition: TypeTraits.h:69