cond.h File Reference
#include <functional>
#include <type_traits>
#include "drake/common/double_overloads.h"
Include dependency graph for cond.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.





Constructs conditional expression (similar to Lisp's cond).

  cond(cond_1, expr_1,
       cond_2, expr_2,
          ...,   ...,
       cond_n, expr_n,

The value returned by the above cond expression is expr_1 if cond_1 is true; else if cond_2 is true then expr_2; ... ; else if cond_n is true then expr_n. If none of the conditions are true, it returns expr_{n+1}.

This functions assumes that ScalarType provides operator< and the type of f_cond is the type of the return type of operator<(ScalarType, ScalarType). For example, symbolic::Expression can be used as a ScalarType because it provides symbolic::Formula operator<(symbolic::Expression, symbolic::Expression).
template<typename ScalarType >
ScalarType cond (const ScalarType &e)
template<typename ScalarType , typename... Rest>
ScalarType cond (const decltype(ScalarType()< ScalarType())&f_cond, const ScalarType &e_then, Rest...rest)