Topic: automatic generation of visitor for variant type with


Author: godefv@gmail.com
Date: Fri, 20 May 2016 02:28:59 -0700 (PDT)
Raw View
------=_Part_6_1975202892.1463736539556
Content-Type: multipart/alternative;
 boundary="----=_Part_7_344078546.1463736539557"

------=_Part_7_344078546.1463736539557
Content-Type: text/plain; charset=UTF-8

Consider the following :

##################
template<class T>
concept bool Arithmetic = std::is_arithmetic<T>::value;

void f(Arithmetic i){
  /* do something with i */
}

int main(){
  variant<int, double> my_variant{/* give some value */};
/*
 * Here is what would be nice (maybe) :
 */
  f(my_variant);
/*
 * and would be equivalent to
 * apply([](Aritmetic i){return f(i);}, my_variant);
 * assuming the variant type provides an "apply" or "visit" function, which
should be the case.
 */
}
##################

The benefit is also greater if the function has multiple template arguments.
It is just syntactic sugar though...

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0c53e1d5-4fc6-4822-8c32-078ab1b3e705%40isocpp.org.

------=_Part_7_344078546.1463736539557
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Consider the following :<br><br>##################<br>temp=
late&lt;class T&gt;<br>concept bool Arithmetic =3D std::is_arithmetic&lt;T&=
gt;::value;<br><br>void f(Arithmetic i){<br>=C2=A0 /* do something with i *=
/<br>}<br><br>int main(){<br>=C2=A0 variant&lt;int, double&gt; my_variant{/=
* give some value */};<br>/*<br>=C2=A0* Here is what would be nice (maybe) =
:<br>=C2=A0*/<br>=C2=A0 f(my_variant);<br>/*<br>=C2=A0* and would be equiva=
lent to<br>=C2=A0* apply([](Aritmetic i){return f(i);}, my_variant);<br>=C2=
=A0* assuming the variant type provides an &quot;apply&quot; or &quot;visit=
&quot; function, which should be the case.<br>=C2=A0*/<br>}<br>############=
######<br><br>The benefit is also greater if the function has multiple temp=
late arguments.<br>It is just syntactic sugar though...<br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0c53e1d5-4fc6-4822-8c32-078ab1b3e705%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0c53e1d5-4fc6-4822-8c32-078ab1b3e705=
%40isocpp.org</a>.<br />

------=_Part_7_344078546.1463736539557--

------=_Part_6_1975202892.1463736539556--

.