Topic: constexpr_if for specializing data members


Author: rhalbersma@gmail.com
Date: Thu, 12 Nov 2015 13:53:46 -0800 (PST)
Raw View
------=_Part_899_761736926.1447365226906
Content-Type: multipart/alternative;
 boundary="----=_Part_900_1071770446.1447365226906"

------=_Part_900_1071770446.1447365226906
Content-Type: text/plain; charset=UTF-8

Will the constexpr_if feature allow specializing data members in class
templates? So instead of having to specialize class templates, or having to
derive from std::conditional_t, one could do a constexpr_if at class scope
to switch between different implementations (enabling logging/caching
etc.), or different storage containers (deque/vector/list)


--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_900_1071770446.1447365226906
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Will the constexpr_if feature allow specializing data memb=
ers in class templates? So instead of having to specialize class templates,=
 or having to derive from std::conditional_t, one could do a constexpr_if a=
t class scope to switch between different implementations (enabling logging=
/caching etc.), or different storage containers (deque/vector/list)<div><br=
></div><div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_900_1071770446.1447365226906--
------=_Part_899_761736926.1447365226906--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 12 Nov 2015 14:01:41 -0800
Raw View
--001a1140c11a7ec02f05245f165b
Content-Type: text/plain; charset=UTF-8

On Thu, Nov 12, 2015 at 1:53 PM, <rhalbersma@gmail.com> wrote:

> Will the constexpr_if feature allow specializing data members in class
> templates? So instead of having to specialize class templates, or having to
> derive from std::conditional_t, one could do a constexpr_if at class scope
> to switch between different implementations (enabling logging/caching
> etc.), or different storage containers (deque/vector/list)
>

No. It's not permitted anywhere a non-constexpr if is not permitted.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a1140c11a7ec02f05245f165b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Nov 12, 2015 at 1:53 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:rhalb=
ersma@gmail.com" target=3D"_blank">rhalbersma@gmail.com</a>&gt;</span> wrot=
e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Will the constexpr_if=
 feature allow specializing data members in class templates? So instead of =
having to specialize class templates, or having to derive from std::conditi=
onal_t, one could do a constexpr_if at class scope to switch between differ=
ent implementations (enabling logging/caching etc.), or different storage c=
ontainers (deque/vector/list)</div></blockquote><div><br></div><div>No. It&=
#39;s not permitted anywhere a non-constexpr if is not permitted.</div></di=
v></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a1140c11a7ec02f05245f165b--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 12 Nov 2015 14:03:59 -0800
Raw View
On Thursday 12 November 2015 13:53:46 rhalbersma@gmail.com wrote:
> Will the constexpr_if feature allow specializing data members in class
> templates? So instead of having to specialize class templates, or having to
> derive from std::conditional_t, one could do a constexpr_if at class scope
> to switch between different implementations (enabling logging/caching
> etc.), or different storage containers (deque/vector/list)

P0128 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0128r0.html)
does not show any inclination towards constexpr_if being usable outside of a
function, but N3329 did. In fact, it said "A static if declaration can appear
wherever a declaration or a statement is legal."

If the implementation of constexpr_if resembles that of what N3329 proposed,
yes, you could use it to decide on members.

But that's not a guarantee. The biggest problem with static if was that it was
overly broad, so constexpr_if shrinks its scope.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.