From 5210795599868648942
X-Google-Thread: 7894ca11fe,cc8aa11441b7bb9c
X-Google-Attributes: gid7894ca11fe,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,UTF8
Path: g2news1.google.com!news1.google.com!news.glorb.com!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: "Johannes Schaub (litb)" <schaub-johannes@web.de>
Newsgroups: comp.std.c++
Subject: Re: Getting rid of "typename ...::type" for some cases?
Followup-To: comp.std.c++
Date: Mon,  8 Feb 2010 22:27:41 CST
Organization: T-Online
Lines: 39
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <hkq58n$eld$03$1@news.t-online.com>
References: <hk6feu$un6$00$1@news.t-online.com>
  <7bade475-2428-4066-8660-5707eeff2019@h2g2000yqj.googlegroups.com>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain; charset="UTF-8"
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Tue, 09 Feb 2010 00:04:15 +0100
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Xref: g2news1.google.com comp.std.c++:2194

Daniel Krügler wrote:

> On 1 Feb., 18:38, "Johannes Schaub (litb)" <schaub-johan...@web.de>
> wrote:
>> I wonder whether it would be possible to get rid of "typename
>> <tmp>::type" for the most common cases (enable_if (?))
>>
>> template<bool C, typename T = void>
>> using enable_if = typename enable_if<C, T>::type;
>>
>> Does that allow the following?
>>
>> template<typename T>
>> enable_if<is_pointer<T>::value> f();
>>
>> If it does, has it been considered to make it that way?
> 
> I don't think that you can reintroduce the name enable_if,
> but except for this the approach looks both feasible and
> nice to me. Regarding your second question: I don't
> think that it has been considered - nice idea.
> 

I think were it would be most useful is for std::identity. I find myself
using it alot, and allowing for shorter typing would be very nice. I'm
thinking of "alias" or something similar:

alias<char[1]> &f();
operator alias<void()>*();
template<typename T> T implicit_cast(alias<T> t) { return t; }
f(alias<unsigned char>());


-- 
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



