Topic: Proposal for generic rebind template


Author: Charles Salvia <charles.a.salvia@gmail.com>
Date: Sat, 16 Jun 2018 19:25:18 -0700 (PDT)
Raw View
------=_Part_13511_499786151.1529202318135
Content-Type: multipart/alternative;
 boundary="----=_Part_13512_626479861.1529202318136"

------=_Part_13512_626479861.1529202318136
Content-Type: text/plain; charset="UTF-8"

A Proposal to Add a Generic Rebind Template

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org.

------=_Part_13512_626479861.1529202318136
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><h1 style=3D"color: rgb(0, 0, 0); font-family: &quot;Times=
 New Roman&quot;;">A Proposal to Add a Generic Rebind Template</h1><div><br=
></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd=
%40isocpp.org</a>.<br />

------=_Part_13512_626479861.1529202318136--

------=_Part_13511_499786151.1529202318135
Content-Type: text/html; charset=US-ASCII; name=CPP-REBIND-PROPOSAL.htm
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=CPP-REBIND-PROPOSAL.htm
X-Attachment-Id: 54854c71-38ad-40a4-8c9f-c12a32654c18
Content-ID: <54854c71-38ad-40a4-8c9f-c12a32654c18>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>A Proposal to Add a Generic Rebind Template to the Stand=
ard Library Technical Report</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<style type =3D "text/css">
..cpp-type {
  color: green;
}
..keyword {
  color: blue;
}
..comment {
  color: gray;
}
</style>
</HEAD>
<BODY><FONT size=3D-1>Charles Salvia &lt;csalvia@bloomberg.net&gt; <BR>6 Ju=
n 2018
<BR>Doc number  N0000=3D18-0605</FONT>

<H1>A Proposal to Add a Generic Rebind Template to the Standard Library Tec=
hnical Report</H1>

<H2>I. Motivation</H2>

<p>C++ meta-programming facilities often require rebinding (substituting) t=
he template arguments of an existing instantiation of a class template with=
 different types.  The earliest standardized incarnation of this facility w=
as in <tt>std::allocator&lt;T&gt;::rebind</tt>, which enabled a container c=
lass to substitute the first parameter of an allocator class template with =
some arbitrary type.  More recently, the <tt>std::allocator_traits</tt> cla=
ss template has employed both <tt>std::allocator_traits&lt;T&gt;::rebind_al=
loc</tt> and <tt>std::allocator_traits&lt;T&gt;::rebind_traits</tt> to prov=
ide similar flexibility.</p>
<p>Often it is necessary to create arbitrary rebind templates for custom me=
ta-programming facilities.  This proposal proposes the inclusion of a <i>ge=
neric</i> rebind alias template, <tt>std::rebind_t</tt>, to enable the conv=
enient arbitrary substitution of template parameters.

<h4>Trivial Example:</h4>

Given:

<blockquote>
<pre>
<span class=3D'keyword'>using</span> vec_type =3D std::vector&lt;<span clas=
s=3D'cpp-type'>double</span>, std::allocator&lt;<span class=3D'cpp-type'>do=
uble</span>&gt;&gt;;
</pre>
</blockquote>

We can rebind the vector type to a different template argument by doing:

<blockquote>
<pre>
<span class=3D'keyword'>using</span> new_vec_type =3D std::rebind_t&lt;vec_=
type, <span class=3D'cpp-type'>std::string</span>&gt;;
</pre>
</blockquote>

Which produces the type:

<blockquote>
<pre>
std::vector&lt;<span class=3D'cpp-type'>std::string</span>, std::allocator&=
lt;<span class=3D'cpp-type'>std::string</span>&gt;&gt;;
</pre>
</blockquote>

<h4>More Complex Example:</h4>

The generic template <tt>std::rebind_t</tt> works with any arbitrary number=
 of template arguments.  Arguments are rebound in positional left-to-right =
order, with omitted right-hand arguments automatically replaced with their =
original types. If an omitted right-hand argument has a default template ar=
gument that refers to a prior rebound argument to the left, all references =
to that argument are substituted with the new rebound argument.
<br>
<br>
For example, given class template <tt>alloc</tt>, class template <tt>C</tt>=
, and classes <tt>X</tt>, <tt>Y</tt> and <tt>Z</tt>, defined as:
<blockquote>
<pre>
<span class=3D'keyword'>template</span> &lt;<span class=3D'keyword'>class</=
span> T&gt;
<span class=3D'keyword'>struct</span> alloc {};

<span class=3D'keyword'>template</span> &lt;<span class=3D'keyword'>class</=
span> A, <span class=3D'keyword'>class</span> B, <span class=3D'keyword'>cl=
ass</span> C, <span class=3D'keyword'>class</span> D =3D alloc&lt;A&gt, <sp=
an class=3D'keyword'>class</span> E =3D alloc&lt;B&gt, <span class=3D'keywo=
rd'>class</span> F =3D alloc&lt;C&gt&gt;
<span class=3D'keyword'>struct</span> C {};

<span class=3D'keyword'>struct</span> X {};
<span class=3D'keyword'>struct</span> Y {};
<span class=3D'keyword'>struct</span> Z {};
</pre>
</blockquote>

Applying <tt>std::rebind_t</tt> produces the following type transformations=
:

<blockquote>
<table cellpadding =3D "2" border =3D "1">
<tr>
=09<td><pre><b>Rebind expression</b></pre></td><td><pre><b>New type</b></pr=
e></td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt;, X&gt;
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;X, <span class=3D'cpp-type'>float</span>, <span class=3D'cpp-type'>dou=
ble</span>, alloc&lt;X&gt;, alloc&lt;<span class=3D'cpp-type'>float</span>&=
gt;, alloc&lt;<span class=3D'cpp-type'>double</span>&gt;&gt;;
</pre>
=09</td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt;, X, Y&gt=
;
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;X, Y, <span class=3D'cpp-type'>double</span>, alloc&lt;X&gt;, alloc&lt=
;Y&gt;, alloc&lt;<span class=3D'cpp-type'>double</span>&gt;&gt;;
</pre>
=09</td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt;, X, Y, Z=
&gt;
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;X, Y, Z, alloc&lt;X&gt;, alloc&lt;Y&gt;, alloc&lt;Z&gt;&gt;;
</pre>
=09</td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt;, X, Y, Z=
, <span class=3D'cpp-type'>std::string</span>&gt;
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;X, Y, Z, <span class=3D'cpp-type'>std::string</span>, alloc&lt;Y&gt;, =
alloc&lt;Z&gt;&gt;;
</pre>
=09</td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt;, X, Y, Z=
, <span class=3D'cpp-type'>std::string</span>, alloc&lt;<span class=3D'cpp-=
type'>char</span>&gt;&gt;
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;X, Y, Z, <span class=3D'cpp-type'>std::string</span>, alloc&lt;<span c=
lass=3D'cpp-type'>char</span>&gt;, alloc&lt;Z&gt;&gt;;
</pre>
=09</td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt;, X, Y, Z=
, <span class=3D'cpp-type'>std::string</span>, alloc&lt;<span class=3D'cpp-=
type'>char</span>&gt;, <span class=3D'cpp-type'>void</span>&gt;
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;X, Y, Z, <span class=3D'cpp-type'>std::string</span>, alloc&lt;<span c=
lass=3D'cpp-type'>char</span>&gt;, <span class=3D'cpp-type'>void</span>&gt;=
;
</pre>
=09</td>
</tr>
<tr>
=09<td valign=3D"top">
<pre>
std::rebind_t&lt;C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'=
cpp-type'>float</span>, <span class=3D'cpp-type'>double</span>&gt; &gt; <sp=
an class=3D'comment'>/* zero arguments */</span>
<pre>
=09</td>
=09<td valign=3D"top">
<pre>
C&lt;<span class=3D'cpp-type'>long</span>, <span class=3D'cpp-type'>float</=
span>, <span class=3D'cpp-type'>double</span>, alloc&lt;<span class=3D'cpp-=
type'>long</span>&gt;, alloc&lt;<span class=3D'cpp-type'>float</span>&gt;, =
alloc&lt;<span class=3D'cpp-type'>double</span>&gt;&gt;;
</pre>
=09</td>
</tr>
</table>
</blockquote>

<p>The generic <tt>std::rebind_t</tt> template could be used in place of <t=
t>std::allocator_traits::rebind_alloc</tt>, or in any other context where t=
emplate parameters need to be rebound for a specific instantiation.</p>

<blockquote>
<pre>
<span class=3D'keyword'>template</span> &lt;<span class=3D'keyword'>class</=
span> T, <span class=3D'keyword'>class</span> Allocator =3D std::allocator&=
lt;T&gt;&gt;
<span class=3D'keyword'>class</span> LinkedList
{
  <span class=3D'keyword'>struct</span> internal_node;

  <span class=3D'keyword'>using</span> internal_allocator_type =3D std::reb=
ind_t&lt;Allocator, internal_node&gt;;

  ...
};
</pre>
</blockquote>

<H2>II. Impact On the Standard</H2>

<p>This proposal is a pure library extension. It does not require changes t=
o any standard classes, functions or headers.  It has been implemented in s=
tandard C++14.</p>


<H2>III. Implementation Considerations</H2>

<p>The <tt>rebind_t</tt> alias template must take into account the number o=
f default template arguments in a given class template <tt>C</tt>.  Therefo=
re, it must be possible in standard C++ to programatically count the number=
 of default template arguments in an arbitrary class template.  This can be=
 accomplished using any method that exploits substitution failure, such as =
the use of <tt>std::void_t</tt>, to iteratively attempt to instantiate the =
class template with a decreasing number of template arguments, until substi=
tution failure occurs.  At that point, the number of default template argum=
ents can be inferred.</p>

<H2>IV. Proposed Text</H2>
<h3>Append to <tt>23.15.7.6</tt>  <tt>[meta.trans.other]</tt></h3>
<blockquote><tt><pre>
namespace std {

  <span class =3D 'keyword'>template</span> &lt;<span class =3D 'keyword'>c=
lass</span> C, <span class =3D 'keyword'>class</span>... Params&gt;
  <span class =3D 'keyword'>using</span> rebind_t =3D <span class=3D'commen=
t'>/* implementation defined */</span> ;

  ...
}
</pre></tt></blockquote>

<h3>Append to <tt>23.15.7.6</tt> <tt>[meta.trans.other] Table 50</tt>

<blockquote>
<table cellpadding =3D "2" border =3D "1">
<tr>
<td valign =3D "top">
<pre>
template &lt;class C, class</span>... T&gt;
using rebind_t =3D <i>implementation-defined</i>;
</pre>
</td>
<td valign =3D "top">
If class <tt>C</tt> is not a class template instantiation or alias template=
, the program is ill-formed.  The expression <tt>rebind_t&lt;C, T...&gt;</t=
t> substitutes the template arguments of class <tt>C</tt> with the paramete=
r pack <tt>T</tt> in left-to-right order.  If <tt>sizeof... T</tt> is less =
than the number of template parameters of <tt>C</tt>, then the omitted righ=
t-hand-side template parameters are replaced with the positionally-correspo=
nding original types in class template <tt>C</tt>, or, if an omitted right-=
hand-side argument corresponds positionally to the <tt><i>i</i>th</tt> temp=
late parameter of <tt>C</tt> that has a default template argument, and the =
default template argument is an <i>id-expression</i> (8.1.4) that refers to=
 a prior parameter of <tt>C</tt> that was replaced with a positionally corr=
esponding argument <tt>T<sub>j</sub></tt> in the parameter pack <tt>T</tt>,=
 then all references to the prior template parameter of <tt>C</tt> in the <=
i>id-expression</i> are substituted with the type <tt>T<sub>j</sub></tt>. =
=20
</td>
</tr>
</table>
</blockquote>

<H2>IV. Future Work</H2>

<p>
The alias template <tt>std::rebind_t</tt> is specified to substitute templa=
te arguments in left-to-right, positional order.  It may be desirable to re=
place the <i>i</i>th argument of a class template instantiation, while leav=
ing some prior arguments as their original types without having to explicit=
ly specify the original type.  This could be achieved by a special <i>place=
holder</i> type, similar to the placeholder types used with <tt>std::bind</=
tt>.  Using the placeholder type with <tt>std::rebind_t&lt;C, T...&gt;</tt>=
 would construct a new type where each template argument of class template =
<tt>C</tt> that corresponds positionally with the <i>placeholder expression=
</i> in the parameter pack <tt>T</tt> would remain as original the template=
 argument in <tt>C</tt>.
</p>
<br>
<br>
<br>
</BODY>
</HTML>

------=_Part_13511_499786151.1529202318135
Content-Type: text/x-c++hdr; charset=US-ASCII; name=rebind.hpp
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=rebind.hpp
X-Attachment-Id: 42854b54-01d9-4436-8592-0baf9f9bc564
Content-ID: <42854b54-01d9-4436-8592-0baf9f9bc564>

#ifndef STD_REBIND_HPP
#define STD_REBIND_HPP

// std::rebind_t implementation
// Author: Charles Salvia, csalvia@bloomberg.net

#include <type_traits>
#include <tuple>

namespace std { namespace experimental {

namespace detail {

 // Implementation of void_t for pre-C++17 compilers
 //
 template <class... T>
 struct void_t_impl
 {
  typedef void type;
 };

 template <class... T>
 using void_t = typename detail::void_t_impl<T...>::type;


 template <class C, class ParameterTuple, class Enable = void>
 struct instantiate_from_tuple
 { };

 template <
  template <class...> class C,
  class... Params1,
  class... Params2
 >
 struct instantiate_from_tuple<
  C<Params1...>,
  std::tuple<Params2...>,
  void_t<C<Params2...>>
 >
 {
  using type = C<Params2...>;
 };

 template <class C, class ParameterTuple>
 using instantiate_from_tuple_t = typename instantiate_from_tuple<
  C,
  ParameterTuple
 >::type;

 // Helper meta-function to determine the number of default template arguments in a class
 // template.  Here we attempt to instantiate class template C with a decreasing number
 // of template parameters, until a substitution failure occurs, at which point we
 // can infer the number of default template arguments.
 //
 template <class C, class ParamTuple, std::size_t Count, class Void = void, class Enable = void>
 struct default_argument_count_impl
 {
  constexpr static std::size_t value = Count;
 };

 // Helper templates to pop the last type from a tuple type
 //
 template <class Tuple>
 struct pop_back_impl;

 template <class Tuple, class... Args>
 struct do_pop_back;

 template <class... Args1, class T, class... Args2>
 struct do_pop_back<std::tuple<Args1...>, T, Args2...>
 {
  using type = typename do_pop_back<std::tuple<Args1..., T>, Args2...>::type;
 };

 template <class... Args, class T>
 struct do_pop_back<std::tuple<Args...>, T>
 {
  using type = std::tuple<Args...>;
 };

 template <class... Args>
 struct pop_back_impl<std::tuple<Args...>>
 {
  using type = typename do_pop_back<std::tuple<>, Args...>::type;
 };

 // Attempt to pop the last type from a tuple type, or trigger a substitution failure
 //
 template <class Tuple, class Enable = void>
 struct pop_back_or_substitution_failure
 { };

 template <class Tuple>
 struct pop_back_or_substitution_failure<
  Tuple,
  typename std::enable_if<
   std::tuple_size<Tuple>::value != 0
  >::type
 >
 {
  using type = typename pop_back_impl<Tuple>::type;
 };

 template <
  class... Params1,
  template <class...> class C,
  class... Params2,
  std::size_t Count
 >
 struct default_argument_count_impl<
  C<Params1...>,
  std::tuple<Params2...>,
  Count,
  void_t<
   instantiate_from_tuple_t<
    C<Params1...>,
    typename pop_back_or_substitution_failure<std::tuple<Params2...>>::type
   >
  >
 >
 {
  constexpr static std::size_t value = default_argument_count_impl<
   instantiate_from_tuple_t<
    C<Params1...>,
    typename pop_back_or_substitution_failure<std::tuple<Params2...>>::type
   >,
   typename pop_back_or_substitution_failure<std::tuple<Params2...>>::type,
   Count + 1
  >::value;
 };

 template <class C>
 struct default_argument_count;

 template <
  template <class...> class C,
  class... Params
 >
 struct default_argument_count<C<Params...>>
 {
  constexpr static std::size_t value = default_argument_count_impl<
   C<Params...>,
   std::tuple<Params...>,
   0
  >::value;
 };

 template <class C>
 struct template_parameters
 {
  using parameters = std::tuple<>;
 };

 template <
  template <class...> class C,
  class... Params1
 >
 struct template_parameters<C<Params1...>>
 {
  template <class... Params2, std::size_t... I>
  static auto rebind(
   std::tuple<Params2...>,
   std::index_sequence<I...>
  )
   ->
    C<
     Params2...,
     std::tuple_element_t<
      I + sizeof... (Params2),
      std::tuple<Params1...>
     >...
    >
  ;

  using parameters = std::tuple<Params1...>;
 };

 namespace static_test {

  template <class A = void, class B = void, class C = void, class D = void, class E = void>
  struct C1 { };

  template <class A, class B = void, class C = void, class D = void, class E = void>
  struct C2 { };

  template <class A, class B, class C = void, class D = void, class E = void>
  struct C3 { };

  template <class A, class B, class C, class D = void, class E = void>
  struct C4 { };

  template <class A, class B, class C, class D, class E = void>
  struct C5 { };

  template <class A, class B, class C, class D, class E>
  struct C6 { };

  static_assert(
   detail::default_argument_count<C1<int,int,int,int,int>>::value == 5,
   "Internal library error"
  );

  static_assert(
   detail::default_argument_count<C2<int,int,int,int,int>>::value == 4,
   "Internal library error"
  );

  static_assert(
   detail::default_argument_count<C3<int,int,int,int,int>>::value == 3,
   "Internal library error"
  );

  static_assert(
   detail::default_argument_count<C4<int,int,int,int,int>>::value == 2,
   "Internal library error"
  );

  static_assert(
   detail::default_argument_count<C5<int,int,int,int,int>>::value == 1,
   "Internal library error"
  );

  static_assert(
   detail::default_argument_count<C6<int,int,int,int,int>>::value == 0,
   "Internal library error"
  );

 } // end namespace static_test

} // end namespace detail


// Retrieve the Nth template parameter type from class template C
//
template <class C, std::size_t N>
struct template_parameter
{
 using type = typename std::tuple_element<
  N,
  typename detail::template_parameters<C>::parameters
 >::type;
};

template <class C, std::size_t N>
using template_param_t = typename template_parameter<
 C,
 N
>::type;

// Retrieve the number of template parameters associated with class template C
//
template <class C>
struct template_parameter_count
{
 constexpr static std::size_t value = std::tuple_size<
  typename detail::template_parameters<C>::parameters
 >::value;
};

// Determine if class C is a class template
//
template <class C>
struct is_template
 :
 std::integral_constant<
  bool,
  template_parameter_count<C>::value != 0
 >
{ };

namespace detail {

 template <class C, class ParameterTuple, class Enable = void>
 struct rebind_impl
 {
  static_assert(
   is_template<C>::value,
   "Class used with rebind_t is not a class template"
  );
 };

 template <template <class...> class C, class... Params1, class... Params2>
 struct rebind_impl<
  C<Params1...>,
  std::tuple<Params2...>,
  typename std::enable_if<
   (sizeof...(Params1) != 1) && (sizeof...(Params2) != 0)
  >::type
 >
 {
  static_assert(
   sizeof...(Params1) >= sizeof... (Params2),
   "rebind_t: too many rebound template parameters"
  );

  constexpr static std::size_t old_params = sizeof... (Params1);
  constexpr static std::size_t new_params = sizeof...(Params2);
  constexpr static std::size_t num_defaults = detail::default_argument_count<
   C<Params1...>
  >::value;

  constexpr static std::size_t num_required = old_params - num_defaults;
  constexpr static std::size_t diff = old_params - new_params;
  constexpr static std::size_t seq_size = diff - (
   (new_params > num_required) ? (num_defaults - (new_params - num_required)) : num_defaults
  );

  using type = decltype(
   detail::template_parameters<C<Params1...>>::rebind(
    std::tuple<Params2...>{},
    std::make_index_sequence<seq_size>{}
   )
  );
 };

 template <template <class...> class C, class... Params1, class... Params2>
 struct rebind_impl<
  C<Params1...>,
  std::tuple<Params2...>,
  typename std::enable_if<(
   (sizeof...(Params1) == 1 && sizeof...(Params2) == 1)
  )>::type
 >
 {
  using type = C<Params2...>;
 };

 // ----- specialization for 0 rebound template parameters
 //
 template <template <class...> class C, class... Params1, class... Params2>
 struct rebind_impl<
  C<Params1...>,
  std::tuple<Params2...>,
  typename std::enable_if<(sizeof...(Params2) == 0)>::type
 >
 {
  using type = C<Params1...>;
 };

} // end namespace detail


// Rebind class template C to the specified parameter list
//
template <class C, class... Params>
struct rebind;

template <template <class...> class C, class... Params1, class... Params2>
struct rebind<
 C<Params1...>,
 Params2...
>
 : detail::rebind_impl<C<Params1...>, std::tuple<Params2...>>
{ };

template <class C, class... Params>
using rebind_t = typename rebind<C, Params...>::type;

namespace detail { namespace static_test {

 template <class T>
 struct alloc
 { };

 static_assert(
  std::is_same<
   rebind_t<alloc<int>, float>,
   alloc<float>
  >::value,
  "Internal library error"
 );

 template <class T = int>
 struct c0
 { };

 static_assert(
  std::is_same<
   rebind_t<c0<int>, float>,
   c0<float>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c0<int>>,
   c0<int>
  >::value,
  "Internal library error"
 );

 template <class A, class B, class C>
 struct a0
 { };

 static_assert(
  std::is_same<
   rebind_t<a0<int, float, double>, char, short, long>,
   a0<char, short, long>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<a0<int, float, double>, char, short>,
   a0<char, short, double>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<a0<int, float, double>, char>,
   a0<char, float, double>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<a0<int, float, double>>,
   a0<int, float, double>
  >::value,
  "Internal library error"
 );

 template <class T, class Alloc = alloc<T>>
 struct c1
 { };

 static_assert(
  std::is_same<
   rebind_t<c1<int>, float>,
   c1<float, alloc<float>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c1<int>, float, alloc<double>>,
   c1<float, alloc<double>>
  >::value,
  "Internal library error"
 );

 template <class A, class B, class C, class D = alloc<A>, class E = alloc<B>, class F = alloc<C>>
 struct c2
 { };

 struct X {};
 struct Y {};
 struct Z {};

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>>,
   c2<long, float, long double, alloc<long>, alloc<float>, alloc<long double>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>, X>,
   c2<X, float, long double, alloc<X>, alloc<float>, alloc<long double>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>, X, Y>,
   c2<X, Y, long double, alloc<X>, alloc<Y>, alloc<long double>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>, X, Y, Z>,
   c2<X, Y, Z, alloc<X>, alloc<Y>, alloc<Z>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>, X, Y, Z, float>,
   c2<X, Y, Z, float, alloc<Y>, alloc<Z>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>, X, Y, Z, float, alloc<float>>,
   c2<X, Y, Z, float, alloc<float>, alloc<Z>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>, X, Y, Z, float, alloc<float>, alloc<double>>,
   c2<X, Y, Z, float, alloc<float>, alloc<double>>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<c2<long, float, long double>>,
   c2<long, float, long double>
  >::value,
  "Internal library error"
 );


 template <class... T>
 struct B
 { };

 static_assert(
  std::is_same<
   rebind_t<B<int, long, float>, double>,
   B<double>
  >::value,
  "Internal library error"
 );

 static_assert(
  std::is_same<
   rebind_t<B<int, long, float>, double, char>,
   B<double, char>
  >::value,
  "Internal library error"
 );

} } // end namespace detail::static_test

} } // end namespace std::experimental

#endif



------=_Part_13511_499786151.1529202318135
Content-Type: text/x-c++src; charset=US-ASCII; name=rebind-test.cpp
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=rebind-test.cpp
X-Attachment-Id: df5c9453-dc60-4456-8fcc-6c6f96f96118
Content-ID: <df5c9453-dc60-4456-8fcc-6c6f96f96118>

#include "rebind.hpp"
#include <vector>
#include <string>

using vec_type1 = std::vector<int>;
using vec_type2 = std::experimental::rebind_t<vec_type1, std::string>;

static_assert(
 std::is_same<
  vec_type2,
  std::vector<std::string, std::allocator<std::string>>
 >::value,
 "Fail"
);

int main()
{
 // Test is compile-time only
}

------=_Part_13511_499786151.1529202318135--

.


Author: Manuel Bergler <berglerma@gmail.com>
Date: Sun, 17 Jun 2018 09:22:48 +0200
Raw View
--000000000000c7105d056ed159b6
Content-Type: text/plain; charset="UTF-8"

There is one major issue with this: C++ currently doesn't have a syntax to
refer to both type and non-type template parameters. Thus your variadic
rebind template doesn't work e.g. for std::array.

Best
Manuel

Am So., 17. Juni 2018 um 04:25 Uhr schrieb Charles Salvia <
charles.a.salvia@gmail.com>:

> A Proposal to Add a Generic Rebind Template
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAM76qmvuEgiO-NXjNMesTJuRnMpx4%3Dueot7i_RL27UY_WbiO3w%40mail.gmail.com.

--000000000000c7105d056ed159b6
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">There is one major issue with this: C++ currently doesn&#3=
9;t have a syntax to refer to both type and non-type template parameters. T=
hus your variadic rebind template doesn&#39;t work e.g. for std::array.<div=
><br></div><div>Best</div><div>Manuel</div></div><br><div class=3D"gmail_qu=
ote"><div dir=3D"ltr">Am So., 17. Juni 2018 um 04:25=C2=A0Uhr schrieb Charl=
es Salvia &lt;<a href=3D"mailto:charles.a.salvia@gmail.com">charles.a.salvi=
a@gmail.com</a>&gt;:<br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><h1 style=3D"color:rgb(0,0,0);font-family:&quot;Times New Roman&quot;">A=
 Proposal to Add a Generic Rebind Template</h1><div><br></div></div>

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-=
4ca5-b17f-db5ba21245dd%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAM76qmvuEgiO-NXjNMesTJuRnMpx4%3Dueot=
7i_RL27UY_WbiO3w%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAM76qmvuEgiO-N=
XjNMesTJuRnMpx4%3Dueot7i_RL27UY_WbiO3w%40mail.gmail.com</a>.<br />

--000000000000c7105d056ed159b6--

.


Author: Charles Salvia <charles.a.salvia@gmail.com>
Date: Mon, 18 Jun 2018 10:18:14 -0400
Raw View
--000000000000847f72056eeb3c1c
Content-Type: text/plain; charset="UTF-8"

True, unfortunately that's a language-level limitation

On Sun, Jun 17, 2018 at 3:22 AM, Manuel Bergler <berglerma@gmail.com> wrote:

> There is one major issue with this: C++ currently doesn't have a syntax to
> refer to both type and non-type template parameters. Thus your variadic
> rebind template doesn't work e.g. for std::array.
>
> Best
> Manuel
>
> Am So., 17. Juni 2018 um 04:25 Uhr schrieb Charles Salvia <
> charles.a.salvia@gmail.com>:
>
>> A Proposal to Add a Generic Rebind Template
>>
>> --
>> 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.
>> To view this discussion on the web visit https://groups.google.com/a/
>> isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-
>> b17f-db5ba21245dd%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/CAM76qmvuEgiO-NXjNMesTJuRnMpx4%3Dueot7i_
> RL27UY_WbiO3w%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAM76qmvuEgiO-NXjNMesTJuRnMpx4%3Dueot7i_RL27UY_WbiO3w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOZs%3DjKYB2JhvHB5O7x9%2BgbS0PMHTiqv-zKU%2B9iH1nb5W6Bpew%40mail.gmail.com.

--000000000000847f72056eeb3c1c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">True, unfortunately that&#39;s a language-level limitation=
</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Sun, Jun=
 17, 2018 at 3:22 AM, Manuel Bergler <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:berglerma@gmail.com" target=3D"_blank">berglerma@gmail.com</a>&gt;</span>=
 wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">There is one maj=
or issue with this: C++ currently doesn&#39;t have a syntax to refer to bot=
h type and non-type template parameters. Thus your variadic rebind template=
 doesn&#39;t work e.g. for std::array.<div><br></div><div>Best</div><div>Ma=
nuel</div></div><div><div class=3D"h5"><br><div class=3D"gmail_quote"><div =
dir=3D"ltr">Am So., 17. Juni 2018 um 04:25=C2=A0Uhr schrieb Charles Salvia =
&lt;<a href=3D"mailto:charles.a.salvia@gmail.com" target=3D"_blank">charles=
..a.salvia@gmail.com</a>&gt;:<br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><h1 style=3D"color:rgb(0,0,0);font-family:&quot;Times New Roman&=
quot;">A Proposal to Add a Generic Rebind Template</h1><div><br></div></div=
>

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/824b=
d50b-55f9-4ca5-<wbr>b17f-db5ba21245dd%40isocpp.org</a><wbr>.<br>
</blockquote></div>

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAM76qmvuEgiO-NXjNMesTJuRnMpx4%3Dueot=
7i_RL27UY_WbiO3w%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/st=
d-<wbr>proposals/CAM76qmvuEgiO-<wbr>NXjNMesTJuRnMpx4%3Dueot7i_<wbr>RL27UY_W=
biO3w%40mail.gmail.com</a><wbr>.<br>
</blockquote></div><br></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOZs%3DjKYB2JhvHB5O7x9%2BgbS0PMHTiqv=
-zKU%2B9iH1nb5W6Bpew%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOZs%3DjKY=
B2JhvHB5O7x9%2BgbS0PMHTiqv-zKU%2B9iH1nb5W6Bpew%40mail.gmail.com</a>.<br />

--000000000000847f72056eeb3c1c--

.


Author: Charles Salvia <charles.a.salvia@gmail.com>
Date: Mon, 18 Jun 2018 09:03:12 -0700 (PDT)
Raw View
------=_Part_20583_1760564402.1529337792820
Content-Type: multipart/alternative;
 boundary="----=_Part_20584_219462927.1529337792820"

------=_Part_20584_219462927.1529337792820
Content-Type: text/plain; charset="UTF-8"

*Updated draft proposal for generic rebind template:*

http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html


Implementation files:

https://github.com/charles-salvia/std-proposal-generic-template-rebind

This is a proposal to create a generic mechanism for rebinding template
parameters (std::rebind_t), to remove the need for ad-hoc rebind templates,
such as std::allocator_traits::rebind_alloc, etc.

As noted above by Manuel Bergler, the rebind_t template is necessarily
limited to type template parameters, as there is no way to express a
variadic template with an argument pack that contains some arbitrary
combination of both type and value parameters.


On Sunday, June 17, 2018 at 3:25:19 AM UTC-4, Manuel Bergler wrote:
>
> There is one major issue with this: C++ currently doesn't have a syntax to
> refer to both type and non-type template parameters. Thus your variadic
> rebind template doesn't work e.g. for std::array.
>
> Best
> Manuel
>
> Am So., 17. Juni 2018 um 04:25 Uhr schrieb Charles Salvia <
> charles....@gmail.com <javascript:>>:
>
>> A Proposal to Add a Generic Rebind Template
>>
>> --
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/eefbbc29-477c-403c-8cc1-361a17dc2653%40isocpp.org.

------=_Part_20584_219462927.1529337792820
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><b>Updated draft proposal for generic rebind template:</b>=
<div><br></div><div><a href=3D"http://charles-salvia.github.io/CPP-REBIND-P=
ROPOSAL.html">http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html</a><=
/div><div><br></div><div><br></div><div>Implementation files:</div><div><br=
></div><div><a href=3D"https://github.com/charles-salvia/std-proposal-gener=
ic-template-rebind">https://github.com/charles-salvia/std-proposal-generic-=
template-rebind</a></div><div><br></div><div>This is a proposal to create a=
 generic mechanism for rebinding template parameters (std::rebind_t), to re=
move the need for ad-hoc rebind templates, such as std::allocator_traits::r=
ebind_alloc, etc.=C2=A0</div><div><br></div><div>As noted above by Manuel B=
ergler, the rebind_t template is necessarily limited to type template param=
eters, as there is no way to express a variadic template with an argument p=
ack that contains some arbitrary combination of both type and value paramet=
ers.<br><br></div><br>On Sunday, June 17, 2018 at 3:25:19 AM UTC-4, Manuel =
Bergler wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
>There is one major issue with this: C++ currently doesn&#39;t have a synta=
x to refer to both type and non-type template parameters. Thus your variadi=
c rebind template doesn&#39;t work e.g. for std::array.<div><br></div><div>=
Best</div><div>Manuel</div></div><br><div class=3D"gmail_quote"><div dir=3D=
"ltr">Am So., 17. Juni 2018 um 04:25=C2=A0Uhr schrieb Charles Salvia &lt;<a=
 href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"3EoGjiZnAw=
AJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;retur=
n true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">charles=
.....@gmail.com</a>&gt;:<br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr"><h1 style=3D"color:rgb(0,0,0);font-family:&quot;Times New Roman&quot;=
">A Proposal to Add a Generic Rebind Template</h1><div><br></div></div>

<p></p>

-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
3EoGjiZnAwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"3EoGjiZnAwAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/824bd50b-55f9-4ca5-b17f-db5ba21245dd%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/824bd50b-55f9-4ca5-<wbr>b17f-=
db5ba21245dd%40isocpp.org</a><wbr>.<br>
</blockquote></div>
</blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/eefbbc29-477c-403c-8cc1-361a17dc2653%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eefbbc29-477c-403c-8cc1-361a17dc2653=
%40isocpp.org</a>.<br />

------=_Part_20584_219462927.1529337792820--

------=_Part_20583_1760564402.1529337792820--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Tue, 19 Jun 2018 10:20:10 -0700 (PDT)
Raw View
------=_Part_25173_434067806.1529428810591
Content-Type: multipart/alternative;
 boundary="----=_Part_25174_1020279595.1529428810591"

------=_Part_25174_1020279595.1529428810591
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salvia wrote:
>
> *Updated draft proposal for generic rebind template:*
>
> http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html
>
> Implementation files:
>
> https://github.com/charles-salvia/std-proposal-generic-template-rebind=20
> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia=
%2Fstd-proposal-generic-template-rebind&sa=3DD&sntz=3D1&usg=3DAFQjCNFd63xmU=
N5MQyW_aWJBKDNIE-w9NA>
>
> This is a proposal to create a generic mechanism for rebinding template=
=20
> parameters (std::rebind_t), to remove the need for ad-hoc rebind template=
s,=20
> such as std::allocator_traits::rebind_alloc, etc.=20
>

This is a bad idea for several philosophical reasons (and I say that as the=
=20
presenter of this talk <https://www.youtube.com/watch?v=3D0MdSJsCTRkY> on a=
=20
similar subject. The difference is that I don't want any "generic" rebind=
=20
facility, I just want a greater number of special-purpose rebinders).

However, your idea doesn't work anyway. Try it on some library types:

    using V =3D std::pmr::vector<int>;
    using W =3D rebind_t<V, double>;
    static_assert(std::is_same_v<W, std::pmr::vector<double>>);  // error!

Since it's a bad idea *and* doesn't work, I think you should give it up.

However, it's also much easier to implement as a pure library extension=20
than you thought it was. I can do it in 28 lines and I bet it can be done=
=20
in fewer.
https://wandbox.org/permlink/pRIQ8lJaf8irznwK

=E2=80=93Arthur

--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7f5b55e9-e935-421a-b0ab-3b5cbbb1c624%40isocpp.or=
g.

------=_Part_25174_1020279595.1529428810591
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salv=
ia wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><b>U=
pdated draft proposal for generic rebind template:</b><div><br></div><div><=
a href=3D"http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FCPP-REBIND-PROPOSA=
L.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7swlsWak1g=
&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q=
\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FCPP-REBIND-PROPOSAL.html\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7swlsWak1g&#39;;return =
true;">http://charles-salvia.github.<wbr>io/CPP-REBIND-PROPOSAL.html</a></d=
iv><div><br></div><div>Implementation files:</div><div><br></div><div><a hr=
ef=3D"https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-sal=
via%2Fstd-proposal-generic-template-rebind&amp;sa=3DD&amp;sntz=3D1&amp;usg=
=3DAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA" target=3D"_blank" rel=3D"nofollow" o=
nmousedown=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%=
2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-generic-template-rebind\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA&#39;;return =
true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A=
%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-generic-template-rebind\x2=
6sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA&#39;;ret=
urn true;">https://github.com/charles-<wbr>salvia/std-proposal-generic-<wbr=
>template-rebind</a></div><div><br></div><div>This is a proposal to create =
a generic mechanism for rebinding template parameters (std::rebind_t), to r=
emove the need for ad-hoc rebind templates, such as std::allocator_traits::=
rebind_<wbr>alloc, etc.=C2=A0</div></div></blockquote><div><br></div><div>T=
his is a bad idea for several philosophical reasons (and I say that as the =
presenter of <a href=3D"https://www.youtube.com/watch?v=3D0MdSJsCTRkY">this=
 talk</a> on a similar subject. The difference is that I don&#39;t want any=
 &quot;generic&quot; rebind facility, I just want a greater number of speci=
al-purpose rebinders).</div><div><br></div><div>However, your idea doesn&#3=
9;t work anyway. Try it on some library types:</div><div><br></div><div>=C2=
=A0 =C2=A0 using V =3D std::pmr::vector&lt;int&gt;;</div><div>=C2=A0 =C2=A0=
 using W =3D rebind_t&lt;V, double&gt;;</div><div>=C2=A0 =C2=A0 static_asse=
rt(std::is_same_v&lt;W, std::pmr::vector&lt;double&gt;&gt;); =C2=A0// error=
!</div><div><br></div><div>Since it&#39;s a bad idea <b><i>and</i></b> does=
n&#39;t work, I think you should give it up.</div><div><br></div><div>Howev=
er, it&#39;s also much easier to implement as a pure library extension than=
 you thought it was. I can do it in 28 lines and I bet it can be done in fe=
wer.</div><div><a href=3D"https://wandbox.org/permlink/pRIQ8lJaf8irznwK">ht=
tps://wandbox.org/permlink/pRIQ8lJaf8irznwK</a><br></div><div><br></div><di=
v>=E2=80=93Arthur</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7f5b55e9-e935-421a-b0ab-3b5cbbb1c624%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7f5b55e9-e935-421a-b0ab-3b5cbbb1c624=
%40isocpp.org</a>.<br />

------=_Part_25174_1020279595.1529428810591--

------=_Part_25173_434067806.1529428810591--

.


Author: Charles Salvia <charles.a.salvia@gmail.com>
Date: Tue, 19 Jun 2018 14:57:35 -0700 (PDT)
Raw View
------=_Part_26529_1560161599.1529445456186
Content-Type: multipart/alternative;
 boundary="----=_Part_26530_1758866658.1529445456187"

------=_Part_26530_1758866658.1529445456187
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Right.  In that case it wouldn't do the expected thing, because=20
std::pmr::vector is defined as an alias template rather than a class=20
template.

On Tuesday, June 19, 2018 at 1:20:10 PM UTC-4, Arthur O'Dwyer wrote:
>
> On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salvia wrote:
>>
>> *Updated draft proposal for generic rebind template:*
>>
>> http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html
>>
>> Implementation files:
>>
>> https://github.com/charles-salvia/std-proposal-generic-template-rebind=
=20
>> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-salvi=
a%2Fstd-proposal-generic-template-rebind&sa=3DD&sntz=3D1&usg=3DAFQjCNFd63xm=
UN5MQyW_aWJBKDNIE-w9NA>
>>
>> This is a proposal to create a generic mechanism for rebinding template=
=20
>> parameters (std::rebind_t), to remove the need for ad-hoc rebind templat=
es,=20
>> such as std::allocator_traits::rebind_alloc, etc.=20
>>
>
> This is a bad idea for several philosophical reasons (and I say that as=
=20
> the presenter of this talk <https://www.youtube.com/watch?v=3D0MdSJsCTRkY=
>=20
> on a similar subject. The difference is that I don't want any "generic"=
=20
> rebind facility, I just want a greater number of special-purpose rebinder=
s).
>
> However, your idea doesn't work anyway. Try it on some library types:
>
>     using V =3D std::pmr::vector<int>;
>     using W =3D rebind_t<V, double>;
>     static_assert(std::is_same_v<W, std::pmr::vector<double>>);  // error=
!
>
> Since it's a bad idea *and* doesn't work, I think you should give it up.
>
> However, it's also much easier to implement as a pure library extension=
=20
> than you thought it was. I can do it in 28 lines and I bet it can be done=
=20
> in fewer.
> https://wandbox.org/permlink/pRIQ8lJaf8irznwK
>
> =E2=80=93Arthur
>

--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/17d39779-2bb9-4073-ab3f-4b14eef2d0de%40isocpp.or=
g.

------=_Part_26530_1758866658.1529445456187
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Right.=C2=A0 In that case it wouldn&#39;t do the expected =
thing, because std::pmr::vector is defined as an alias template rather than=
 a class template.<br><br>On Tuesday, June 19, 2018 at 1:20:10 PM UTC-4, Ar=
thur O&#39;Dwyer wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salvia wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><b>Updated draft=
 proposal for generic rebind template:</b><div><br></div><div><a href=3D"ht=
tp://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html" rel=3D"nofollow" ta=
rget=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q=
\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FCPP-REBIND-PROPOSAL.html\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7swlsWak1g&#39;;return =
true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2=
F%2Fcharles-salvia.github.io%2FCPP-REBIND-PROPOSAL.html\x26sa\x3dD\x26sntz\=
x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7swlsWak1g&#39;;return true;">http:/=
/charles-salvia.github.<wbr>io/CPP-REBIND-PROPOSAL.html</a></div><div><br><=
/div><div>Implementation files:</div><div><br></div><div><a href=3D"https:/=
/www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-pro=
posal-generic-template-rebind&amp;sa=3DD&amp;sntz=3D1&amp;usg=3DAFQjCNFd63x=
mUN5MQyW_aWJBKDNIE-w9NA" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"=
this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2=
Fcharles-salvia%2Fstd-proposal-generic-template-rebind\x26sa\x3dD\x26sntz\x=
3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA&#39;;return true;" onclick=
=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.c=
om%2Fcharles-salvia%2Fstd-proposal-generic-template-rebind\x26sa\x3dD\x26sn=
tz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA&#39;;return true;">htt=
ps://github.com/charles-<wbr>salvia/std-proposal-generic-<wbr>template-rebi=
nd</a></div><div><br></div><div>This is a proposal to create a generic mech=
anism for rebinding template parameters (std::rebind_t), to remove the need=
 for ad-hoc rebind templates, such as std::allocator_traits::rebind_<wbr>al=
loc, etc.=C2=A0</div></div></blockquote><div><br></div><div>This is a bad i=
dea for several philosophical reasons (and I say that as the presenter of <=
a href=3D"https://www.youtube.com/watch?v=3D0MdSJsCTRkY" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.youtube.com/wa=
tch?v\x3d0MdSJsCTRkY&#39;;return true;" onclick=3D"this.href=3D&#39;https:/=
/www.youtube.com/watch?v\x3d0MdSJsCTRkY&#39;;return true;">this talk</a> on=
 a similar subject. The difference is that I don&#39;t want any &quot;gener=
ic&quot; rebind facility, I just want a greater number of special-purpose r=
ebinders).</div><div><br></div><div>However, your idea doesn&#39;t work any=
way. Try it on some library types:</div><div><br></div><div>=C2=A0 =C2=A0 u=
sing V =3D std::pmr::vector&lt;int&gt;;</div><div>=C2=A0 =C2=A0 using W =3D=
 rebind_t&lt;V, double&gt;;</div><div>=C2=A0 =C2=A0 static_assert(std::is_s=
ame_v&lt;<wbr>W, std::pmr::vector&lt;double&gt;&gt;); =C2=A0// error!</div>=
<div><br></div><div>Since it&#39;s a bad idea <b><i>and</i></b> doesn&#39;t=
 work, I think you should give it up.</div><div><br></div><div>However, it&=
#39;s also much easier to implement as a pure library extension than you th=
ought it was. I can do it in 28 lines and I bet it can be done in fewer.</d=
iv><div><a href=3D"https://wandbox.org/permlink/pRIQ8lJaf8irznwK" target=3D=
"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.googl=
e.com/url?q\x3dhttps%3A%2F%2Fwandbox.org%2Fpermlink%2FpRIQ8lJaf8irznwK\x26s=
a\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7TQ5WnDEbqIXY5r9llFNLTY8laQ&#39;;retur=
n true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%=
3A%2F%2Fwandbox.org%2Fpermlink%2FpRIQ8lJaf8irznwK\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNE7TQ5WnDEbqIXY5r9llFNLTY8laQ&#39;;return true;">https://wand=
box.org/permlink/<wbr>pRIQ8lJaf8irznwK</a><br></div><div><br></div><div>=E2=
=80=93Arthur</div></div></blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/17d39779-2bb9-4073-ab3f-4b14eef2d0de%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/17d39779-2bb9-4073-ab3f-4b14eef2d0de=
%40isocpp.org</a>.<br />

------=_Part_26530_1758866658.1529445456187--

------=_Part_26529_1560161599.1529445456186--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Tue, 19 Jun 2018 15:20:54 -0700 (PDT)
Raw View
------=_Part_26584_338790623.1529446854756
Content-Type: multipart/alternative;
 boundary="----=_Part_26585_1054251981.1529446854757"

------=_Part_26585_1054251981.1529446854757
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tuesday, June 19, 2018 at 2:57:36 PM UTC-7, Charles Salvia wrote:
>
> Right.  In that case it wouldn't do the expected thing, because=20
> std::pmr::vector is defined as an alias template rather than a class=20
> template.
>

Even if you spell out the type, your "rebind" STILL does the wrong thing.

    using V =3D std::vector<int, std::pmr::polymorphic_allocator<int>>;
    using W =3D rebind_t<V, double>;
    static_assert(is_same_v<W, std::vector<double,=20
std::pmr::polymorphic_allocator<int>>>); // Oops!

=E2=80=93Arthur

=20

> On Tuesday, June 19, 2018 at 1:20:10 PM UTC-4, Arthur O'Dwyer wrote:
>>
>> On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salvia wrote:
>>>
>>> *Updated draft proposal for generic rebind template:*
>>>
>>> http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html
>>>
>>> Implementation files:
>>>
>>> https://github.com/charles-salvia/std-proposal-generic-template-rebind=
=20
>>> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-salv=
ia%2Fstd-proposal-generic-template-rebind&sa=3DD&sntz=3D1&usg=3DAFQjCNFd63x=
mUN5MQyW_aWJBKDNIE-w9NA>
>>>
>>> This is a proposal to create a generic mechanism for rebinding template=
=20
>>> parameters (std::rebind_t), to remove the need for ad-hoc rebind templa=
tes,=20
>>> such as std::allocator_traits::rebind_alloc, etc.=20
>>>
>>
>> This is a bad idea for several philosophical reasons (and I say that as=
=20
>> the presenter of this talk <https://www.youtube.com/watch?v=3D0MdSJsCTRk=
Y>=20
>> on a similar subject. The difference is that I don't want any "generic"=
=20
>> rebind facility, I just want a greater number of special-purpose rebinde=
rs).
>>
>> However, your idea doesn't work anyway. Try it on some library types:
>>
>>     using V =3D std::pmr::vector<int>;
>>     using W =3D rebind_t<V, double>;
>>     static_assert(std::is_same_v<W, std::pmr::vector<double>>);  // erro=
r!
>>
>> Since it's a bad idea *and* doesn't work, I think you should give it up.
>>
>> However, it's also much easier to implement as a pure library extension=
=20
>> than you thought it was. I can do it in 28 lines and I bet it can be don=
e=20
>> in fewer.
>> https://wandbox.org/permlink/pRIQ8lJaf8irznwK
>>
>> =E2=80=93Arthur
>>
>

--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/600a547b-484d-4c2e-812e-cf3d9762ea71%40isocpp.or=
g.

------=_Part_26585_1054251981.1529446854757
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, June 19, 2018 at 2:57:36 PM UTC-7, Charles Sal=
via wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Rig=
ht.=C2=A0 In that case it wouldn&#39;t do the expected thing, because std::=
pmr::vector is defined as an alias template rather than a class template.<b=
r></div></blockquote><div><br></div><div>Even if you spell out the type, yo=
ur &quot;rebind&quot; STILL does the wrong thing.</div><div><br></div><div>=
=C2=A0 =C2=A0 using V =3D std::vector&lt;int, std::pmr::polymorphic_allocat=
or&lt;int&gt;&gt;;</div><div>=C2=A0 =C2=A0 using W =3D rebind_t&lt;V, doubl=
e&gt;;</div><div>=C2=A0 =C2=A0 static_assert(is_same_v&lt;W, std::vector&lt=
;double, std::pmr::polymorphic_allocator&lt;int&gt;&gt;&gt;); // Oops!</div=
><div><br></div><div>=E2=80=93Arthur</div><div><br></div><div>=C2=A0</div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Tuesday, Ju=
ne 19, 2018 at 1:20:10 PM UTC-4, Arthur O&#39;Dwyer wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">On Monday, June 18, 2018 at 9:03:12=
 AM UTC-7, Charles Salvia wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr"><b>Updated draft proposal for generic rebind template:</b><di=
v><br></div><div><a href=3D"http://charles-salvia.github.io/CPP-REBIND-PROP=
OSAL.html" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#=
39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FC=
PP-REBIND-PROPOSAL.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1=
Sr0hoqq7swlsWak1g&#39;;return true;" onclick=3D"this.href=3D&#39;http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FCPP-REBIND-PRO=
POSAL.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7swlsW=
ak1g&#39;;return true;">http://charles-salvia.github.<wbr>io/CPP-REBIND-PRO=
POSAL.html</a></div><div><br></div><div>Implementation files:</div><div><br=
></div><div><a href=3D"https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.=
com%2Fcharles-salvia%2Fstd-proposal-generic-template-rebind&amp;sa=3DD&amp;=
sntz=3D1&amp;usg=3DAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA" rel=3D"nofollow" tar=
get=3D"_blank" onmousedown=3D"this.href=3D&#39;https://www.google.com/url?q=
\x3dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-generic-templa=
te-rebind\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w=
9NA&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.com/u=
rl?q\x3dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-generic-te=
mplate-rebind\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKDN=
IE-w9NA&#39;;return true;">https://github.com/charles-<wbr>salvia/std-propo=
sal-generic-<wbr>template-rebind</a></div><div><br></div><div>This is a pro=
posal to create a generic mechanism for rebinding template parameters (std:=
:rebind_t), to remove the need for ad-hoc rebind templates, such as std::al=
locator_traits::rebind_<wbr>alloc, etc.=C2=A0</div></div></blockquote><div>=
<br></div><div>This is a bad idea for several philosophical reasons (and I =
say that as the presenter of <a href=3D"https://www.youtube.com/watch?v=3D0=
MdSJsCTRkY" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&=
#39;https://www.youtube.com/watch?v\x3d0MdSJsCTRkY&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;https://www.youtube.com/watch?v\x3d0MdSJsCTRkY&#39;;=
return true;">this talk</a> on a similar subject. The difference is that I =
don&#39;t want any &quot;generic&quot; rebind facility, I just want a great=
er number of special-purpose rebinders).</div><div><br></div><div>However, =
your idea doesn&#39;t work anyway. Try it on some library types:</div><div>=
<br></div><div>=C2=A0 =C2=A0 using V =3D std::pmr::vector&lt;int&gt;;</div>=
<div>=C2=A0 =C2=A0 using W =3D rebind_t&lt;V, double&gt;;</div><div>=C2=A0 =
=C2=A0 static_assert(std::is_same_v&lt;<wbr>W, std::pmr::vector&lt;double&g=
t;&gt;); =C2=A0// error!</div><div><br></div><div>Since it&#39;s a bad idea=
 <b><i>and</i></b> doesn&#39;t work, I think you should give it up.</div><d=
iv><br></div><div>However, it&#39;s also much easier to implement as a pure=
 library extension than you thought it was. I can do it in 28 lines and I b=
et it can be done in fewer.</div><div><a href=3D"https://wandbox.org/permli=
nk/pRIQ8lJaf8irznwK" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this=
..href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwandbox.org%2Fpe=
rmlink%2FpRIQ8lJaf8irznwK\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7TQ5WnDE=
bqIXY5r9llFNLTY8laQ&#39;;return true;" onclick=3D"this.href=3D&#39;https://=
www.google.com/url?q\x3dhttps%3A%2F%2Fwandbox.org%2Fpermlink%2FpRIQ8lJaf8ir=
znwK\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7TQ5WnDEbqIXY5r9llFNLTY8laQ&#=
39;;return true;">https://wandbox.org/permlink/<wbr>pRIQ8lJaf8irznwK</a><br=
></div><div><br></div><div>=E2=80=93Arthur</div></div></blockquote></div></=
blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/600a547b-484d-4c2e-812e-cf3d9762ea71%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/600a547b-484d-4c2e-812e-cf3d9762ea71=
%40isocpp.org</a>.<br />

------=_Part_26585_1054251981.1529446854757--

------=_Part_26584_338790623.1529446854756--

.


Author: Charles Salvia <charles.a.salvia@gmail.com>
Date: Tue, 19 Jun 2018 18:30:05 -0700 (PDT)
Raw View
------=_Part_27087_463653750.1529458205129
Content-Type: multipart/alternative;
 boundary="----=_Part_27088_1789772432.1529458205129"

------=_Part_27088_1789772432.1529458205129
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Yeah, I see what you mean.  I suppose it's unclear to me actually if that's=
=20
bad.  The default argument for template parameter 2 in std::vector is=20
std::allocator, not std::pmr::polymorphic_allocator.  Default arguments are=
=20
really a property of the *template*, not a particular instantiation - so=20
naturally, if you omit the second parameter in the rebind expression,=20
relying on the default parameter, then it would of course have to use the=
=20
default parameter used by the *template*, which is std::allocator.  So, I=
=20
guess you could argue this is to be the expected behavior.  You'd need to=
=20
explicitly spell out the second argument if you wanted to use a different=
=20
allocator type.

Regardless, I agree with you that cases like this certainly call into=20
question the overall usefulness of an attempt to write a generic rebind=20
template.

On Tuesday, June 19, 2018 at 6:20:54 PM UTC-4, Arthur O'Dwyer wrote:
>
> On Tuesday, June 19, 2018 at 2:57:36 PM UTC-7, Charles Salvia wrote:
>>
>> Right.  In that case it wouldn't do the expected thing, because=20
>> std::pmr::vector is defined as an alias template rather than a class=20
>> template.
>>
>
> Even if you spell out the type, your "rebind" STILL does the wrong thing.
>
>     using V =3D std::vector<int, std::pmr::polymorphic_allocator<int>>;
>     using W =3D rebind_t<V, double>;
>     static_assert(is_same_v<W, std::vector<double,=20
> std::pmr::polymorphic_allocator<int>>>); // Oops!
>
> =E2=80=93Arthur
>
> =20
>
>> On Tuesday, June 19, 2018 at 1:20:10 PM UTC-4, Arthur O'Dwyer wrote:
>>>
>>> On Monday, June 18, 2018 at 9:03:12 AM UTC-7, Charles Salvia wrote:
>>>>
>>>> *Updated draft proposal for generic rebind template:*
>>>>
>>>> http://charles-salvia.github.io/CPP-REBIND-PROPOSAL.html
>>>>
>>>> Implementation files:
>>>>
>>>> https://github.com/charles-salvia/std-proposal-generic-template-rebind=
=20
>>>> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fcharles-sal=
via%2Fstd-proposal-generic-template-rebind&sa=3DD&sntz=3D1&usg=3DAFQjCNFd63=
xmUN5MQyW_aWJBKDNIE-w9NA>
>>>>
>>>> This is a proposal to create a generic mechanism for rebinding templat=
e=20
>>>> parameters (std::rebind_t), to remove the need for ad-hoc rebind templ=
ates,=20
>>>> such as std::allocator_traits::rebind_alloc, etc.=20
>>>>
>>>
>>> This is a bad idea for several philosophical reasons (and I say that as=
=20
>>> the presenter of this talk <https://www.youtube.com/watch?v=3D0MdSJsCTR=
kY>=20
>>> on a similar subject. The difference is that I don't want any "generic"=
=20
>>> rebind facility, I just want a greater number of special-purpose rebind=
ers).
>>>
>>> However, your idea doesn't work anyway. Try it on some library types:
>>>
>>>     using V =3D std::pmr::vector<int>;
>>>     using W =3D rebind_t<V, double>;
>>>     static_assert(std::is_same_v<W, std::pmr::vector<double>>);  //=20
>>> error!
>>>
>>> Since it's a bad idea *and* doesn't work, I think you should give it up=
..
>>>
>>> However, it's also much easier to implement as a pure library extension=
=20
>>> than you thought it was. I can do it in 28 lines and I bet it can be do=
ne=20
>>> in fewer.
>>> https://wandbox.org/permlink/pRIQ8lJaf8irznwK
>>>
>>> =E2=80=93Arthur
>>>
>>

--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/077d3c60-6cc4-42aa-9b18-5dbb593b107b%40isocpp.or=
g.

------=_Part_27088_1789772432.1529458205129
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yeah, I see what you mean.=C2=A0 I suppose it&#39;s unclea=
r to me actually if that&#39;s bad.=C2=A0 The default argument for template=
 parameter 2 in std::vector is std::allocator, not std::pmr::polymorphic_al=
locator.=C2=A0 Default arguments are really a property of the <i>template</=
i>, not a particular instantiation - so naturally, if you omit the second p=
arameter in the rebind expression, relying on the default parameter, then i=
t would of course have to use the default parameter used by the *template*,=
 which is std::allocator.=C2=A0 So, I guess you could argue this is to be t=
he expected behavior.=C2=A0 You&#39;d need to explicitly spell out the seco=
nd argument if you wanted to use a different allocator type.<div><div><br><=
/div><div>Regardless, I agree with you that cases like this certainly call =
into question the overall usefulness of an attempt to write a generic rebin=
d template.<br></div><div><div><br>On Tuesday, June 19, 2018 at 6:20:54 PM =
UTC-4, Arthur O&#39;Dwyer wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
"><div dir=3D"ltr">On Tuesday, June 19, 2018 at 2:57:36 PM UTC-7, Charles S=
alvia wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left=
:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Right.=
=C2=A0 In that case it wouldn&#39;t do the expected thing, because std::pmr=
::vector is defined as an alias template rather than a class template.<br><=
/div></blockquote><div><br></div><div>Even if you spell out the type, your =
&quot;rebind&quot; STILL does the wrong thing.</div><div><br></div><div>=C2=
=A0 =C2=A0 using V =3D std::vector&lt;int, std::pmr::polymorphic_<wbr>alloc=
ator&lt;int&gt;&gt;;</div><div>=C2=A0 =C2=A0 using W =3D rebind_t&lt;V, dou=
ble&gt;;</div><div>=C2=A0 =C2=A0 static_assert(is_same_v&lt;W, std::vector&=
lt;double, std::pmr::polymorphic_<wbr>allocator&lt;int&gt;&gt;&gt;); // Oop=
s!</div><div><br></div><div>=E2=80=93Arthur</div><div><br></div><div>=C2=A0=
</div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Tuesday, =
June 19, 2018 at 1:20:10 PM UTC-4, Arthur O&#39;Dwyer wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr">On Monday, June 18, 2018 at 9:03:=
12 AM UTC-7, Charles Salvia wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><b>Updated draft proposal for generic rebind template:</b=
><div><br></div><div><a href=3D"http://charles-salvia.github.io/CPP-REBIND-=
PROPOSAL.html" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=
=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.i=
o%2FCPP-REBIND-PROPOSAL.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1=
gu_d1Sr0hoqq7swlsWak1g&#39;;return true;" onclick=3D"this.href=3D&#39;http:=
//www.google.com/url?q\x3dhttp%3A%2F%2Fcharles-salvia.github.io%2FCPP-REBIN=
D-PROPOSAL.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHCRbK1gu_d1Sr0hoqq7=
swlsWak1g&#39;;return true;">http://charles-salvia.github.<wbr>io/CPP-REBIN=
D-PROPOSAL.html</a></div><div><br></div><div>Implementation files:</div><di=
v><br></div><div><a href=3D"https://www.google.com/url?q=3Dhttps%3A%2F%2Fgi=
thub.com%2Fcharles-salvia%2Fstd-proposal-generic-template-rebind&amp;sa=3DD=
&amp;sntz=3D1&amp;usg=3DAFQjCNFd63xmUN5MQyW_aWJBKDNIE-w9NA" rel=3D"nofollow=
" target=3D"_blank" onmousedown=3D"this.href=3D&#39;https://www.google.com/=
url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-generic-t=
emplate-rebind\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aWJBKD=
NIE-w9NA&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.=
com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcharles-salvia%2Fstd-proposal-gener=
ic-template-rebind\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFd63xmUN5MQyW_aW=
JBKDNIE-w9NA&#39;;return true;">https://github.com/charles-<wbr>salvia/std-=
proposal-generic-<wbr>template-rebind</a></div><div><br></div><div>This is =
a proposal to create a generic mechanism for rebinding template parameters =
(std::rebind_t), to remove the need for ad-hoc rebind templates, such as st=
d::allocator_traits::rebind_<wbr>alloc, etc.=C2=A0</div></div></blockquote>=
<div><br></div><div>This is a bad idea for several philosophical reasons (a=
nd I say that as the presenter of <a href=3D"https://www.youtube.com/watch?=
v=3D0MdSJsCTRkY" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.hre=
f=3D&#39;https://www.youtube.com/watch?v\x3d0MdSJsCTRkY&#39;;return true;" =
onclick=3D"this.href=3D&#39;https://www.youtube.com/watch?v\x3d0MdSJsCTRkY&=
#39;;return true;">this talk</a> on a similar subject. The difference is th=
at I don&#39;t want any &quot;generic&quot; rebind facility, I just want a =
greater number of special-purpose rebinders).</div><div><br></div><div>Howe=
ver, your idea doesn&#39;t work anyway. Try it on some library types:</div>=
<div><br></div><div>=C2=A0 =C2=A0 using V =3D std::pmr::vector&lt;int&gt;;<=
/div><div>=C2=A0 =C2=A0 using W =3D rebind_t&lt;V, double&gt;;</div><div>=
=C2=A0 =C2=A0 static_assert(std::is_same_v&lt;<wbr>W, std::pmr::vector&lt;d=
ouble&gt;&gt;); =C2=A0// error!</div><div><br></div><div>Since it&#39;s a b=
ad idea <b><i>and</i></b> doesn&#39;t work, I think you should give it up.<=
/div><div><br></div><div>However, it&#39;s also much easier to implement as=
 a pure library extension than you thought it was. I can do it in 28 lines =
and I bet it can be done in fewer.</div><div><a href=3D"https://wandbox.org=
/permlink/pRIQ8lJaf8irznwK" rel=3D"nofollow" target=3D"_blank" onmousedown=
=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwandbox.=
org%2Fpermlink%2FpRIQ8lJaf8irznwK\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE=
7TQ5WnDEbqIXY5r9llFNLTY8laQ&#39;;return true;" onclick=3D"this.href=3D&#39;=
https://www.google.com/url?q\x3dhttps%3A%2F%2Fwandbox.org%2Fpermlink%2FpRIQ=
8lJaf8irznwK\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7TQ5WnDEbqIXY5r9llFNL=
TY8laQ&#39;;return true;">https://wandbox.org/permlink/<wbr>pRIQ8lJaf8irznw=
K</a><br></div><div><br></div><div>=E2=80=93Arthur</div></div></blockquote>=
</div></blockquote></div></blockquote></div></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/077d3c60-6cc4-42aa-9b18-5dbb593b107b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/077d3c60-6cc4-42aa-9b18-5dbb593b107b=
%40isocpp.org</a>.<br />

------=_Part_27088_1789772432.1529458205129--

------=_Part_27087_463653750.1529458205129--

.