tinympl  0.2
mini MPL library for C++11
unordered_equal.hpp
1 // Copyright (C) 2013, Ennio Barbaro.
2 //
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://sbabbi.github.io/tinympl for documentation.
8 //
9 // You are welcome to contact the author at:
10 // enniobarbaro@gmail.com
11 //
12 
13 #ifndef TINYMPL_UNORDERED_EQUAL_HPP
14 #define TINYMPL_UNORDERED_EQUAL_HPP
15 
16 #include <tinympl/variadic/count.hpp>
17 #include <tinympl/variadic/all_of.hpp>
18 #include <tinympl/as_sequence.hpp>
19 #include <tinympl/sequence.hpp>
20 #include <tinympl/logical_and.hpp>
21 #include <tinympl/variadic/count.hpp>
22 #include <tinympl/variadic/all_of.hpp>
23 #include <type_traits>
24 
25 namespace tinympl {
26 
39 template<class SequenceA, class SequenceB>
41  unordered_equal< as_sequence_t<SequenceA>, as_sequence_t<SequenceB> > {};
42 
43 namespace detail {
44 template<class SequenceA, class SequenceB> struct unordered_equal_impl;
45 
46 template<class ... As, class ... Bs>
47 struct unordered_equal_impl<sequence<As...>, sequence<Bs...> > {
48 private:
49  template<class T>
50  struct check_t {
51  typedef std::integral_constant < bool,
52  variadic::count<T, As...>::type::value ==
53  variadic::count<T, Bs...>::type::value > type;
54  };
55 
56 public:
57  typedef typename logical_and <
58  typename variadic::all_of< check_t, As...>::type,
59  typename variadic::all_of< check_t, Bs...>::type >::type type;
60 };
61 }
62 
63 template<class ... As, class ... Bs>
64 struct unordered_equal<sequence<As...>, sequence<Bs...> > :
65  detail::unordered_equal_impl< sequence<As...>, sequence<Bs...> >::type
66 {};
67 
68 } // namespace tinympl
69 
70 #endif // TINYMPL_UNORDERED_EQUAL_HPP
Counts the number of elements in a sequence equal to a given one.
Definition: count.hpp:36
Determines whether it is possible to reorder the sequence A to match exactly the sequence B ...
Definition: unordered_equal.hpp:40
The main sequence type.
Definition: sequence.hpp:28