diff options
Diffstat (limited to 'libs/variant/doc/reference/concepts.xml')
-rw-r--r-- | libs/variant/doc/reference/concepts.xml | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libs/variant/doc/reference/concepts.xml b/libs/variant/doc/reference/concepts.xml index 78c418e4a..03534ec2c 100644 --- a/libs/variant/doc/reference/concepts.xml +++ b/libs/variant/doc/reference/concepts.xml @@ -82,7 +82,9 @@ <listitem>Must allow invocation as a function by overloading <code>operator()</code>, unambiguously accepting any value of type <code>T</code>.</listitem> - <listitem>Must expose inner type <code>result_type</code>. (See + <listitem>Must expose inner type <code>result_type</code>. C++14 compatible compilers + could detect <code>result_type</code> automatically, but will stick to + <code>result_type</code> if it is defined. (See <code><functionname>boost::visitor_ptr</functionname></code> for a solution to using functions as visitors.)</listitem> <listitem>If <code>result_type</code> is not <code>void</code>, then @@ -131,6 +133,18 @@ public: } };</programlisting> + <para>C++14 compatible compilers detect <code>result_type</code> automatically:</para> + +<programlisting> + <classname>boost::variant</classname><int, float> v; + // ... + + <functionname>boost::apply_visitor</functionname>( + [](auto val) { return std::to_string(val); }, + v + ); +</programlisting> + </section> </section> |