Sorry for my probably wrong title, i don't know how to call it properly.
I've got a function that has two parametrs. These parapetrs are templates.
If 1st parametr is bigger or equal to 2nd parametr it's returned. Otherwise 2nd one is returnd. How to write declaration of this function?
You can use the ternary conditional operator, which will find the common type for you (or you can use std::common_type, but that's just using the ternary operator indirectly)
1st suggestion doesn't work on VS 2013. Maybe I don't have C++14 enabled.
2nd suggestion kind of works. If I write "std::cout << Bigger(10, 'c')" function returns char as int (it returns code of 'c' letter, 99). Any ideas to make it work better? If no thanks for what you wrote already.
EDIT
I cheked coliru.stacked and on their site 1st option also returns int instead of char;
A function can return only one type. (This is important as you need to know how to generate code before function call). So the return type is deduced as common (one which can hold values of both types).
If you need to return two types, you will need to use something more complex.
Like saving actual type (typeid or similar) alongside return value.