carl  24.04
Computer ARithmetic Library
constants.h
Go to the documentation of this file.
1 /**
2  * @file constants.h
3  * @author Sebastian Junges
4  *
5  */
6 
7 #pragma once
8 
9 #ifndef INCLUDED_FROM_NUMBERS_H
10 static_assert(false, "This file may only be included indirectly by numbers.h");
11 #endif
12 
13 #define constant_zero_declaration_type(type, zero_decl) \
14 template<> \
15  struct constant_zero<type> { \
16  static const type& get() \
17  { \
18  static type t = zero_decl; \
19  return t; \
20  } \
21  };
22 
23 #define constant_one_declaration_type(type, one_decl) \
24 template<> \
25  struct constant_one<type> { \
26  static const type& get() \
27  { \
28  static type t = one_decl; \
29  return t; \
30  } \
31  };
32 
33 //
34 #define constant_declarations(type, zero_decl, one_decl) \
35  constant_zero_declaration(type, zero_decl) \
36  constant_one_declaration(type, one_decl)
37 
38 namespace carl
39 {
40  template<typename T>
41  struct constant_zero {
42  static const T& get()
43  {
44  static T t(0); // NOLINT
45  return t;
46  }
47  };
48 
49  template<typename T>
50  struct constant_one {
51  static const T& get()
52  {
53  static T t(1); // NOLINT
54  return t;
55  }
56  };
57 }
carl is the main namespace for the library.
static const T & get()
Definition: constants.h:42
static const T & get()
Definition: constants.h:51