Skip to content

A lot of ifs can be replaced by if constexpr #3163

Open
@jachymb

Description

@jachymb

This is based on review by @SteveBronder in my PR #3157 (comment) but it apparently pertains to many other already implemented distributions as well as functions

When I run the following command

grep -rE if \(!?is_constant stan/math

The output has 1146 lines.

If I understand correctly the value is known at compile time and these could be replaced by if constexpr

similarly:

grep -rE if \(!?include_summand stan/math

has 285 lines.

This is just for illustration, there are others that can be found that can be found by filtering for <.*> or ::value etc. The grep may not find all in case of formatting line breaks. Perhaps this can be done by a more sophisticated regex search and replace through the codebase?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions