Drake
default_scalars.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 /// A macro that defines explicit class template instantiations for Drake's
7 /// default set of supported scalar types. This macro should only be used in
8 /// .cc files, never in .h files.
9 ///
10 /// @param SomeType the template typename to instantiate, *including* the
11 /// leading `class` or `struct` keyword.
12 ///
13 /// Currently the supported types are:
14 /// - double
15 /// - drake::AutoDiffXd
16 /// - drake::symbolic::Expression
17 ///
18 /// Example `my_system.h`:
19 /// @code
20 /// namespace sample {
21 /// template <typename T>
22 /// class MySystem final : public LeafSystem<T> {
23 /// ...
24 /// @endcode
25 ///
26 /// Example `my_system.cc`:
27 /// @code
28 /// #include "my_system.h"
29 ///
30 /// #include "drake/common/default_scalars.h"
31 ///
32 /// DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_SCALARS(
33 /// class ::sample::MySystem)
34 /// @endcode
35 ///
36 /// See also @ref system_scalar_conversion.
37 // N.B. `CommonScalarPack` in `systems_pybind.h` should be kept in sync
38 // with this.
39 #define DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_SCALARS( \
40  SomeType) \
41 DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_NONSYMBOLIC_SCALARS( \
42  SomeType) \
43 template SomeType<::drake::symbolic::Expression>;
44 
45 /// A macro to that defines explicit class template instantiations for Drake's
46 /// default set of supported scalar types, excluding all symbolic types. This
47 /// macro should only be used in .cc files, never in .h files. This is
48 /// identical to DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_SCALARS
49 /// except that it does not define support for any drake::symbolic types.
50 // N.B. `NonSymbolicScalarPack` in `systems_pybind.h` should be kept in sync
51 // with this.
52 #define \
53  DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_NONSYMBOLIC_SCALARS( \
54  SomeType) \
55 template SomeType<double>; \
56 template SomeType<::drake::AutoDiffXd>;
Provides public header files of Drake&#39;s symbolic library.