@@ -1849,7 +1849,10 @@ <h3 id="Declaration_Order">Declaration Order</h3>
1849
1849
1850
1850
< p > Within each section, generally prefer grouping similar
1851
1851
kinds of declarations together, and generally prefer the
1852
- following order: types (including < code > typedef</ code > ,
1852
+ following order:
1853
+ < span class ="drake "> DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN or
1854
+ DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN</ span > ,
1855
+ types (including < code > typedef</ code > ,
1853
1856
< code > using</ code > , and nested structs and classes),
1854
1857
constants, factory functions, constructors and assignment
1855
1858
operators, destructor, all other methods, data members.</ p >
@@ -2642,28 +2645,41 @@ <h3 id="Friends">Friends</h3>
2642
2645
2643
2646
< h3 id ="Exceptions "> Exceptions</ h3 >
2644
2647
2645
- < p class ="drake "> Throwing exceptions is permitted and encouraged for error handling only.</ p >
2646
2648
< p class ="nondrake "> We do not use C++ exceptions.</ p >
2649
+ < p class ="drake "> Throwing exceptions is permitted and encouraged for error
2650
+ reporting only. Catching exceptions is forbidden except in unit tests as
2651
+ noted below.</ p >
2647
2652
2648
2653
< div class ="stylebody ">
2649
2654
< p class ="drake "> Unit tests may catch exceptions using
2650
2655
< a href ="https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#exception-assertions "> EXPECT_THROW</ a >
2651
- if the exception is documented in the API. Otherwise, catching exceptions is
2652
- forbidden. For more context, see
2653
- < a href ="https://github.com/robotlocomotion/drake/pull/3759 "> PR
2654
- #3759</ a > .</ p >
2655
-
2656
- < p class ="drake "> We allow exceptions to be thrown because it enables a more
2657
- detailed description of the error to be provided relative to an assert
2658
- statement.</ p >
2659
-
2660
- < p class ="drake "> Note: This is a work-in-progress rule, but captures our
2661
- currently-in-effect style. We are open to discussion on additional uses for
2662
- exceptions if and when the need arises.</ p >
2656
+ or
2657
+ < a href ="https://github.com/RobotLocomotion/drake/blob/master/common/test_utilities/expect_throws_message.h "> DRAKE_EXPECT_THROWS_MESSAGE</ a > ,
2658
+ but only if the tested function's Doxygen documentation mentions that the
2659
+ function throws an exception.</ p >
2660
+
2661
+ < p class ="drake "> When documenting exceptions in an API, only state that
2662
+ the function will throw < code > std::exception</ code > ; never promise a more
2663
+ specific subclass:</ p >
2664
+ < ul class ="drake ">
2665
+ < li > As we evolve implementations, sometimes it becomes difficult to upkeep
2666
+ the old promises (especially if they were the semantically "wrong" type), or
2667
+ to refactor the code in ways that keeps the subclass unchanged.</ li >
2668
+ < li > There's no great way to deprecate a particular exception signature.</ li >
2669
+ < li > Since we can't catch exceptions anyway, nevermind use a multi-layer-catch
2670
+ by specific subclasses, the only purpose of a subclass is for improved error
2671
+ reporting -- this purpose is still met by throwing a subclass, but we don't
2672
+ need to document it in Doxygen for this purpose.</ li >
2673
+ </ ul >
2674
+ </ p >
2663
2675
</ div >
2664
2676
2665
2677
< p class ="pros "> </ p >
2666
2678
< ul >
2679
+ < li class ="drake "> We allow exceptions to be thrown because it enables a more
2680
+ detailed description of the error to be provided relative to an assert
2681
+ statement.</ li >
2682
+
2667
2683
< li > Exceptions allow higher levels of an application to
2668
2684
decide how to handle "can't happen" failures in deeply
2669
2685
nested functions, without the obscuring and error-prone
@@ -4227,8 +4243,14 @@ <h3 id="Template_metaprogramming">Template Metaprogramming</h3>
4227
4243
4228
4244
< h3 id ="Boost "> Boost</ h3 >
4229
4245
4246
+ < div class ="drake ">
4247
+ < p > Drake's library code is not permitted to use Boost.</ p >
4248
+ </ div >
4249
+
4250
+ < div class ="nondrake ">
4230
4251
< p > Use only approved libraries from the Boost library
4231
4252
collection.</ p >
4253
+ </ div >
4232
4254
4233
4255
< p class ="definition "> </ p >
4234
4256
< p > The
@@ -4249,8 +4271,14 @@ <h3 id="Boost">Boost</h3>
4249
4271
4250
4272
< p class ="decision "> </ p >
4251
4273
4274
+ < div class ="drake ">
4275
+ < p > Drake's library code is not permitted to use Boost. To improve uptake,
4276
+ we have chosen not to inflict this dependency on our users. It would be
4277
+ permissible for unit tests to use Boost, though so far we have not seen
4278
+ any need for that.</ p >
4279
+ </ div >
4252
4280
4253
-
4281
+ < div class =" nondrake " >
4254
4282
< div >
4255
4283
< p > In order to maintain a high level of readability for
4256
4284
all contributors who might read and maintain code, we
@@ -4325,6 +4353,7 @@ <h3 id="Boost">Boost</h3>
4325
4353
features to the list, so this list may be expanded in
4326
4354
the future.</ p >
4327
4355
</ div >
4356
+ </ div >
4328
4357
4329
4358
< h3 id ="std_hash "> std::hash</ h3 >
4330
4359
0 commit comments