[#BloombergLP-bdlb-VariantImp-print]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/VariantImp.adoc[VariantImp]::print
:relfileprefix: ../../../
:mrdocs:

Format this object to the specified output `stream`&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;variant&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::ostream&
print(
    std::ostream& stream,
    int level = 0,
    int spacesPerLevel = 4) const;
----

== Description

If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period; Nothing is printed if this variant is unset&period; Each type that may be contained by this variant shall be printable with `bdlb&colon;&colon;PrintMethods` (typically meaning that they either declare the `bdlb&colon;&colon;HasPrintMethod` trait or provide the `&lt;&lt;` output streaming operator)&period; See &lcub;`bdlb&lowbar;printmethods`&rcub;&period; The compiler will emit an error if `bdlb&colon;&colon;PrintMethods&colon;&colon;print` cannot be instantiated for each type that may be contained by this variant&period;

== Return Value

a reference to `stream`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| stream used for input or output
| *level*
| absolute indentation level
| *spacesPerLevel*
| spaces per indentation level
|===


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