Topic: Could we use T:X to abbreviate "typename T::X"? (and get


Author: SG<s.gesemann@googlemail.com>
Date: Wed, 27 Feb 2013 09:05:37 -0800 (PST)
Raw View
On Jan 23, 12:26 am, Daniel Kr   gler wrote:
>  Am 22.01.2013 17:54, schrieb Walter Mascarenhas:
>  >  When I use constructs like std::enable_if my code gets polluted with many typenames,
>  >  as in
>  >
>  >  typename std::enable_if<    std::is_same<typename A::X, typename B::Y>::value,
>  >                             typename C::Z>::type

[snip]

>  template<bool C, class T = void>
>  using EnableIf = typename std::enable_if<C, T>::type;

Is the right hand side of this template alias considered an immediate
context with respect to SFINAE?

Cheers!
S.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Wed, 27 Feb 2013 10:52:35 -0800 (PST)
Raw View
Am 27.02.2013 18:05, schrieb SG:
>
> On Jan 23, 12:26 am, Daniel Kr   gler wrote:
> [snip]
>
>>   template<bool C, class T = void>
>>   using EnableIf = typename std::enable_if<C, T>::type;
>
>
> Is the right hand side of this template alias considered an immediate
> context with respect to SFINAE?


Let me start with a general remark in regard to "immediate context"
used in 14.8: The Standard committee had introduced this term knowing
that this is a fuzzy definition. In regard to alias templates the
wording *could* be interpreted as if the "definition of alias would be
a different context. In general, this is not intended, because alias
substitution is supposed to happen very early. I think that this usage
of alias template is safe (and considered to be in the immediate
context) when you compare it with

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1558

The current suggestion is that

a) Substitution happens in the immediate context of the template that
had causes the substitution

b) Access checking (see CWG issue

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1554
) is performed in the context of the definition of alias template.

HTH & Greetings from Bremen,

Daniel Kr   gler



--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Tue, 22 Jan 2013 15:26:32 -0800 (PST)
Raw View
Am 22.01.2013 17:54, schrieb Walter Mascarenhas:
>
>
> When I use constructs like std::enable_if my code gets polluted with many typenames, as in
>
> typename std::enable_if<  std::is_same<typename A::X, typename B::Y>::value,
>                           typename C::Z>::type
>
> Would it be too costly to introduce a symbol, say ':', in the language so
> that "T:X" is an abbreviation for "typename T::X"?


An alternative solution without need of any further language
extensions is the usage of a template alias instead. Typical examples
are:

template<bool C, class T = void>
using EnableIf = typename std::enable_if<C, T>::type;

HTH & Greetings from Bremen,

Daniel Kr   gler




--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: Walter Mascarenhas<walter.mascarenhas@googlemail.com>
Date: Thu, 24 Jan 2013 15:15:38 -0800 (PST)
Raw View
On Tuesday, January 22, 2013 9:26:32 PM UTC-2, Daniel Kr   gler wrote:
>  Am 22.01.2013 17:54, schrieb Walter Mascarenhas:
>
>
>  >  When I use constructs like std::enable_if my code gets polluted with many typenames, as in
>  >  typename std::enable_if<   std::is_same<typename A::X, typename B::Y>::value,
>  >                            typename C::Z>::type
>

>  >  Would it be too costly to introduce a symbol, say ':', in the language so
>  >  that "T:X" is an abbreviation for "typename T::X"?
>
>
>  An alternative solution without need of any further language
>  extensions is the usage of a template alias instead. Typical examples
>  are:
>
>  template<bool C, class T = void>
>  using EnableIf = typename std::enable_if<C, T>::type;
>
>
>  HTH&  Greetings from Bremen,
>
>
>
>  Daniel Kr   gler
>


Thanks for the reply. This is indeed a
good alternative for people with good
compilers.

Unfortunately I am stuck with Visual C++
and won't be able to apply this solution
for a while. Of course microsoft is the
one to blame here and people in this
list shouldn't worry about this question.

Greetings from Brazil,

         walter.




>
>
>  --
>
>  [ comp.std.c++ is moderated.  To submit articles, try posting with your ]
>
>  [ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
>
>  [              --- Please see the FAQ before posting. ---               ]
>
>  [ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]