Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DerivedFrom should be publicly and unambiguously #255

Closed
ericniebler opened this issue Nov 9, 2016 · 5 comments
Closed

DerivedFrom should be publicly and unambiguously #255

ericniebler opened this issue Nov 9, 2016 · 5 comments

Comments

@ericniebler
Copy link
Owner

ericniebler commented Nov 9, 2016

Proposed Resolution

Change [concepts.lib.corelang.derived] as follows:

 template <class T, class U>
 concept bool DerivedFrom() {
-  return see below ;
+  return is_base_of<U, T>::value &&
+    is_convertible<remove_cv_t<T>*, remove_cv_t<U>*>::value; // see below
 }

-1 DerivedFrom<T, U>() is satisfied if and only if is_base_of<U, T>::value is
-  true.
+1 There need not be a subsumption relationship between DerivedFrom<T, U>() and either
+  is_base_of<U, T>::value or is_convertible<remove_cv_t<T>*, remove_cv_t<U>*>::value.
+
+2 [Note: DerivedFrom<T, U>() is satisfied if and only if T is publicly and unambiguously
+  derived from U, or T and U are the same class type ignoring cv qualifiers.-end note]
@ericniebler
Copy link
Owner Author

@CaseyCarter Comments?

@CaseyCarter
Copy link
Collaborator

CaseyCarter commented Feb 1, 2017

"if and only if is_base_of<U, T>::value && is_convertible<T*, U*>::value is true" is shorter/simpler.

@ericniebler
Copy link
Owner Author

ericniebler commented Feb 2, 2017

Resolution edited to hide the subsumption relationship with the traits (#321).

@timsong-cpp
Copy link
Contributor

is_base_of<U, T> ignores cv-qualification, but is_convertible<T*, U*> doesn't. Should DerivedFrom care about cv-qualifications on T and U?

@CaseyCarter
Copy link
Collaborator

Should DerivedFrom care about cv-qualifications on T and U?

It definitely should not; PR corrected to use is_convertible<remove_cv_t<T>*, remove_cv_t<U>*>::value.

CaseyCarter added a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 26, 2017
CaseyCarter added a commit to CaseyCarter/cmcstl2 that referenced this issue Feb 26, 2017
@ericniebler ericniebler added ready and removed open labels Jul 12, 2017
@CaseyCarter CaseyCarter mentioned this issue Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants