How to get the return type of a method call in IntelliJ?
Hit Ctrl + Q (or ⌃J on Mac) when cursor is on a method declaration or call. It will show you the pop-up you want. As a bonus: Ctrl + Shift + I will display method body as well in a pop-up.
Hit Ctrl + Q (or ⌃J on Mac) when cursor is on a method declaration or call. It will show you the pop-up you want. As a bonus: Ctrl + Shift + I will display method body as well in a pop-up.
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
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
The canonical example is a .clone()/.copy() method. So you can always do obj = obj->copy(); regardless what obj’s type is. Edit: This clone method would be defined in the Object base class (as it actually is in Java). So if clone wasn’t covariant, you would either have to cast, or would be restricted to methods … Read more
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
The struct you’re returning is not an anonymous struct. The C standard defines an anonymous struct as a member of another struct that doesn’t use a tag. What you’re returning is a struct without a tag, but since it isn’t a member, it is not anonymous. GCC uses the name < anonymous > to indicate … Read more
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
Why should functions return values of a consistent type? To meet the following two rules. Rule 1 — a function has a “type” — inputs mapped to outputs. It must return a consistent type of result, or it isn’t a function. It’s a mess. Mathematically, we say some function, F, is a mapping from domain, … Read more
Why not just change it to int foo(int x, y) { if (y == 0) throwException(“Doh!”); return x/y; } This gives the same runtime results, and the compiler won’t complain.