I want to create a local object of some typename
Type
in a template function:
template <typename Type, typename... Args>
void create_local(Args... args)
{
Type val(args...);
}
Now when I call this function with no arguments (where Type
is the class with the non-copyable element):
struct T {
std::mutex m;
};
int main()
{
T t;
create_local<T>();
}
(coliru link)
g ++ (4.7.3 to 5.2) fails to compile and requires the definition of a move constructor T? clang 3.7 compiles successfully.
Also, if I (1) remove a member std::mutex
from T, (2) declares a default constructor for T, and (3) declares a remote copy instance for T:
struct T {
T() = default;
T(const T&) = delete;
};
int main()
{
T t;
create_local<T>();
}
all versions of g ++ and clang successfully compiled. Why is g ++ not compiling for any type Type
with non-copied members?