[docs] Fix style and typo in HowToSetUpLLVMStyleRTTI.rst after D126943

This commit is contained in:
Fangrui Song 2022-06-06 12:41:21 -07:00
parent cca662b849
commit f9e9037c86
1 changed files with 9 additions and 12 deletions

View File

@ -513,9 +513,8 @@ we can use some provided cast traits like so:
template <typename T> template <typename T>
struct CastInfo<T, SomeValue> struct CastInfo<T, SomeValue>
: public CastIsPossible<T, SomeValue>, : CastIsPossible<T, SomeValue>, NullableValueCastFailed<T>,
public NullableValueCastFailed<T>, DefaultDoCastIfPossible<T, SomeValue, CastInfo<T, SomeValue>> {
public DefaultDoCastIfPossible<T, SomeValue, CastInfo<T, SomeValue>> {
static T doCast(SomeValue v) { static T doCast(SomeValue v) {
return T(v.getPointer()); return T(v.getPointer());
} }
@ -530,9 +529,8 @@ that type from a char pointer type. So what we would do in that case is:
template <typename T> template <typename T>
struct CastInfo<SomeValue, T *> struct CastInfo<SomeValue, T *>
: public NullableValueCastFailed<SomeValue>, : NullableValueCastFailed<SomeValue>,
public DefaultDoCastIfPossible<SomeValue, T *, DefaultDoCastIfPossible<SomeValue, T *, CastInfo<SomeValue, T *>> {
CastInfo<SomeValue, T *>> {
static bool isPossible(const T *t) { static bool isPossible(const T *t) {
return std::is_same<T, char>::value; return std::is_same<T, char>::value;
} }
@ -552,8 +550,7 @@ In those cases, you probably want something like this:
.. code-block:: c++ .. code-block:: c++
template <typename T> template <typename T>
struct CastInfo<T, SomeValue> struct CastInfo<T, SomeValue> : OptionalValueCast<T, SomeValue> {};
: public OptionalValueCast<T, SomeValue> {};
That cast trait requires that ``T`` is constructible from ``const SomeValue &`` That cast trait requires that ``T`` is constructible from ``const SomeValue &``
but it enables casting like so: but it enables casting like so:
@ -563,7 +560,7 @@ but it enables casting like so:
SomeValue someVal = ...; SomeValue someVal = ...;
Optional<AnotherValue> valOr = dyn_cast<AnotherValue>(someVal); Optional<AnotherValue> valOr = dyn_cast<AnotherValue>(someVal);
With the ``_is_present`` variants, you can even do optional chaining like this: With the ``_if_present`` variants, you can even do optional chaining like this:
.. code-block:: c++ .. code-block:: c++