cp_library_rs/
chmax.rs

1/// `chmax!(x1, x2, ..., xn)`:`x1`,`x2`,...,`xn`のうち最大のものを、`x1`に代入する
2/// - 代入があったとき、`true`を返す
3#[macro_export]
4macro_rules! chmax {
5    ( $a:expr, $b:expr $(,)* ) => {{
6        if $a < $b {
7            $a = $b;
8            true
9        } else {
10            false
11        }
12    }};
13    ( $a:expr, $b:expr, $c:expr $(,$other:expr)* $(,)* ) => {{
14        chmax! {
15            $a,
16            ($b).max($c)
17            $(,$other)*
18        }
19    }}
20}