[libcxx-commits] [PATCH] D59678: Make common_type's implementation common

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 22 12:16:54 PDT 2019


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

This is good by me (but you should address Marshall's comment about the tests). Cool trick with the macro for variadic templates.



================
Comment at: include/type_traits:2189
+    : conditional<
+        is_same<_Tp, typename decay<_Tp>::type>::value && is_same<_Up, typename decay<_Up>::type>::value,
+        __common_type2_imp<_Tp, _Up>,
----------------
EricWF wrote:
> ldionne wrote:
> > If one is already decayed but the other isn't, shouldn't you decay the one that isn't?
> No. The standard is very specific about this:
> 
> http://eel.is/c++draft/meta.trans.other#3.3
Ah, I see! To match the wording perfectly you could also do:

```
conditional<
    !is_same<_Tp, typename decay<_Tp>::type>::value || !is_same<_Up, typename decay<_Up>::type>::value,
    common_type<typename decay<_Tp>::type, typename decay<_Up>::type>,
    __common_type2_imp<_Tp, _Up>
>
```

I'm not requesting that you do that, though.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59678/new/

https://reviews.llvm.org/D59678





More information about the libcxx-commits mailing list