template <typename I>
class Ratio
{
public:
Ratio (I, I = 1) {};
Ratio (double, double = 1.0) = delete;
};
template class Ratio<int>;
Hi All,
Is the following explicit class template instantiation well-formed?:
template <typename I>
class Ratio
{
public:
Ratio (I, I = 1) {};
Ratio (double, double = 1.0) = delete;
};
template class Ratio<int>;
The second constructor is neither inherited, nor is it a template, so as per [temp.explicit]/8, it should be instantiated. Is such instantiation equivalent to being "used" in the sense provided by [dcl.fct.def.delete]/2? ("A program that refers to a deleted function implicitly or explicitly, other than to declare it, is ill-formed.")
GCC and Clang accept, it, but I cannot find a place in the Standard to support it.
Regards,
&rzej;
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
On 11 Oct 2016 1:52 am, "Andrzej Krzemieński" <akrz...@gmail.com> wrote:Hi All,
Is the following explicit class template instantiation well-formed?:
template <typename I>
class Ratio
{
public:
Ratio (I, I = 1) {};
Ratio (double, double = 1.0) = delete;
};
template class Ratio<int>;
The second constructor is neither inherited, nor is it a template, so as per [temp.explicit]/8, it should be instantiated. Is such instantiation equivalent to being "used" in the sense provided by [dcl.fct.def.delete]/2? ("A program that refers to a deleted function implicitly or explicitly, other than to declare it, is ill-formed.")The only reference to the function is the declaration generated by the instantiation. So the program arguably didn't refer to the function in any way other than to declare it.
Declarations are exempt from the "refering to a deleted function is illformed".
Anyway, this does not even require an explicit instantiation. Merely saying
Ratio<int> r(5)
Refers to the deleted constructor in order to declare it as a member of "Ratio<int>".
I don't have the spec here, but I believe that you could argue that the constructor is not even deleted yet at that point and at the point that it is explicitly instantiated. Because the deletion is the function's definition, and when the explicit instantiation of the function definition (the = delete part) is performed, the function is not yet deleted. Only afterwards.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.