Skip to content

Commit fb27f4f

Browse files
[llvm] Use "static constexpr bool flow" in YamlIO.rst (#165166)
In C++17, we should use "static constexpr bool" instead of "static const bool" for class-scope constants for for better compile-time evaluation and checks.
1 parent 160b727 commit fb27f4f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/docs/YamlIO.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ Flow Mapping
807807
A YAML "flow mapping" is a mapping that uses the inline notation
808808
(e.g { x: 1, y: 0 } ) when written to YAML. To specify that a type should be
809809
written in YAML using flow mapping, your MappingTraits specialization should
810-
add "static const bool flow = true;". For instance:
810+
add ``static constexpr bool flow = true;``. For instance:
811811

812812
.. code-block:: c++
813813

@@ -824,7 +824,7 @@ add "static const bool flow = true;". For instance:
824824
...
825825
}
826826

827-
static const bool flow = true;
827+
static constexpr bool flow = true;
828828
}
829829

830830
Flow mappings are subject to line wrapping according to the ``Output`` object
@@ -859,7 +859,7 @@ Flow Sequence
859859
A YAML "flow sequence" is a sequence that when written to YAML it uses the
860860
inline notation (e.g [ foo, bar ] ). To specify that a sequence type should
861861
be written in YAML as a flow sequence, your SequenceTraits specialization should
862-
add "static const bool flow = true;". For instance:
862+
add ``static constexpr bool flow = true;``. For instance:
863863

864864
.. code-block:: c++
865865

@@ -869,7 +869,7 @@ add "static const bool flow = true;". For instance:
869869
static MyListEl &element(IO &io, MyList &list, size_t index) { ... }
870870

871871
// The existence of this member causes YAML I/O to use a flow sequence
872-
static const bool flow = true;
872+
static constexpr bool flow = true;
873873
};
874874

875875
With the above, if you used MyList as the data type in your native data

0 commit comments

Comments
 (0)