This has been asked before, but I'm curious to see if anything has changed in newer C++ standards. Any current or future standard is acceptable.
I have the following code:This compiles fine with clang (as I would expect), but gcc produces the following error:
I declare two templates, the first converts the argument x from type T to type U and the second from type U to type T. If I call cast with 10, the compiler does not complain. I think both meet the requirements to be used and therefore there should be...
I'm trying to write syntactic sugar, in a monad-style, over std::optional. Please consider:As is, this function cannot be called with a non-optional T1 (e.g. an int), even though there exists a conversion from T to std::optional<T>2.
This code:yields the following error (with GCC 6.3):Now, I can work around this, like so:but why do I have to? I mean, why isn't the compiler willing to "plug" the second template parameter of std::unique_ptr with its default value and allow std::unique_ptr to be used as a template argument to...
When you have class template argument deduction available from C++17, why can't you deduce the template arguments of std::unique_ptr? For example, this gives me an error:
Could you help me understand why the argument deduction works for the class template and does not work for the function template?
I have class template with single type param and const char* type full specialization, simplified example below: