RFC: TypeTraits Variables

156 views
Skip to first unread message

Vicente J. Botet Escriba

unread,
May 26, 2013, 6:40:46 AM5/26/13
to std-pr...@isocpp.org
Hi,

please see the attached proposal that presents an alternative to the not adopted section 4 of “N3546 - TransformationTraits Redux , v2” that makes use of the new template variables C++14 feature to provide a shorter name to access associated template struct traits ::value.
For example

template<typename T>
constexpr bool is_reference_c = is_reference<T>::value;

Comments welcome,
Vicente

type_traits_variables.pdf

Akira Takahashi

unread,
May 27, 2013, 11:53:54 PM5/27/13
to std-pr...@isocpp.org
HI, Vicente

2013/5/26 Vicente J. Botet Escriba <vicent...@wanadoo.fr>

I totally agree!
I think need more variable.

<functional> header

namespace std {
  template <class T> constexpr bool is_bind_expression_c = is_bind_expression<T>::value;
  template <class T> constexpr int is_placeholder_c = is_placeholder<T>::value;
}


Thanks,
Akira

>>========================
Akira Takahashi
mailto:faitha...@gmail.com
site: https://sites.google.com/site/faithandbrave/about/en

Jonathan Wakely

unread,
May 28, 2013, 6:37:43 AM5/28/13
to std-pr...@isocpp.org
Concepts Lite will add constexpr functions that allow Is_default_constructible<T>() and Is_same<T, U>(), do we need variables if we have those?  Is there any advantage to having both?  I would expect a proposal to include some discussion of that.


Message has been deleted

toma...@gmail.com

unread,
May 28, 2013, 8:50:39 AM5/28/13
to std-pr...@isocpp.org

W dniu wtorek, 28 maja 2013 12:37:43 UTC+2 użytkownik Jonathan Wakely napisał:
Concepts Lite will add constexpr functions that allow Is_default_constructible<T>() and Is_same<T, U>(), do we need variables if we have those?  Is there any advantage to having both?  I would expect a proposal to include some discussion of that.



With the acceptance of the operator() for integral_constant, the both proposal may be merged by declaring:
template<typename T>
constexpr is_bind_expression<T> Is_bind_expression;


Then Is_bind_expression<T> will be both convertible to bool (via constexpr conversion operator) and expression Is_bind_expression<T>() used by Concepts-lite will be well-formed.

Vicente J. Botet Escriba

unread,
May 28, 2013, 12:41:13 PM5/28/13
to std-pr...@isocpp.org
Le 28/05/13 12:37, Jonathan Wakely a �crit :
I would expect that concept lite accept template bool variables in the
same way it accepts constexpr nullary boolean functions. As variables
don't need the "()" I think it is enough to support the variable form.

The problem on the current experimentation with ConceptLite is that we
don't have yet template variables.

Vicente

Vicente J. Botet Escriba

unread,
May 28, 2013, 12:46:11 PM5/28/13
to std-pr...@isocpp.org
Le 28/05/13 14:50, toma...@gmail.com a �crit�:

W dniu wtorek, 28 maja 2013 12:37:43 UTC+2 u�ytkownik Jonathan Wakely napisa�:
Concepts Lite will add constexpr functions that allow Is_default_constructible<T>() and Is_same<T, U>(), do we need variables if we have those?ďż˝ Is there any advantage to having both?ďż˝ I would expect a proposal to include some discussion of that.



With the acceptance of the operator() for integral_constant, the both proposal may be merged by declaring:
template<typename T>
constexpr is_bind_expression<T> Is_bind_expression;


Then Is_bind_expression<T> will be both convertible to bool (via constexpr conversion operator) and expression Is_bind_expression<T>() used by Concepts-lite will be well-formed.

Interesting, but I'm not sure ConceptLite would accept it as shortcut

ďż˝ template <Is_bind_expression T> f(T);

Otherwise I would expect that this could be used in the requires clause, even without "()"

ďż˝ template <typename T>ďż˝
ďż˝ requites Is_bind_expression<T>
ďż˝ f(T);

Vicente
Reply all
Reply to author
Forward
0 new messages