So I have a template function which has a defaulted 2nd argument. It's 1st argument can be deduced, so something like:
I have my own fixed-size array type I want to be constexpr constructible from an std::initializer_list without having to explicitly define the size template argument.
Consider the following codewhich yieldsSo it basically looks as if the externally defined constructor perfectly forwards the value category of its argument while the inline-defined constructor does not.
Why does make_pair and Class Template Argument Deduction (CTAD) not agree on which type to generate?Output:
https://www.godbolt.org/z/_4aqsF:gcc, clang and msvc apparently agree that this cannot compile because find_if would return an array.
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...