You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Eric Lemings <Er...@roguewave.com> on 2008/06/10 18:12:45 UTC
An internal add_const_reference type trait
Travis,
According to our plans for type traits, is this how you would define an
internal class template that combines the add_const<T> and
add_reference<T> type modifiers?
#include <rw/_type_traits.h>
_RWSTD_NAMESPACE (__rw) {
template <class _TypeT>
class __rw_add_const_ref
{
typedef _TYPENAME __rw_add_const<_TypeT>::type _ConstT;
public:
typedef _TYPENAME __rw_add_reference<_ConstT>::type type;
};
} // namespace __rw
Also, it'd be nice if you jot down some of these plans for type traits
on the C++0x Wiki <http://wiki.apache.org/stdcxx/Cpp0x>; e.g., header
names, internal utilities, TODO work, etc. ;)
Thanks,
Brad.
RE: An internal add_const_reference type trait
Posted by Travis Vitek <Tr...@roguewave.com>.
Eric Lemings wrote:
>
>Travis Vitek wrote:
>>
>> >Eric Lemings wrote:
>> >
>> >Travis,
>> >
>> >According to our plans for type traits, is this how you
>> would define an
>> >internal class template that combines the add_const<T> and
>> >add_reference<T> type modifiers?
>> >
>> > #include <rw/_type_traits.h>
>> >
>> > _RWSTD_NAMESPACE (__rw) {
>> >
>> > template <class _TypeT>
>> > class __rw_add_const_ref
>> > {
>> > typedef _TYPENAME __rw_add_const<_TypeT>::type _ConstT;
>> >
>> > public:
>> >
>> > typedef _TYPENAME __rw_add_reference<_ConstT>::type type;
>> > };
>> >
>> > } // namespace __rw
>> >
>>
>> It is really close. I'd probably make it a struct and if
>there was any
>> complicated logic it would move into an impl struct to reduce
>> clutter in
>> the outer class.
>>
>> If you need the above trait, I should let you know that TR1 had
>> add_reference, but C++0x replaces that with add_lvalue_reference and
>> add_rvalue_reference. So it you should probably use the new
>> names as we
>> probably won't have an __rw_add_reference trait.
>>
>> #include <rw/_typetraits.h>
>>
>> _RWSTD_NAMESPACE (__rw) {
>>
>> template <class _TypeT>
>> struct __rw_add_const_ref
>> {
>> typedef _TYPENAME __rw_add_lval_ref<
>> _TYPENAME __rw_add_const<_TypeT>::type
>> >::type type;
>> };
>>
>> } // namespace __rw
>
>Actually, wouldn't this be even better?
>
> template <class _TypeT>
> struct __rw_add_const_ref
> : __rw_add_lval_ref<_RWSTD_ADD_CONST(_TypeT)> { };
>
Ah yes, assuming that I continue to provide the macros. :)
>Brad.
>
RE: An internal add_const_reference type trait
Posted by Eric Lemings <Er...@roguewave.com>.
> -----Original Message-----
> From: Travis Vitek [mailto:Travis.Vitek@roguewave.com]
> Sent: Tuesday, June 10, 2008 10:34 AM
> To: dev@stdcxx.apache.org
> Subject: RE: An internal add_const_reference type trait
>
>
>
> >Eric Lemings wrote:
> >
> >Travis,
> >
> >According to our plans for type traits, is this how you
> would define an
> >internal class template that combines the add_const<T> and
> >add_reference<T> type modifiers?
> >
> > #include <rw/_type_traits.h>
> >
> > _RWSTD_NAMESPACE (__rw) {
> >
> > template <class _TypeT>
> > class __rw_add_const_ref
> > {
> > typedef _TYPENAME __rw_add_const<_TypeT>::type _ConstT;
> >
> > public:
> >
> > typedef _TYPENAME __rw_add_reference<_ConstT>::type type;
> > };
> >
> > } // namespace __rw
> >
>
> It is really close. I'd probably make it a struct and if there was any
> complicated logic it would move into an impl struct to reduce
> clutter in
> the outer class.
>
> If you need the above trait, I should let you know that TR1 had
> add_reference, but C++0x replaces that with add_lvalue_reference and
> add_rvalue_reference. So it you should probably use the new
> names as we
> probably won't have an __rw_add_reference trait.
>
> #include <rw/_typetraits.h>
>
> _RWSTD_NAMESPACE (__rw) {
>
> template <class _TypeT>
> struct __rw_add_const_ref
> {
> typedef _TYPENAME __rw_add_lval_ref<
> _TYPENAME __rw_add_const<_TypeT>::type
> >::type type;
> };
>
> } // namespace __rw
Actually, wouldn't this be even better?
template <class _TypeT>
struct __rw_add_const_ref
: __rw_add_lval_ref<_RWSTD_ADD_CONST(_TypeT)> { };
Brad.
RE: An internal add_const_reference type trait
Posted by Travis Vitek <Tr...@roguewave.com>.
>Eric Lemings wrote:
>
>Travis,
>
>According to our plans for type traits, is this how you would define an
>internal class template that combines the add_const<T> and
>add_reference<T> type modifiers?
>
> #include <rw/_type_traits.h>
>
> _RWSTD_NAMESPACE (__rw) {
>
> template <class _TypeT>
> class __rw_add_const_ref
> {
> typedef _TYPENAME __rw_add_const<_TypeT>::type _ConstT;
>
> public:
>
> typedef _TYPENAME __rw_add_reference<_ConstT>::type type;
> };
>
> } // namespace __rw
>
It is really close. I'd probably make it a struct and if there was any
complicated logic it would move into an impl struct to reduce clutter in
the outer class.
If you need the above trait, I should let you know that TR1 had
add_reference, but C++0x replaces that with add_lvalue_reference and
add_rvalue_reference. So it you should probably use the new names as we
probably won't have an __rw_add_reference trait.
#include <rw/_typetraits.h>
_RWSTD_NAMESPACE (__rw) {
template <class _TypeT>
struct __rw_add_const_ref
{
typedef _TYPENAME __rw_add_lval_ref<
_TYPENAME __rw_add_const<_TypeT>::type
>::type type;
};
} // namespace __rw
>Also, it'd be nice if you jot down some of these plans for type traits
>on the C++0x Wiki <http://wiki.apache.org/stdcxx/Cpp0x>; e.g., header
>names, internal utilities, TODO work, etc. ;)
Yes, I know. Given that discussion on the topic has died down I could
actually document what we've arrived at.
>
>Thanks,
>Brad.
>