Can we have a function with multiple return types? (in C++11 and above)

The return type must be determined at compile-time. You might use std::common_type (since C++11): For arithmetic types not subject to promotion, the common type may be viewed as the type of the (possibly mixed-mode) arithmetic expression such as T0() + T1() + … + Tn(). template < typename T, typename X> typename std::common_type<T, X>::type Max_Number … Read more

Return Type Covariance with Smart Pointers

You can’t do it directly, but there are a couple of ways to simulate it, with the help of the Non-Virtual Interface idiom. Use covariance on raw pointers, and then wrap them struct Base { private: virtual Base* doClone() const { … } public: shared_ptr<Base> Clone() const { return shared_ptr<Base>(doClone()); } virtual ~Base(){} }; struct … Read more

SQL function return-type: TABLE vs SETOF records

When returning SETOF record the output columns are not typed and not named. Thus this form can’t be used directly in a FROM clause as if it was a subquery or a table. That is, when issuing: SELECT * from events_by_type_2(‘social’); we get this error: ERROR: a column definition list is required for functions returning … Read more

How to specify method return type list of (what) in Python?

With Python 3.6, the built-in typing package will do the job. from typing import List def validate(self, item:dict, attrs:dict)-> List[str]: … The notation is a bit weird, since it uses brackets but works out pretty well. Edit: With the new 3.9 version of Python, you can annotate types without importing from the typing module. The … Read more