source: branches/profile/TEMPLATES/arb_algo.h

Last change on this file was 8719, checked in by westram, 12 years ago
  • added header arb_algo.h (idioms based on <algorithm>)
    • added force_in_range
  • use in DI_view_matrix
File size: 998 bytes
Line 
1// =========================================================== //
2//                                                             //
3//   File      : arb_algo.h                                    //
4//   Purpose   : idioms based on algorithm                     //
5//                                                             //
6//   Coded by Ralf Westram (coder@reallysoft.de) in May 2012   //
7//   Institute of Microbiology (Technical University Munich)   //
8//   http://www.arb-home.de/                                   //
9//                                                             //
10// =========================================================== //
11
12#ifndef ARB_ALGO_H
13#define ARB_ALGO_H
14
15#ifndef _GLIBCXX_ALGORITHM
16#include <algorithm>
17#endif
18
19template <typename T>
20inline const T& force_in_range(const T& lower_bound, const T& value, const T& upper_bound) {
21    return std::min(std::max(lower_bound, value), upper_bound);
22}
23
24#else
25#error arb_algo.h included twice
26#endif // ARB_ALGO_H
Note: See TracBrowser for help on using the repository browser.