Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
are_sorted.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file are_sorted.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 namespace Acts {
12 namespace detail {
29 template <bool ascending, bool strict, typename T, T... values>
30 struct are_sorted;
31 
33 // one value is always sorted
34 template <bool ascending, bool strict, typename T, T v>
35 struct are_sorted<ascending, strict, T, v> {
36  enum { value = true };
37 };
38 
39 // strict, ascending ordering
40 template <typename T, T a, T b, T... N>
41 struct are_sorted<true, true, T, a, b, N...> {
43 };
44 
45 // weak, ascending ordering
46 template <typename T, T a, T b, T... N>
47 struct are_sorted<true, false, T, a, b, N...> {
48  enum { value = (a <= b && are_sorted<true, false, T, b, N...>::value) };
49 };
50 
51 // strict, descending ordering
52 template <typename T, T a, T b, T... N>
53 struct are_sorted<false, true, T, a, b, N...> {
54  enum { value = (a > b && are_sorted<false, true, T, b, N...>::value) };
55 };
56 
57 // weak, descending ordering
58 template <typename T, T a, T b, T... N>
59 struct are_sorted<false, false, T, a, b, N...> {
60  enum { value = (a >= b && are_sorted<false, false, T, b, N...>::value) };
61 };
63 } // namespace detail
65 } // namespace Acts