On 28/11/17 07:19, Stefan Ram wrote:
> "James R. Kuyper" <
james...@verizon.net> writes:
>> I had to add seven arguments to your function, while making no use of
>> the only argument you probably thought was relevant. I expect that
>> similar issues would apply to the other four things that you want
>> calculated, though I haven't bothered checking yet.
>> Does this even remotely resemble what you're looking for?
>
> I was starting to write about constructors for my
> German-language C++ course.
>
> Of course, I wanted to state the conditions under
> which constructors are declared implicitly.
>
> The rules seemed to be complicated. But maybe they
> just /seemed/ to be complicated /to me/, but were
> really quite simple for an expert who might be able
> to give all the rules in just a few lines of text?
>
> So, I had the idea to ask in this newsgroup.
>
> But then I also thought that the English language
> might add some ambiguity or vagueness to rules, and
> that ambiguity or vagueness could be avoided by
> expressing the rules in a more formal manner.
>
> Since we already got C++ as a formal language,
> it would be natural to express the rules using C++
> herself.
>
> From the rest of your reply I take it that the rules
> are so complicated that even for an expert it is
> not simple to write such a function.
>
> Moreover, the rules might change in the future:
> Scott Meyers wrote in 2014:
>
> "At some point, analogous rules may be extended to the
> copy operations, because C++11 deprecates the automatic
> generation of copy operations for classes declaring copy
> operations or a destructor."
>
> Another complication is that in that point of my course, I
> do not have explained all other parts of the language and
> - wishing to avoid forward references - I still have to
> exclude mentioning some parts of the language.
>
> So, in the final end, it might come down to me having to use
> some simplifications in that part of my course and only
> mention some common situations in which certain special
> member functions are generated or are not generated.
>
I would have thought you'd be looking at type traits here. There are
three things you /don't/ want - one is for the user to have to supply a
long list of type attributes manually, when it is easy for them to make
mistakes. The next is to have complex logic like Ben showed you needed,
since it is easy for /you/ to make mistakes. And the third is to have
it all done at run-time instead of compile-time.
I am still not sure of what your use-cases are here. But I think you
want to start with the existing type traits. Then move on to
constructing your own type traits for anything missing. For things that
you can't figure out this way, you then want to ask if it really is a
useful feature.