Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
log2.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/meta/log2.hpp
3  *
4  * Template Metaprogramming Tools (from the Generative Programming book Krysztof
5  * Czarnecki, Ulrich Eisenecker)
6  *
7  * Part of tlx - http://panthema.net/tlx
8  *
9  * Copyright (C) 2003 Roman Dementiev <[email protected]>
10  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
11  * Copyright (C) 2010-2017 Timo Bingmann <[email protected]>
12  *
13  * All rights reserved. Published under the Boost Software License, Version 1.0
14  ******************************************************************************/
15 
16 #ifndef TLX_META_LOG2_HEADER
17 #define TLX_META_LOG2_HEADER
18 
19 #include <cstdint>
20 
21 namespace tlx {
22 
23 //! \addtogroup tlx_meta
24 //! \{
25 
26 /******************************************************************************/
27 // Log2Floor<Value>::value
28 
29 template <uint64_t Input>
30 class Log2Floor
31 {
32 public:
33  enum {
34  value = Log2Floor<Input / 2>::value + 1
35  };
36 };
37 
38 template <>
39 class Log2Floor<1>
40 {
41 public:
42  enum { value = 0 };
43 };
44 
45 template <>
46 class Log2Floor<0>
47 {
48 public:
49  enum { value = 0 };
50 };
51 
52 /******************************************************************************/
53 // Log2<Value>::floor and Log2<Value>::ceil
54 
55 template <uint64_t Input>
56 class Log2
57 {
58 public:
59  enum {
61  ceil = Log2Floor<Input - 1>::value + 1
62  };
63 };
64 
65 template <>
66 class Log2<1>
67 {
68 public:
69  enum {
70  floor = 0,
71  ceil = 0
72  };
73 };
74 
75 template <>
76 class Log2<0>
77 {
78 public:
79  enum {
80  floor = 0,
81  ceil = 0
82  };
83 };
84 
85 //! \}
86 
87 } // namespace tlx
88 
89 #endif // !TLX_META_LOG2_HEADER
90 
91 /******************************************************************************/
int value
Definition: gen_data.py:41