Drake
dummy_value.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <limits>
4 
5 namespace drake {
6 
16 template <typename T>
17 struct dummy_value {
18  static constexpr T get() {
19  static_assert(std::numeric_limits<T>::has_quiet_NaN,
20  "Custom scalar types should specialize this struct");
21  return std::numeric_limits<T>::quiet_NaN();
22  }
23 };
24 
25 template <>
26 struct dummy_value<int> {
27  static constexpr int get() {
28  // D is for "Dummy". We assume as least 32 bits (per cppguide) -- if `int`
29  // is larger than 32 bits, this will leave some fraction of the bytes zero
30  // instead of 0xDD, but that's okay.
31  return 0xDDDDDDDD;
32  }
33 };
34 
35 } // namespace drake
Definition: automotive_demo.cc:88
Provides a "dummy" value for a ScalarType – a value that is unlikely to be mistaken for a purposeful...
Definition: dummy_value.h:17