C++20にはusing enumが入る。この機能、すっかり見逃していた。
どのような機能かというと、scoped enumを名前空間のusing directiveのように使うことができる。
using enumがないと以下のように書かなければならないが
enum struct color { red, green, blue } ;
void f( color c )
{
switch( c )
{
case color::red :
break ;
case color::green :
break ;
case color::blue :
break ;
}
}
using enumを使えば以下のように書ける。
enum struct color { red, green, blue } ;
void f( color c )
{
using enum color ;
switch( c )
{
case red :
break ;
case green :
break ;
case blue :
break ;
}
}
scoped enumは暗黙の型変換をしないので、従来のenumに変わって使われるべきだが、いちいちenum名を修飾子なければならないのは面倒だ。そこで、名前空間のusingディレクティブのような機能、using enumが追加された。
3 comments:
Thank you for your thoughtfulness
https://sabunlicin.com/
http://www.darajulolori.com/
http://www.aleapullumreliable.com/
http://www.doragonbetto.net/
http://www.muchinahito.net/
http://www.rakkibeta.net/
Thank you for all that you have given to me, hopefully all of these are useful for all of us
http://www.graniewpilki.com/
http://www.pokagyanburusaito.net/
http://www.daftarnegaramiskin.com/
https://www.ceritamitosdunia.web.id/
http://www.daftaranjingpopuler.web.id/
idn play deposit pulsa tanpa potongan
texaspoker88
APK IDN Poker
Post a Comment