[#absl-down_cast-048]
= xref:absl.adoc[absl]::down&lowbar;cast
:relfileprefix: ../
:mrdocs:

Overload of down&lowbar;cast for references&period; Use like this&colon; absl&colon;&colon;down&lowbar;cast&lt;T&amp;&gt;(foo)&period; The code is slightly convoluted because we&apos;re still using the pointer form of dynamic cast&period; (The reference form throws an exception if it fails&period;)

== Synopsis

Declared in `&lt;absl&sol;base&sol;casts&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename To,
    typename From&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
To
down&lowbar;cast(From& f);
----

== Description

There&apos;s no need for a special const overload either for the pointer or the reference form&period; If you call down&lowbar;cast with a const T&amp;, the compiler will just bind From to const T&period;

== Return Value

`f`, downcast to `To`&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *f*
| The source reference to downcast&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
