Drake
number_traits.h
Go to the documentation of this file.
1 #pragma once
2 
3 /// @file
4 /// This file contains traits for number (scalar) types. Drake libraries that
5 /// are templated on a scalar type may consult these traits to perform
6 /// appropriate conditional compilation.
7 ///
8 /// This file will also contain trait specializations for officially-supported
9 /// Drake scalar types, as we decide what those types are. Other scalar types,
10 /// such as experimental, test, and example types within Drake, or custom types
11 /// outside of Drake, may specialize the traits locally.
12 
13 namespace drake {
14 
15 /// is_numeric is true for types that are on the real line. The exact list
16 /// of operations that Drake requires numeric types to satisfy is not yet a
17 /// hard API commitment; we expect it to expand slowly over time. However, it
18 /// will only include operations that real numbers can implement.
19 ///
20 /// By default, is_numeric is true. It should be specialized to false as
21 /// needed to avoid compiling Drake features that don't make sense for
22 /// non-real types.
23 ///
24 /// Examples:
25 ///
26 /// is_numeric should be true for types like double, int, and AutoDiffScalar.
27 ///
28 /// is_numeric should be false for types like std::complex, Polynomial, and
29 /// symbolic::Expression.
30 template <typename T>
31 struct is_numeric {
32  static constexpr bool value = true;
33 };
34 
35 } // namespace drake
static constexpr bool value
Definition: number_traits.h:32
Definition: automotive_demo.cc:88
is_numeric is true for types that are on the real line.
Definition: number_traits.h:31