Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Acts/Utilities/detail/MPL/are_sorted.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 namespace Acts::detail {
0011 /**
0012  * @brief check whether integral values are sorted
0013  *
0014  * @tparam ascending boolean flag to check for ascending order (@c true) or
0015  * descending order (@c false)
0016  * @tparam strict boolean flag whether strict ordering is required
0017  * @tparam T integral type of values whose order should be checked
0018  * @tparam values template parameter pack containing the list of values
0019  *
0020  * @test Unit tests are implemented \link
0021  * Acts::Test::BOOST_AUTO_TEST_CASE(are_sorted_helper_tests) here\endlink.
0022  *
0023  * @return `are_sorted<asc,strict,T,values...>::value` is @c true if the given
0024  * values are properly sorted,
0025  *         otherwise @c false
0026  */
0027 template <bool ascending, bool strict, typename T, T... values>
0028 struct are_sorted;
0029 
0030 /// @cond
0031 // one value is always sorted
0032 template <bool ascending, bool strict, typename T, T v>
0033 struct are_sorted<ascending, strict, T, v> {
0034   enum { value = true };
0035 };
0036 
0037 // strict, ascending ordering
0038 template <typename T, T a, T b, T... N>
0039 struct are_sorted<true, true, T, a, b, N...> {
0040   enum { value = ((a < b) && are_sorted<true, true, T, b, N...>::value) };
0041 };
0042 
0043 // weak, ascending ordering
0044 template <typename T, T a, T b, T... N>
0045 struct are_sorted<true, false, T, a, b, N...> {
0046   enum { value = (a <= b && are_sorted<true, false, T, b, N...>::value) };
0047 };
0048 
0049 // strict, descending ordering
0050 template <typename T, T a, T b, T... N>
0051 struct are_sorted<false, true, T, a, b, N...> {
0052   enum { value = (a > b && are_sorted<false, true, T, b, N...>::value) };
0053 };
0054 
0055 // weak, descending ordering
0056 template <typename T, T a, T b, T... N>
0057 struct are_sorted<false, false, T, a, b, N...> {
0058   enum { value = (a >= b && are_sorted<false, false, T, b, N...>::value) };
0059 };
0060 /// @endcond
0061 }  // namespace Acts::detail