Skip to content

Value-type support in DRAKE_THROW_UNLESS #23468

@SeanCurtis-TRI

Description

@SeanCurtis-TRI

To developers

If you are requesting support for a new value type, please add a comment below making the request. Ideally, the context in which you need the type will facilitate the conversation. We cannot promise that every value type will be supported, but if a value is deemed unsupportable, we'll provide the reason below.

The background

As of #19229 DRAKE_THROW_UNLESS provided support where value expressions could be passed in addition to a condition, so that the exception message would include the values relevant to the failed condition.

The first implementation only supported float-valued expressions. It was written with the understanding that other types would be both practical and useful. However, we're going to wait until specific types are needed at real call sites.

The primary motivation is to make sure that DRAKE_THROW_UNLESS is written in a way that it can be safely inlined. By starting small (floats only), we can guarantee it. Each subsequent PR is then obliged to add a type while maintaining the invariant.

This issue is referenced in a compile-time message if a developer attempts to pass an unsupported value type. This issue is the medium through which developers can request support for a new value type.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions