Good afternoon! Can someone explain why an error occurs when using a function where only one vector is passed?
Well, that is, there you can transfer constants without pain: 3, "asdf" 2.3, etc., but named variables are not. But for some reason a crossbreed is possible. Why is this suddenly possible?
#include <iostream>
#include <vector>
template<typename... Args>
struct func
{
func(const Args&... args)
{
std::cout << "ok" << std::endl;
}
};
template <typename... Args>
func(Args...) -> func<Args...>;
int main()
{
const std::vector<int> v { 1, 2, 3 };
func(v); // error is here
func(v, 3); // no error
func("asdf"); // no error
}
ERROR: Cannot use parentheses when declaring variable with deduced class template specialization type
example: https://godbolt.org/z/jdnce5Gdv