C++ return type overload hack

后端 未结 7 650
无人及你
无人及你 2021-02-04 09:02

I was bored and came up with such hack (pseudocode):

 1 struct proxy {
 2     operator int(); // int function
 3     operator double(); // double function
 4             


        
7条回答
  •  悲&欢浪女
    2021-02-04 09:38

    Actually it seems you have reinvented a Variant type. Just take a look at all *variant types that are present in many frameworks, eg.: MS uses VARIANT, Qt has QVariant.

提交回复
热议问题