Topic: Is mutable(bool) worth pursuing?


Author: Andrew Giese <gieseanw@gmail.com>
Date: Tue, 3 Jul 2018 12:54:12 -0700 (PDT)
Raw View
------=_Part_52543_483192643.1530647652188
Content-Type: multipart/alternative;
 boundary="----=_Part_52544_55052258.1530647652189"

------=_Part_52544_55052258.1530647652189
Content-Type: text/plain; charset="UTF-8"

Along the same lines as conditional noexcept and conditional explicit, I'd
like to make the mutability of a member variable conditional.

Forgive the intentionally simplified and slightly contrived nature of my
example.

My motivating example:

I have some lightweight wrapper around a std::container that is meant to be
derived from, and children may override certain aspects of the class for
their own customization:

template<class T>
class VectorWrapper
{
public:
    template<class U>
    void Add(U&& val)
    {
        data.push_back(std::forward<U>(val));
    }

    virtual const T& Get(size_t index) const
    {
        return data.at(index);
    }

    protected:
    std::vector<T> data;
};



Now, a derived class suddenly finds that it needs to serialize to and from
disk. This deserialization is potentially expensive and isn't always
necessary, so we put off the deserialization until the absolute last minute
(lazy loading).

class LazyIntLoader : public VectorWrapper<int>
{
    const int& Get(size_t index) const override
    {
        std::cout << "Lazily loading the data...\n";
        data = std::vector<int>{1, 2, 3, 4, 5};
        std::cout << "...done\n";
        return VectorWrapper<int>::Get(index);
    }
};


The problem is that we cannot do this because the "data" member is not
mutable. So we either go back to the base class and make it always mutable
(wrong), or we decide to make it conditional on some template argument:

template<class T, bool>
struct VectorHolder
{
    protected:
    std::vector<T> data;
};


template<class T>
struct VectorHolder<T, true>
{
    protected:
    mutable std::vector<T> data;
};


template<class T, bool Mutable = false>
class VectorWrapper : public VectorHolder<T, Mutable>
{
    public:
    template<class U>
    void Add(U&& val)
    {
        this->data.push_back(std::forward<U>(val));
    }

    virtual const T& Get(size_t index) const
    {
        return this->data.at(index);
    }
};


I don't like this because now I have to add yet another level to the
inheritance chain which becomes problematic when I'm trying to avoid any
kind of multiple inheritance scenario, and also I have to use some template
specialization which introduces another level of indirection and in my
humble opinion, reduces readability.

I believe I could invent more contrived scenarios where I'd like the
mutability to depend on the value of an expression e.g.  if
LazyLoadInt::is_lazy_loaded returns is a constexpr true boolean, or if
LazyLoadInt::LazyLoad is a member function. However, syntax like

mutable(bool)

would make my life easier. (If "mutable" was part of the type like const or
volatile, we could use std::conditional_t, but I wouldn't prefer that
avenue.)

Then I could write code (also a bit contrived and simplified) like this
instead:

template<class T, bool Mutable = false>
class VectorWrapper
{
    public:
    template<class U>
    void Add(U&& val)
    {
        this->data.push_back(std::forward<U>(val));
    }

    virtual const T& Get(size_t index) const
    {
        return this->data.at(index);
    }

    mutable(Mutable) std::vector<T> data;
};

template<class T>
using MutableVectorWrapper = VectorWrapper<T, true>;

class LazyIntLoader : public MutableVectorWrapper<int>
{
public:
    const int& Get(size_t index) const override
    {
        std::cout << "Lazily loading the data...\n";
        this->data = std::vector<int>{1, 2, 3, 4, 5};
        std::cout << "...done\n";
        return VectorWrapper<int, true>::Get(index);
    }
};

*Is such a proposal worth pursuing?*

I think it follows the pattern for conditional explicit and conditional
noexcept in many ways.

--
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/b7fd8a46-593a-4505-8ceb-9bb0e9deb010%40isocpp.org.

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

<div dir=3D"ltr">Along the same lines as conditional noexcept and condition=
al explicit, I&#39;d like to make the mutability of a member variable condi=
tional.<div><br></div><div>Forgive the intentionally simplified and slightl=
y contrived nature of my example.<br><div><br></div><div>My motivating exam=
ple:</div><div><br></div><div>I have some lightweight wrapper around a std:=
:container that is meant to be derived from, and children may override cert=
ain aspects of the class for their own customization:</div><div><br></div><=
div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #008;" class=3D"styled-by-prettify">template=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">VectorWrapper</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">te=
mplate</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> U</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">Add</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">U</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> val</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 data</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">push_back</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">forward=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">U</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">val</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">));</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0<br>=C2=A0 =C2=A0 </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">virtual</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Get=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">size_t index</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> data</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">at</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">index</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">protected</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">vector</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> data</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">};</span></div></=
code></div><div><br></div></div><div><br></div><div><br><div>Now, a derived=
 class suddenly finds that it needs to serialize to and from disk. This des=
erialization is potentially expensive and isn&#39;t always necessary, so we=
 put off the deserialization until the absolute last minute (lazy loading).=
</div><div><br></div><div><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
LazyIntLoader</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">VectorWrapper</span><span style=3D"co=
lor: #080;" class=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Get</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t index</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">override</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cl=
ass=3D"styled-by-prettify">&quot;Lazily loading the data...\n&quot;</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 data </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">vector</span><span =
style=3D"color: #080;" class=3D"styled-by-prettify">&lt;int&gt;</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"sty=
led-by-prettify">2</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">3</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">4</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&qu=
ot;...done\n&quot;</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">VectorWrapper</span><span style=3D"color: #080;" class=3D"styled-by=
-prettify">&lt;int&gt;</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #606;" class=3D"styled-by-pretti=
fy">Get</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">index</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">};</span></div></code></div><div=
><br></div></div><div><br></div><div>The problem is that we cannot do this =
because the &quot;data&quot; member is not mutable. So we either go back to=
 the base class and make it always mutable (wrong), or we decide to make it=
 conditional on some template argument:</div><div><br></div><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">bool</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">VectorHolder</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">protected</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">vector</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> data</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">template=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">VectorHolder</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">true</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">protected</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">mutable</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">vector</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> data</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Mutable</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">false</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">VectorWrapper</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">public<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">VectorHolder</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Mutable</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">public</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">template</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">clas=
s</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> U</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Add</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">U</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> val</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> <br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">this</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">data</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">push_back</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">forward</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">U</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">val</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0<br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">virtual</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">Get</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">size_t index</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">this</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">data</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">at</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">index</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br></span></div></code></div><div><b=
r>I don&#39;t like this because now I have to add yet another level to the =
inheritance chain which becomes problematic when I&#39;m trying to avoid an=
y kind of multiple inheritance scenario, and also I have to use some templa=
te specialization which introduces another level of indirection and in my h=
umble opinion, reduces readability.</div><div><br></div><div>I believe I co=
uld invent more contrived scenarios where I&#39;d like the mutability to de=
pend on the value of an expression e.g.=C2=A0 if LazyLoadInt::is_lazy_loade=
d returns is a constexpr true boolean, or if LazyLoadInt::LazyLoad is a mem=
ber function. However, syntax like</div><div><br></div><div><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">mutable</span><font color=
=3D"#666600"><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></font></div></co=
de></div><br>would make my life easier. (If &quot;mutable&quot; was part of=
 the type like const or volatile, we could use std::conditional_t, but I wo=
uldn&#39;t prefer that avenue.)</div></div></div><div><br></div><div>Then I=
 could write code (also a bit contrived and simplified) like this instead:<=
/div><div><br></div><div><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: sol=
id; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><font color=3D"#660066"><div class=3D"subpret=
typrint">template&lt;class T, bool Mutable =3D false&gt;</div><div class=3D=
"subprettyprint">class VectorWrapper</div><div class=3D"subprettyprint">{</=
div><div class=3D"subprettyprint">=C2=A0 =C2=A0 public:</div><div class=3D"=
subprettyprint">=C2=A0 =C2=A0 template&lt;class U&gt;</div><div class=3D"su=
bprettyprint">=C2=A0 =C2=A0 void Add(U&amp;&amp; val)=C2=A0</div><div class=
=3D"subprettyprint">=C2=A0 =C2=A0 {=C2=A0</div><div class=3D"subprettyprint=
">=C2=A0 =C2=A0 =C2=A0 =C2=A0 this-&gt;data.push_back(std::forward&lt;U&gt;=
(val));</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 }</div><div class=
=3D"subprettyprint">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 virtual const T=
&amp; Get(size_t index) const</div><div class=3D"subprettyprint">=C2=A0 =C2=
=A0 {</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return=
 this-&gt;data.at(index);</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 =
}</div><div class=3D"subprettyprint">=C2=A0 =C2=A0=C2=A0</div><div class=3D=
"subprettyprint">=C2=A0 =C2=A0 mutable(Mutable) std::vector&lt;T&gt; data;<=
/div><div class=3D"subprettyprint">};</div><div class=3D"subprettyprint"><b=
r></div><div class=3D"subprettyprint">template&lt;class T&gt;</div><div cla=
ss=3D"subprettyprint">using MutableVectorWrapper =3D VectorWrapper&lt;T, tr=
ue&gt;;</div><div class=3D"subprettyprint"><br></div><div class=3D"subprett=
yprint">class LazyIntLoader : public MutableVectorWrapper&lt;int&gt;</div><=
div class=3D"subprettyprint">{</div><div class=3D"subprettyprint">public:</=
div><div class=3D"subprettyprint">=C2=A0 =C2=A0 const int&amp; Get(size_t i=
ndex) const override</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 {</di=
v><div class=3D"subprettyprint">=C2=A0 =C2=A0 =C2=A0 =C2=A0 std::cout &lt;&=
lt; &quot;Lazily loading the data...\n&quot;;</div><div class=3D"subprettyp=
rint">=C2=A0 =C2=A0 =C2=A0 =C2=A0 this-&gt;data =3D std::vector&lt;int&gt;{=
1, 2, 3, 4, 5};</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 std::cout &lt;&lt; &quot;...done\n&quot;;</div><div class=3D"subprettyp=
rint">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return VectorWrapper&lt;int, true&gt;::Ge=
t(index);</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 }</div><div clas=
s=3D"subprettyprint">};</div></font></div></code></div><br><b>Is such a pro=
posal worth pursuing?</b></div><div><b><br></b></div><div>I think it follow=
s the pattern for conditional explicit and conditional noexcept in many way=
s.</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/b7fd8a46-593a-4505-8ceb-9bb0e9deb010%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b7fd8a46-593a-4505-8ceb-9bb0e9deb010=
%40isocpp.org</a>.<br />

------=_Part_52544_55052258.1530647652189--

------=_Part_52543_483192643.1530647652188--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 3 Jul 2018 14:13:40 -0700 (PDT)
Raw View
------=_Part_52699_1784832123.1530652420727
Content-Type: multipart/alternative;
 boundary="----=_Part_52700_1020955650.1530652420727"

------=_Part_52700_1020955650.1530652420727
Content-Type: text/plain; charset="UTF-8"

On Tuesday, July 3, 2018 at 3:54:12 PM UTC-4, Andrew Giese wrote:
>
> *Is such a proposal worth pursuing?*
>
> I think it follows the pattern for conditional explicit and conditional
> noexcept in many ways.
>

Yes, it follows the pattern. But the motivation you've provided is just...
not good code.

The foundation of your example is a misuse of inheritance. The relationship
between `VectorWrapper<T>` and `LazyIntLoader` is not "is a". Lazy loading
of integers is an *operation* on a container of some sort; it is not a
*container* itself. So why do you tightly bind it to `VectorWrapper<T>` in
such a way?

You encounter this problem only because you're using inheritance-based
polymorphism in an incorrect way.

Indeed, look at the quality of your solution. If I have some code that
takes a `const VectorWrapper<int, false>&`, I won't be able to take your
`LazyIntLoader` type, since it uses a `VectorWrapper<int, true>` as its
base class. My code doesn't care if some member variable is mutable or not.
And the mutable member doesn't change the public interface of the type at
all. Yet my code cannot work with your type, simply because of an
implementation detail in the derived class.

Indeed, every function that takes a `VectorWrapper` now has to specify
whether it is taking a mutable one or not; unless it is templated on the
mutability of the `VectorWrapper`, it won't be able to work with
`VectorWrapper` derived classes with a different mutability.

That is not a good solution to the problem.

Maybe conditional `mutable` is useful somewhere. But you'll need a better
motivating example, preferably one where the solution doesn't cause other
problems.

--
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/aab1d52c-f520-4aa3-a7a9-4c006c050838%40isocpp.org.

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

<div dir=3D"ltr">On Tuesday, July 3, 2018 at 3:54:12 PM UTC-4, Andrew Giese=
 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"><div><=
b>Is such a proposal worth pursuing?</b></div><div><b><br></b></div><div>I =
think it follows the pattern for conditional explicit and conditional noexc=
ept in many ways.</div></div></blockquote><div><br></div><div>Yes, it follo=
ws the pattern. But the motivation you&#39;ve provided is just... not good =
code.</div><div><br></div><div>The foundation of your example is a misuse o=
f inheritance. The relationship between `VectorWrapper&lt;T&gt;` and `LazyI=
ntLoader` is not &quot;is a&quot;. Lazy loading of integers is an <i>operat=
ion</i> on a container of some sort; it is not a <i>container</i> itself. S=
o why do you tightly bind it to `VectorWrapper&lt;T&gt;` in such a way?</di=
v><div><br></div><div>You encounter this problem only because you&#39;re us=
ing inheritance-based polymorphism in an incorrect way.</div><div><br></div=
><div>Indeed, look at the quality of your solution. If I have some code tha=
t takes a `const VectorWrapper&lt;int, false&gt;&amp;`, I won&#39;t be able=
 to take your `LazyIntLoader` type, since it uses a `VectorWrapper&lt;int, =
true&gt;` as its base class. My code doesn&#39;t care if some member variab=
le is mutable or not. And the mutable member doesn&#39;t change the public =
interface of the type at all. Yet my code cannot work with your type, simpl=
y because of an implementation detail in the derived class.</div><div><br><=
/div><div>Indeed, every function that takes a `VectorWrapper` now has to sp=
ecify whether it is taking a mutable one or not; unless it is templated on =
the mutability of the `VectorWrapper`, it won&#39;t be able to work with `V=
ectorWrapper` derived classes with a different mutability.<br></div><div><b=
r></div><div>That is not a good solution to the problem.</div><div><br></di=
v><div>Maybe conditional `mutable` is useful somewhere. But you&#39;ll need=
 a better motivating example, preferably one where the solution doesn&#39;t=
 cause other problems.<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/aab1d52c-f520-4aa3-a7a9-4c006c050838%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/aab1d52c-f520-4aa3-a7a9-4c006c050838=
%40isocpp.org</a>.<br />

------=_Part_52700_1020955650.1530652420727--

------=_Part_52699_1784832123.1530652420727--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Tue, 3 Jul 2018 22:20:17 +0100
Raw View
--000000000000a64b2505701ee212
Content-Type: text/plain; charset="UTF-8"

I'd like to second Nicol's notion that your motivating example is not
strong enough.

I can ... see that there is some value in your proposal - but is there
enough? Enough to offset syntax complications? Anyway, just my 2 cents.

On Tue, Jul 3, 2018 at 10:13 PM, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Tuesday, July 3, 2018 at 3:54:12 PM UTC-4, Andrew Giese wrote:
>>
>> *Is such a proposal worth pursuing?*
>>
>> I think it follows the pattern for conditional explicit and conditional
>> noexcept in many ways.
>>
>
> Yes, it follows the pattern. But the motivation you've provided is just...
> not good code.
>
> The foundation of your example is a misuse of inheritance. The
> relationship between `VectorWrapper<T>` and `LazyIntLoader` is not "is a".
> Lazy loading of integers is an *operation* on a container of some sort;
> it is not a *container* itself. So why do you tightly bind it to
> `VectorWrapper<T>` in such a way?
>
> You encounter this problem only because you're using inheritance-based
> polymorphism in an incorrect way.
>
> Indeed, look at the quality of your solution. If I have some code that
> takes a `const VectorWrapper<int, false>&`, I won't be able to take your
> `LazyIntLoader` type, since it uses a `VectorWrapper<int, true>` as its
> base class. My code doesn't care if some member variable is mutable or not.
> And the mutable member doesn't change the public interface of the type at
> all. Yet my code cannot work with your type, simply because of an
> implementation detail in the derived class.
>
> Indeed, every function that takes a `VectorWrapper` now has to specify
> whether it is taking a mutable one or not; unless it is templated on the
> mutability of the `VectorWrapper`, it won't be able to work with
> `VectorWrapper` derived classes with a different mutability.
>
> That is not a good solution to the problem.
>
> Maybe conditional `mutable` is useful somewhere. But you'll need a better
> motivating example, preferably one where the solution doesn't cause other
> problems.
>
> --
> 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/aab1d52c-f520-4aa3-
> a7a9-4c006c050838%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/aab1d52c-f520-4aa3-a7a9-4c006c050838%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/CAANG%3DkUOEYU_8dMDBKcPsqrrvR6cYChsyrb3GW1%3Dnx5rO0oC8Q%40mail.gmail.com.

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

<div dir=3D"ltr">I&#39;d like to second Nicol&#39;s notion that your motiva=
ting example is not strong enough.<div><br></div><div>I can ... see that th=
ere is some value in your proposal - but is there enough? Enough to offset =
syntax complications? Anyway, just my 2 cents.</div></div><div class=3D"gma=
il_extra"><br><div class=3D"gmail_quote">On Tue, Jul 3, 2018 at 10:13 PM, N=
icol Bolas <span dir=3D"ltr">&lt;<a href=3D"mailto:jmckesson@gmail.com" tar=
get=3D"_blank">jmckesson@gmail.com</a>&gt;</span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr"><span class=3D"">On Tuesday, July 3, 2018 =
at 3:54:12 PM UTC-4, Andrew Giese wrote:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div><b>Is such a proposal worth pursuing?</b></div><=
div><b><br></b></div><div>I think it follows the pattern for conditional ex=
plicit and conditional noexcept in many ways.</div></div></blockquote><div>=
<br></div></span><div>Yes, it follows the pattern. But the motivation you&#=
39;ve provided is just... not good code.</div><div><br></div><div>The found=
ation of your example is a misuse of inheritance. The relationship between =
`VectorWrapper&lt;T&gt;` and `LazyIntLoader` is not &quot;is a&quot;. Lazy =
loading of integers is an <i>operation</i> on a container of some sort; it =
is not a <i>container</i> itself. So why do you tightly bind it to `VectorW=
rapper&lt;T&gt;` in such a way?</div><div><br></div><div>You encounter this=
 problem only because you&#39;re using inheritance-based polymorphism in an=
 incorrect way.</div><div><br></div><div>Indeed, look at the quality of you=
r solution. If I have some code that takes a `const VectorWrapper&lt;int, f=
alse&gt;&amp;`, I won&#39;t be able to take your `LazyIntLoader` type, sinc=
e it uses a `VectorWrapper&lt;int, true&gt;` as its base class. My code doe=
sn&#39;t care if some member variable is mutable or not. And the mutable me=
mber doesn&#39;t change the public interface of the type at all. Yet my cod=
e cannot work with your type, simply because of an implementation detail in=
 the derived class.</div><div><br></div><div>Indeed, every function that ta=
kes a `VectorWrapper` now has to specify whether it is taking a mutable one=
 or not; unless it is templated on the mutability of the `VectorWrapper`, i=
t won&#39;t be able to work with `VectorWrapper` derived classes with a dif=
ferent mutability.<br></div><div><br></div><div>That is not a good solution=
 to the problem.</div><div><br></div><div>Maybe conditional `mutable` is us=
eful somewhere. But you&#39;ll need a better motivating example, preferably=
 one where the solution doesn&#39;t cause other problems.<br></div></div><s=
pan class=3D"">

<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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/aab1d52c-f520-4aa3-a7a9-4c006c050838%=
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/aab1=
d52c-f520-4aa3-<wbr>a7a9-4c006c050838%40isocpp.org</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/CAANG%3DkUOEYU_8dMDBKcPsqrrvR6cYChsyr=
b3GW1%3Dnx5rO0oC8Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkUOEY=
U_8dMDBKcPsqrrvR6cYChsyrb3GW1%3Dnx5rO0oC8Q%40mail.gmail.com</a>.<br />

--000000000000a64b2505701ee212--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Tue, 3 Jul 2018 18:00:52 -0400
Raw View
--0000000000009f93c805701f7245
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

In particular, mutable isn't a often used/needed keyword.  So there is low
incentive to improve it.

I think maybe if we got conditional-keywords everywhere else possible, and
mutable was the last one, then sure, do it for completeness.

(ie conditional const on member functions, etc)

And I don't know if those other places have any motivation either, but at
least they are used a lot.


On Tue, Jul 3, 2018 at 5:20 PM, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.=
com> wrote:

> I'd like to second Nicol's notion that your motivating example is not
> strong enough.
>
> I can ... see that there is some value in your proposal - but is there
> enough? Enough to offset syntax complications? Anyway, just my 2 cents.
>
> On Tue, Jul 3, 2018 at 10:13 PM, Nicol Bolas <jmckesson@gmail.com> wrote:
>
>> On Tuesday, July 3, 2018 at 3:54:12 PM UTC-4, Andrew Giese wrote:
>>>
>>> *Is such a proposal worth pursuing?*
>>>
>>> I think it follows the pattern for conditional explicit and conditional
>>> noexcept in many ways.
>>>
>>
>> Yes, it follows the pattern. But the motivation you've provided is
>> just... not good code.
>>
>> The foundation of your example is a misuse of inheritance. The
>> relationship between `VectorWrapper<T>` and `LazyIntLoader` is not "is a=
".
>> Lazy loading of integers is an *operation* on a container of some sort;
>> it is not a *container* itself. So why do you tightly bind it to
>> `VectorWrapper<T>` in such a way?
>>
>> You encounter this problem only because you're using inheritance-based
>> polymorphism in an incorrect way.
>>
>> Indeed, look at the quality of your solution. If I have some code that
>> takes a `const VectorWrapper<int, false>&`, I won't be able to take your
>> `LazyIntLoader` type, since it uses a `VectorWrapper<int, true>` as its
>> base class. My code doesn't care if some member variable is mutable or n=
ot.
>> And the mutable member doesn't change the public interface of the type a=
t
>> all. Yet my code cannot work with your type, simply because of an
>> implementation detail in the derived class.
>>
>> Indeed, every function that takes a `VectorWrapper` now has to specify
>> whether it is taking a mutable one or not; unless it is templated on the
>> mutability of the `VectorWrapper`, it won't be able to work with
>> `VectorWrapper` derived classes with a different mutability.
>>
>> That is not a good solution to the problem.
>>
>> Maybe conditional `mutable` is useful somewhere. But you'll need a bette=
r
>> motivating example, preferably one where the solution doesn't cause othe=
r
>> problems.
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/aab1d52c-f520-4aa3-a7a9-
>> 4c006c050838%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/aab1d52c-f=
520-4aa3-a7a9-4c006c050838%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
> --
> 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/CAANG%3DkUOEYU_
> 8dMDBKcPsqrrvR6cYChsyrb3GW1%3Dnx5rO0oC8Q%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkUO=
EYU_8dMDBKcPsqrrvR6cYChsyrb3GW1%3Dnx5rO0oC8Q%40mail.gmail.com?utm_medium=3D=
email&utm_source=3Dfooter>
> .
>



--=20
Be seeing you,
Tony

--=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/CAOHCbisYWoomGt1PdMe5TD-XxXR953NLY1uP6gg1xwrD9Fz=
BFw%40mail.gmail.com.

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

<div dir=3D"ltr"><div>In particular, mutable isn&#39;t a often used/needed =
keyword.=C2=A0 So there is low incentive to improve it.</div><div><br></div=
><div>I think maybe if we got conditional-keywords everywhere else possible=
, and mutable was the last one, then sure, do it for completeness.</div><di=
v><br></div><div>(ie conditional const on member functions, etc)</div><div>=
<br></div><div>And I don&#39;t know if those other places have any motivati=
on either, but at least they are used a lot.<br></div><div><br></div></div>=
<div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue, Jul 3, 20=
18 at 5:20 PM, Ga=C5=A1per A=C5=BEman <span dir=3D"ltr">&lt;<a href=3D"mail=
to:gasper.azman@gmail.com" target=3D"_blank">gasper.azman@gmail.com</a>&gt;=
</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I&#39;d l=
ike to second Nicol&#39;s notion that your motivating example is not strong=
 enough.<div><br></div><div>I can ... see that there is some value in your =
proposal - but is there enough? Enough to offset syntax complications? Anyw=
ay, just my 2 cents.</div></div><div><div class=3D"h5"><div class=3D"gmail_=
extra"><br><div class=3D"gmail_quote">On Tue, Jul 3, 2018 at 10:13 PM, Nico=
l Bolas <span dir=3D"ltr">&lt;<a href=3D"mailto:jmckesson@gmail.com" target=
=3D"_blank">jmckesson@gmail.com</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr"><span>On Tuesday, July 3, 2018 at 3:54:12 PM=
 UTC-4, Andrew Giese wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div><b>Is such a proposal worth pursuing?</b></div><div><b><br></=
b></div><div>I think it follows the pattern for conditional explicit and co=
nditional noexcept in many ways.</div></div></blockquote><div><br></div></s=
pan><div>Yes, it follows the pattern. But the motivation you&#39;ve provide=
d is just... not good code.</div><div><br></div><div>The foundation of your=
 example is a misuse of inheritance. The relationship between `VectorWrappe=
r&lt;T&gt;` and `LazyIntLoader` is not &quot;is a&quot;. Lazy loading of in=
tegers is an <i>operation</i> on a container of some sort; it is not a <i>c=
ontainer</i> itself. So why do you tightly bind it to `VectorWrapper&lt;T&g=
t;` in such a way?</div><div><br></div><div>You encounter this problem only=
 because you&#39;re using inheritance-based polymorphism in an incorrect wa=
y.</div><div><br></div><div>Indeed, look at the quality of your solution. I=
f I have some code that takes a `const VectorWrapper&lt;int, false&gt;&amp;=
`, I won&#39;t be able to take your `LazyIntLoader` type, since it uses a `=
VectorWrapper&lt;int, true&gt;` as its base class. My code doesn&#39;t care=
 if some member variable is mutable or not. And the mutable member doesn&#3=
9;t change the public interface of the type at all. Yet my code cannot work=
 with your type, simply because of an implementation detail in the derived =
class.</div><div><br></div><div>Indeed, every function that takes a `Vector=
Wrapper` now has to specify whether it is taking a mutable one or not; unle=
ss it is templated on the mutability of the `VectorWrapper`, it won&#39;t b=
e able to work with `VectorWrapper` derived classes with a different mutabi=
lity.<br></div><div><br></div><div>That is not a good solution to the probl=
em.</div><div><br></div><div>Maybe conditional `mutable` is useful somewher=
e. But you&#39;ll need a better motivating example, preferably one where th=
e solution doesn&#39;t cause other problems.<br></div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/aab1d52c-f520-4aa3-a7a9-4c006c050838%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/aab1=
d52c-f520-4aa3-a7a9-<wbr>4c006c050838%40isocpp.org</a>.<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" 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/CAANG%3DkUOEYU_8dMDBKcPsqrrvR6cYChsyr=
b3GW1%3Dnx5rO0oC8Q%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/=
std-<wbr>proposals/CAANG%3DkUOEYU_<wbr>8dMDBKcPsqrrvR6cYChsyrb3GW1%<wbr>3Dn=
x5rO0oC8Q%40mail.gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Be seeing =
you,<br></div>Tony<br></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/CAOHCbisYWoomGt1PdMe5TD-XxXR953NLY1uP=
6gg1xwrD9FzBFw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisYWoomGt1P=
dMe5TD-XxXR953NLY1uP6gg1xwrD9FzBFw%40mail.gmail.com</a>.<br />

--0000000000009f93c805701f7245--

.


Author: Andrew Giese <gieseanw@gmail.com>
Date: Tue, 3 Jul 2018 18:48:29 -0700 (PDT)
Raw View
------=_Part_54837_1839648117.1530668909403
Content-Type: multipart/alternative;
 boundary="----=_Part_54838_500606058.1530668909403"

------=_Part_54838_500606058.1530668909403
Content-Type: text/plain; charset="UTF-8"

I appreciate all the concerns, everyone. Please allow me to elaborate a
little further.

In the domain/project I'm working on, class ownership is fairly nested.
Most classes are thought of as "just containers for" another class(s), and
should act as such (inheritance).

For example: DomainObjectA "is just a container of" DomainObjectB and
DomainObjectB is "just a container of" DomainObjectC. "DomainObjectA" also

Each DomainObject may have different serialization/deserialization
semantics (e.g. from database, to binary, to flat files) that are specific
to that type and as such are implemented on a per-class basis. Whether or
not they're lazily loaded or not is on a per type basis.

So we would have something like so:

class DomainObjectA : public VectorWrapper<DomainObjectB>
{
   // override the getter to lazily load my actual data from disk
   mutable VectorWrapper<DomainObjectD> d_data; // secondary information
that is also lazily loaded, but A isn't thought of directly "as a"
container of DomainObjectD
};


class DomainObjectB : public VectorWrapper<DomainObjectC>
{
  // on construction, might immediately load all DomainObjectC
};

So the base class provides us almost all of the functionality each of these
derived classes needs, except the derived classes may decide to override
the getter to do lazy loading (Again I'm oversimplifying for the sake of
brevity and clarity; they can override any number of methods for their
needs, but this is the gist).

 If I have some code that takes a `const VectorWrapper<int, false>&`, I
> won't be able to take your `LazyIntLoader` type, since it uses a
> `VectorWrapper<int, true>` as its base class


This is a good point. I will mention that in our project this is not
generally an issue because we don't typically deal with the base class
directly. Also, whether or not the data member is mutable or not might
instead depend on a type trait (or whether a member function exists)
provided by the derived class, leading us to use a bit of CRTP (class
DomainObject A : public VectorWrapper<DomainObjectA<DomainObjectB>> for
example)

Of course we could always use composition

class DomainObjectA
{
    mutable VectorWrapper<DomainObjectB> b_data;

    public:
    VectorWrapper<DomainObjectB>& Get();
};


class DomainObjectB
{
   VectorWrapper<DomainObjectC> c_data;

   public:
   VectorWrapper<DomainObjectC>& Get();
};


But this introduces a level of indirection that makes it slightly harder to
deal with. Maybe we could get around that by forcing some kind of
interface. Or a proxy pattern. Or any number of template metaprogramming
techniques. Yes, there are ways to make it work,  but the inheritance
approach is very easy to read and write. This is especially important in a
codebase that consistently receives programmers new to C++ who want to get
going as quickly as possible.

Perhaps this situation is atypical or a "wrong" way to go about things, but
that hasn't been my experience. I'm not arguing that we dumb everything
down for the sake of new developers, but I feel like conditional mutability
would be both simple and expressive.

--
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/41b5ae72-bc96-4b46-b8cd-4e10a214622f%40isocpp.org.

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

<div dir=3D"ltr">I appreciate all the concerns, everyone. Please allow me t=
o elaborate a little further.<div><br></div><div>In the domain/project I&#3=
9;m working on, class ownership is fairly nested. Most classes are thought =
of as &quot;just containers for&quot; another class(s), and should act as s=
uch (inheritance).</div><div><br></div><div>For example: DomainObjectA &quo=
t;is just a container of&quot; DomainObjectB and DomainObjectB is &quot;jus=
t a container of&quot; DomainObjectC. &quot;DomainObjectA&quot; also=C2=A0<=
/div><div><br></div><div>Each DomainObject may have different serialization=
/deserialization semantics (e.g. from database, to binary, to flat files) t=
hat are specific to that type and as such are implemented on a per-class ba=
sis. Whether or not they&#39;re lazily loaded or not is on a per type basis=
..</div><div><br></div><div>So we would have something like so:</div><div><b=
r></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,=
 250); border-color: rgb(187, 187, 187); border-style: solid; border-width:=
 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"sub=
prettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">clas=
s</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">DomainObjectA</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">public</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">VectorWrapper</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">DomainObjectB</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// override the getter to lazily load my actual data from disk</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">mutable=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">VectorWrapper</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span=
 style=3D"color: #606;" class=3D"styled-by-prettify">DomainObjectD</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> d_data</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// secondary information that is also lazily l=
oaded, but A isn&#39;t thought of directly &quot;as a&quot; container of Do=
mainObjectD</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">DomainObjectB</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">public</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">VectorWrapper</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">DomainObjectC</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
on construction, might immediately load all DomainObjectC =C2=A0</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span></div></code></div=
><div><br></div><div>So the base class provides us almost all of the functi=
onality each of these derived classes needs, except the derived classes may=
 decide to override the getter to do lazy loading (Again I&#39;m oversimpli=
fying for the sake of brevity and clarity; they can override any number of =
methods for their needs, but this is the gist).=C2=A0</div><div><br></div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border=
-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">=C2=A0If I have so=
me code that takes a `const VectorWrapper&lt;int, false&gt;&amp;`, I won&#3=
9;t be able to take your `LazyIntLoader` type, since it uses a `VectorWrapp=
er&lt;int, true&gt;` as its base class</blockquote><div><br></div><div>This=
 is a good point. I will mention that in our project this is not generally =
an issue because we don&#39;t typically deal with the base class directly. =
Also, whether or not the data member is mutable or not might instead depend=
 on a type trait (or whether a member function exists) provided by the deri=
ved class, leading us to use a bit of CRTP (class DomainObject A : public V=
ectorWrapper&lt;DomainObjectA&lt;DomainObjectB&gt;&gt; for example)</div><d=
iv><br></div><div>Of course we could always use composition</div><div><br><=
/div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">DomainObjectA</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">mutable</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">VectorWrapper</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">DomainObjectB</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> b_data</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">public</span><font color=3D"#000000"><span =
style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span></font><span style=3D=
"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 </span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">VectorWrapper</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">DomainObjectB</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><font color=3D=
"#000000"><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Get</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span></font><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">DomainObjectB</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0</span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">VectorWrapper</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"styled-=
by-prettify">DomainObjectC</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> c_data</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">public</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0</span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">VectorWrapper</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
DomainObjectC</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&gt;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Get</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br></span></div></code></div><=
div><br>But this introduces a level of indirection that makes it slightly h=
arder to deal with. Maybe we could get around that by forcing some kind of =
interface. Or a proxy pattern. Or any number of template metaprogramming te=
chniques. Yes, there are ways to make it work,=C2=A0 but the inheritance ap=
proach is very easy to read and write. This is especially important in a co=
debase that consistently receives programmers new to C++ who want to get go=
ing as quickly as possible.</div><div><br></div><div>Perhaps this situation=
 is atypical or a &quot;wrong&quot; way to go about things, but that hasn&#=
39;t been my experience. I&#39;m not arguing that we dumb everything down f=
or the sake of new developers, but I feel like conditional mutability would=
 be both simple and expressive.</div><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/41b5ae72-bc96-4b46-b8cd-4e10a214622f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/41b5ae72-bc96-4b46-b8cd-4e10a214622f=
%40isocpp.org</a>.<br />

------=_Part_54838_500606058.1530668909403--

------=_Part_54837_1839648117.1530668909403--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Jul 2018 13:22:41 +0100
Raw View
--000000000000f128c705702b7d35
Content-Type: text/plain; charset="UTF-8"

Could you make a

template <typename T, bool Mutable>
struct cond_mutable_holder {
    T value;
};
template <typename T>
struct cond_mutable_holder<T, true> {
    mutable T value;
};

and use

cond_mutable_holder<VectorWrapper<DomainObjectC>, Mutable> m_data;

as your member, using m_data.value instead of plain m_data in your class.

That gives you a general-purpose widget for conditional mutability without
requiring a language feature. Am I missing something? Conditional noexcept
and constexpr are needed because they are necessary for function
annotations - this one isn't.


On Wed, Jul 4, 2018 at 2:48 AM, Andrew Giese <gieseanw@gmail.com> wrote:

> I appreciate all the concerns, everyone. Please allow me to elaborate a
> little further.
>
> In the domain/project I'm working on, class ownership is fairly nested.
> Most classes are thought of as "just containers for" another class(s), and
> should act as such (inheritance).
>
> For example: DomainObjectA "is just a container of" DomainObjectB and
> DomainObjectB is "just a container of" DomainObjectC. "DomainObjectA" also
>
> Each DomainObject may have different serialization/deserialization
> semantics (e.g. from database, to binary, to flat files) that are specific
> to that type and as such are implemented on a per-class basis. Whether or
> not they're lazily loaded or not is on a per type basis.
>
> So we would have something like so:
>
> class DomainObjectA : public VectorWrapper<DomainObjectB>
> {
>    // override the getter to lazily load my actual data from disk
>    mutable VectorWrapper<DomainObjectD> d_data; // secondary information
> that is also lazily loaded, but A isn't thought of directly "as a"
> container of DomainObjectD
> };
>
>
> class DomainObjectB : public VectorWrapper<DomainObjectC>
> {
>   // on construction, might immediately load all DomainObjectC
> };
>
> So the base class provides us almost all of the functionality each of
> these derived classes needs, except the derived classes may decide to
> override the getter to do lazy loading (Again I'm oversimplifying for the
> sake of brevity and clarity; they can override any number of methods for
> their needs, but this is the gist).
>
>  If I have some code that takes a `const VectorWrapper<int, false>&`, I
>> won't be able to take your `LazyIntLoader` type, since it uses a
>> `VectorWrapper<int, true>` as its base class
>
>
> This is a good point. I will mention that in our project this is not
> generally an issue because we don't typically deal with the base class
> directly. Also, whether or not the data member is mutable or not might
> instead depend on a type trait (or whether a member function exists)
> provided by the derived class, leading us to use a bit of CRTP (class
> DomainObject A : public VectorWrapper<DomainObjectA<DomainObjectB>> for
> example)
>
> Of course we could always use composition
>
> class DomainObjectA
> {
>     mutable VectorWrapper<DomainObjectB> b_data;
>
>     public:
>     VectorWrapper<DomainObjectB>& Get();
> };
>
>
> class DomainObjectB
> {
>    VectorWrapper<DomainObjectC> c_data;
>
>    public:
>    VectorWrapper<DomainObjectC>& Get();
> };
>
>
> But this introduces a level of indirection that makes it slightly harder
> to deal with. Maybe we could get around that by forcing some kind of
> interface. Or a proxy pattern. Or any number of template metaprogramming
> techniques. Yes, there are ways to make it work,  but the inheritance
> approach is very easy to read and write. This is especially important in a
> codebase that consistently receives programmers new to C++ who want to get
> going as quickly as possible.
>
> Perhaps this situation is atypical or a "wrong" way to go about things,
> but that hasn't been my experience. I'm not arguing that we dumb everything
> down for the sake of new developers, but I feel like conditional mutability
> would be both simple and expressive.
>
> --
> 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/is
> ocpp.org/d/msgid/std-proposals/41b5ae72-bc96-4b46-b8cd-
> 4e10a214622f%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/41b5ae72-bc96-4b46-b8cd-4e10a214622f%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/CAANG%3DkXKHyzNr4Q7aDrhkhmz8mUwFM-8i5p%3Do3rKjNY-RqyNUw%40mail.gmail.com.

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

<div dir=3D"ltr">Could you make a<div><br></div><div><font face=3D"monospac=
e, monospace">template &lt;typename T, bool Mutable&gt;</font></div><div><f=
ont face=3D"monospace, monospace">struct cond_mutable_holder {</font></div>=
<div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 T value;</font></div=
><div><font face=3D"monospace, monospace">};</font></div><div><font face=3D=
"monospace, monospace">template &lt;typename T&gt;</font></div><div><font f=
ace=3D"monospace, monospace">struct cond_mutable_holder&lt;T, true&gt; {</f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 mutable T =
value;</font></div><div><font face=3D"monospace, monospace">};</font></div>=
<div><br></div><div>and use=C2=A0</div><div><font face=3D"monospace, monosp=
ace"><br></font></div><div><font face=3D"monospace, monospace">cond_mutable=
_holder&lt;<wbr>VectorWrapper&lt;DomainObjectC&gt;, Mutable&gt; m_data;</fo=
nt></div><div><br></div><div>as your member, using <font face=3D"monospace,=
 monospace">m_data.value</font> instead of plain <font face=3D"monospace, m=
onospace">m_data </font><font face=3D"arial, helvetica, sans-serif">in your=
 class.</font></div><div><br></div><div>That gives you a general-purpose wi=
dget for conditional mutability without requiring a language feature. Am I =
missing something? Conditional noexcept and constexpr are needed because th=
ey are necessary for function annotations - this one isn&#39;t.</div><div><=
br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, =
Jul 4, 2018 at 2:48 AM, Andrew Giese <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:gieseanw@gmail.com" target=3D"_blank">gieseanw@gmail.com</a>&gt;</span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I appreciate all t=
he concerns, everyone. Please allow me to elaborate a little further.<div><=
br></div><div>In the domain/project I&#39;m working on, class ownership is =
fairly nested. Most classes are thought of as &quot;just containers for&quo=
t; another class(s), and should act as such (inheritance).</div><div><br></=
div><div>For example: DomainObjectA &quot;is just a container of&quot; Doma=
inObjectB and DomainObjectB is &quot;just a container of&quot; DomainObject=
C. &quot;DomainObjectA&quot; also=C2=A0</div><div><br></div><div>Each Domai=
nObject may have different serialization/deserialization semantics (e.g. fr=
om database, to binary, to flat files) that are specific to that type and a=
s such are implemented on a per-class basis. Whether or not they&#39;re laz=
ily loaded or not is on a per type basis.</div><div><br></div><div>So we wo=
uld have something like so:</div><div><br></div><div class=3D"m_18217241799=
04284831m_-4377923422633510485prettyprint" style=3D"background-color:rgb(25=
0,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1p=
x;word-wrap:break-word"><code class=3D"m_1821724179904284831m_-437792342263=
3510485prettyprint"><div class=3D"m_1821724179904284831m_-43779234226335104=
85subprettyprint"><span style=3D"color:#008" class=3D"m_1821724179904284831=
m_-4377923422633510485styled-by-prettify">class</span><span style=3D"color:=
#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettif=
y"> </span><span style=3D"color:#606" class=3D"m_1821724179904284831m_-4377=
923422633510485styled-by-prettify">DomainObjectA</span><span style=3D"color=
:#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pretti=
fy"> </span><span style=3D"color:#660" class=3D"m_1821724179904284831m_-437=
7923422633510485styled-by-prettify">:</span><span style=3D"color:#000" clas=
s=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"> </span=
><span style=3D"color:#008" class=3D"m_1821724179904284831m_-43779234226335=
10485styled-by-prettify">public</span><span style=3D"color:#000" class=3D"m=
_1821724179904284831m_-4377923422633510485styled-by-prettify"> </span><span=
 style=3D"color:#606" class=3D"m_1821724179904284831m_-4377923422633510485s=
tyled-by-prettify">VectorWrapper</span><span style=3D"color:#660" class=3D"=
m_1821724179904284831m_-4377923422633510485styled-by-prettify">&lt;</span><=
span style=3D"color:#606" class=3D"m_1821724179904284831m_-4377923422633510=
485styled-by-prettify">DomainObjectB</span><span style=3D"color:#660" class=
=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">&gt;</sp=
an><span style=3D"color:#000" class=3D"m_1821724179904284831m_-437792342263=
3510485styled-by-prettify"><br></span><span style=3D"color:#660" class=3D"m=
_1821724179904284831m_-4377923422633510485styled-by-prettify">{</span><span=
 style=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633510485s=
tyled-by-prettify"><br>=C2=A0 =C2=A0</span><span style=3D"color:#800" class=
=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">// overr=
ide the getter to lazily load my actual data from disk</span><span style=3D=
"color:#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-=
prettify"><br>=C2=A0 =C2=A0</span><span style=3D"color:#008" class=3D"m_182=
1724179904284831m_-4377923422633510485styled-by-prettify">mutable</span><sp=
an style=3D"color:#000" class=3D"m_1821724179904284831m_-437792342263351048=
5styled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_18217241=
79904284831m_-4377923422633510485styled-by-prettify">VectorWrapper</span><s=
pan style=3D"color:#660" class=3D"m_1821724179904284831m_-43779234226335104=
85styled-by-prettify">&lt;</span><span style=3D"color:#606" class=3D"m_1821=
724179904284831m_-4377923422633510485styled-by-prettify">DomainObjectD</spa=
n><span style=3D"color:#660" class=3D"m_1821724179904284831m_-4377923422633=
510485styled-by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_=
1821724179904284831m_-4377923422633510485styled-by-prettify"> d_data</span>=
<span style=3D"color:#660" class=3D"m_1821724179904284831m_-437792342263351=
0485styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_18217=
24179904284831m_-4377923422633510485styled-by-prettify"> </span><span style=
=3D"color:#800" class=3D"m_1821724179904284831m_-4377923422633510485styled-=
by-prettify">// secondary information that is also lazily loaded, but A isn=
&#39;t thought of directly &quot;as a&quot; container of DomainObjectD</spa=
n><span style=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633=
510485styled-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_=
1821724179904284831m_-4377923422633510485styled-by-prettify">};</span><span=
 style=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633510485s=
tyled-by-prettify"><br><br><br></span><span style=3D"color:#008" class=3D"m=
_1821724179904284831m_-4377923422633510485styled-by-prettify">class</span><=
span style=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633510=
485styled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_182172=
4179904284831m_-4377923422633510485styled-by-prettify">DomainObjectB</span>=
<span style=3D"color:#000" class=3D"m_1821724179904284831m_-437792342263351=
0485styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_18217=
24179904284831m_-4377923422633510485styled-by-prettify">:</span><span style=
=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-=
by-prettify"> </span><span style=3D"color:#008" class=3D"m_1821724179904284=
831m_-4377923422633510485styled-by-prettify">public</span><span style=3D"co=
lor:#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pre=
ttify"> </span><span style=3D"color:#606" class=3D"m_1821724179904284831m_-=
4377923422633510485styled-by-prettify">VectorWrapper</span><span style=3D"c=
olor:#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pr=
ettify">&lt;</span><span style=3D"color:#606" class=3D"m_182172417990428483=
1m_-4377923422633510485styled-by-prettify">DomainObjectC</span><span style=
=3D"color:#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-=
by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_1821724179904=
284831m_-4377923422633510485styled-by-prettify"><br></span><span style=3D"c=
olor:#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pr=
ettify">{</span><span style=3D"color:#000" class=3D"m_1821724179904284831m_=
-4377923422633510485styled-by-prettify"><br>=C2=A0 </span><span style=3D"co=
lor:#800" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pre=
ttify">// on construction, might immediately load all DomainObjectC =C2=A0<=
/span><span style=3D"color:#000" class=3D"m_1821724179904284831m_-437792342=
2633510485styled-by-prettify"><br></span><span style=3D"color:#660" class=
=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">};</span=
></div></code></div><div><br></div><div>So the base class provides us almos=
t all of the functionality each of these derived classes needs, except the =
derived classes may decide to override the getter to do lazy loading (Again=
 I&#39;m oversimplifying for the sake of brevity and clarity; they can over=
ride any number of methods for their needs, but this is the gist).=C2=A0</d=
iv><span><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
=C2=A0If I have some code that takes a `const VectorWrapper&lt;int, false&g=
t;&amp;`, I won&#39;t be able to take your `LazyIntLoader` type, since it u=
ses a `VectorWrapper&lt;int, true&gt;` as its base class</blockquote><div><=
br></div></span><div>This is a good point. I will mention that in our proje=
ct this is not generally an issue because we don&#39;t typically deal with =
the base class directly. Also, whether or not the data member is mutable or=
 not might instead depend on a type trait (or whether a member function exi=
sts) provided by the derived class, leading us to use a bit of CRTP (class =
DomainObject A : public VectorWrapper&lt;DomainObjectA&lt;Do<wbr>mainObject=
B&gt;&gt; for example)</div><div><br></div><div>Of course we could always u=
se composition</div><div><br></div><div class=3D"m_1821724179904284831m_-43=
77923422633510485prettyprint" style=3D"background-color:rgb(250,250,250);bo=
rder-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:b=
reak-word"><code class=3D"m_1821724179904284831m_-4377923422633510485pretty=
print"><div class=3D"m_1821724179904284831m_-4377923422633510485subprettypr=
int"><span style=3D"color:#008" class=3D"m_1821724179904284831m_-4377923422=
633510485styled-by-prettify">class</span><span style=3D"color:#000" class=
=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"> </span>=
<span style=3D"color:#606" class=3D"m_1821724179904284831m_-437792342263351=
0485styled-by-prettify">DomainObjectA</span><span style=3D"color:#000" clas=
s=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"><br></s=
pan><span style=3D"color:#660" class=3D"m_1821724179904284831m_-43779234226=
33510485styled-by-prettify">{</span><span style=3D"color:#000" class=3D"m_1=
821724179904284831m_-4377923422633510485styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008" class=3D"m_1821724179904284831m_-4377=
923422633510485styled-by-prettify">mutable</span><span style=3D"color:#000"=
 class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"> <=
/span><span style=3D"color:#606" class=3D"m_1821724179904284831m_-437792342=
2633510485styled-by-prettify">VectorWrapper</span><span style=3D"color:#660=
" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">&=
lt;</span><span style=3D"color:#606" class=3D"m_1821724179904284831m_-43779=
23422633510485styled-by-prettify">DomainObjectB</span><span style=3D"color:=
#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettif=
y">&gt;</span><span style=3D"color:#000" class=3D"m_1821724179904284831m_-4=
377923422633510485styled-by-prettify"> b_data</span><span style=3D"color:#6=
60" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"=
>;</span><span style=3D"color:#000" class=3D"m_1821724179904284831m_-437792=
3422633510485styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008" class=3D"m_1821724179904284831m_-4377923422633510485styled-=
by-prettify">public</span><font color=3D"#000000"><span style=3D"color:#660=
" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">:=
</span><span style=3D"color:#000" class=3D"m_1821724179904284831m_-43779234=
22633510485styled-by-prettify"><br></span></font><span style=3D"color:#000"=
 class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">=
=C2=A0 =C2=A0 </span><span style=3D"color:#606" class=3D"m_1821724179904284=
831m_-4377923422633510485styled-by-prettify">VectorWrapper</span><span styl=
e=3D"color:#660" class=3D"m_1821724179904284831m_-4377923422633510485styled=
-by-prettify">&lt;</span><span style=3D"color:#606" class=3D"m_182172417990=
4284831m_-4377923422633510485styled-by-prettify">DomainObjectB</span><span =
style=3D"color:#660" class=3D"m_1821724179904284831m_-4377923422633510485st=
yled-by-prettify">&gt;</span><font color=3D"#000000"><span style=3D"color:#=
660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify=
">&amp;</span><span style=3D"color:#000" class=3D"m_1821724179904284831m_-4=
377923422633510485styled-by-prettify"> </span><span style=3D"color:#606" cl=
ass=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify">Get</=
span><span style=3D"color:#660" class=3D"m_1821724179904284831m_-4377923422=
633510485styled-by-prettify">();</span></font><span style=3D"color:#000" cl=
ass=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"><br><=
/span><span style=3D"color:#660" class=3D"m_1821724179904284831m_-437792342=
2633510485styled-by-prettify">};</span><span style=3D"color:#000" class=3D"=
m_1821724179904284831m_-4377923422633510485styled-by-prettify"><br><br><br>=
</span><span style=3D"color:#008" class=3D"m_1821724179904284831m_-43779234=
22633510485styled-by-prettify">class</span><span style=3D"color:#000" class=
=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"> </span>=
<span style=3D"color:#606" class=3D"m_1821724179904284831m_-437792342263351=
0485styled-by-prettify">DomainObjectB</span><span style=3D"color:#000" clas=
s=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"><br></s=
pan><span style=3D"color:#660" class=3D"m_1821724179904284831m_-43779234226=
33510485styled-by-prettify">{</span><span style=3D"color:#000" class=3D"m_1=
821724179904284831m_-4377923422633510485styled-by-prettify"><br>=C2=A0 =C2=
=A0</span><span style=3D"color:#606" class=3D"m_1821724179904284831m_-43779=
23422633510485styled-by-prettify">VectorWrapper</span><span style=3D"color:=
#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettif=
y">&lt;</span><span style=3D"color:#606" class=3D"m_1821724179904284831m_-4=
377923422633510485styled-by-prettify">DomainObjectC</span><span style=3D"co=
lor:#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pre=
ttify">&gt;</span><span style=3D"color:#000" class=3D"m_1821724179904284831=
m_-4377923422633510485styled-by-prettify"> c_data</span><span style=3D"colo=
r:#660" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-prett=
ify">;</span><span style=3D"color:#000" class=3D"m_1821724179904284831m_-43=
77923422633510485styled-by-prettify"><br><br>=C2=A0 =C2=A0</span><span styl=
e=3D"color:#008" class=3D"m_1821724179904284831m_-4377923422633510485styled=
-by-prettify">public</span><span style=3D"color:#660" class=3D"m_1821724179=
904284831m_-4377923422633510485styled-by-prettify">:</span><span style=3D"c=
olor:#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-by-pr=
ettify"><br>=C2=A0 =C2=A0</span><span style=3D"color:#606" class=3D"m_18217=
24179904284831m_-4377923422633510485styled-by-prettify">VectorWrapper</span=
><span style=3D"color:#660" class=3D"m_1821724179904284831m_-43779234226335=
10485styled-by-prettify">&lt;</span><span style=3D"color:#606" class=3D"m_1=
821724179904284831m_-4377923422633510485styled-by-prettify">DomainObjectC</=
span><span style=3D"color:#660" class=3D"m_1821724179904284831m_-4377923422=
633510485styled-by-prettify">&gt;&amp;</span><span style=3D"color:#000" cla=
ss=3D"m_1821724179904284831m_-4377923422633510485styled-by-prettify"> </spa=
n><span style=3D"color:#606" class=3D"m_1821724179904284831m_-4377923422633=
510485styled-by-prettify">Get</span><span style=3D"color:#660" class=3D"m_1=
821724179904284831m_-4377923422633510485styled-by-prettify">();</span><span=
 style=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633510485s=
tyled-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_1821724=
179904284831m_-4377923422633510485styled-by-prettify">};</span><span style=
=3D"color:#000" class=3D"m_1821724179904284831m_-4377923422633510485styled-=
by-prettify"><br><br></span></div></code></div><div><br>But this introduces=
 a level of indirection that makes it slightly harder to deal with. Maybe w=
e could get around that by forcing some kind of interface. Or a proxy patte=
rn. Or any number of template metaprogramming techniques. Yes, there are wa=
ys to make it work,=C2=A0 but the inheritance approach is very easy to read=
 and write. This is especially important in a codebase that consistently re=
ceives programmers new to C++ who want to get going as quickly as possible.=
</div><div><br></div><div>Perhaps this situation is atypical or a &quot;wro=
ng&quot; way to go about things, but that hasn&#39;t been my experience. I&=
#39;m not arguing that we dumb everything down for the sake of new develope=
rs, but I feel like conditional mutability would be both simple and express=
ive.</div><div><br></div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/41b5ae72-bc96-4b46-b8cd-4e10a214622f%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/41b5=
ae72-bc96-4b46-b8cd-<wbr>4e10a214622f%40isocpp.org</a>.<br>
</blockquote></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/CAANG%3DkXKHyzNr4Q7aDrhkhmz8mUwFM-8i5=
p%3Do3rKjNY-RqyNUw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkXKHy=
zNr4Q7aDrhkhmz8mUwFM-8i5p%3Do3rKjNY-RqyNUw%40mail.gmail.com</a>.<br />

--000000000000f128c705702b7d35--

.


Author: Andrew Giese <gieseanw@gmail.com>
Date: Wed, 4 Jul 2018 09:30:50 -0700 (PDT)
Raw View
------=_Part_33651_1135699551.1530721850508
Content-Type: multipart/alternative;
 boundary="----=_Part_33652_660762940.1530721850508"

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


>
> Could you make a

template <typename T, bool Mutable>
struct cond_mutable_holder {
    T value;
};
template <typename T>
struct cond_mutable_holder<T, true> {
    mutable T value;
};


In my original post I did precisely that :-)=20

It is easy to use, but I argued that it introduced, in my opinion, a level=
=20
of indirection that should not be necessary. It's almost like what we had=
=20
to do for constexpr if before constexpr if was invented.

I think maybe if we got conditional-keywords everywhere else possible


Yeah, let's do that. Just go for broke, eh ;-)




On Wednesday, July 4, 2018 at 7:23:04 AM UTC-5, Ga=C5=A1per A=C5=BEman wrot=
e:
>
> Could you make a
>
> template <typename T, bool Mutable>
> struct cond_mutable_holder {
>     T value;
> };
> template <typename T>
> struct cond_mutable_holder<T, true> {
>     mutable T value;
> };
>
> and use=20
>
> cond_mutable_holder<VectorWrapper<DomainObjectC>, Mutable> m_data;
>
> as your member, using m_data.value instead of plain m_data in your class.
>
> That gives you a general-purpose widget for conditional mutability withou=
t=20
> requiring a language feature. Am I missing something? Conditional noexcep=
t=20
> and constexpr are needed because they are necessary for function=20
> annotations - this one isn't.
>
>
> On Wed, Jul 4, 2018 at 2:48 AM, Andrew Giese <gies...@gmail.com=20
> <javascript:>> wrote:
>
>> I appreciate all the concerns, everyone. Please allow me to elaborate a=
=20
>> little further.
>>
>> In the domain/project I'm working on, class ownership is fairly nested.=
=20
>> Most classes are thought of as "just containers for" another class(s), a=
nd=20
>> should act as such (inheritance).
>>
>> For example: DomainObjectA "is just a container of" DomainObjectB and=20
>> DomainObjectB is "just a container of" DomainObjectC. "DomainObjectA" al=
so=20
>>
>> Each DomainObject may have different serialization/deserialization=20
>> semantics (e.g. from database, to binary, to flat files) that are specif=
ic=20
>> to that type and as such are implemented on a per-class basis. Whether o=
r=20
>> not they're lazily loaded or not is on a per type basis.
>>
>> So we would have something like so:
>>
>> class DomainObjectA : public VectorWrapper<DomainObjectB>
>> {
>>    // override the getter to lazily load my actual data from disk
>>    mutable VectorWrapper<DomainObjectD> d_data; // secondary information=
=20
>> that is also lazily loaded, but A isn't thought of directly "as a"=20
>> container of DomainObjectD
>> };
>>
>>
>> class DomainObjectB : public VectorWrapper<DomainObjectC>
>> {
>>   // on construction, might immediately load all DomainObjectC =20
>> };
>>
>> So the base class provides us almost all of the functionality each of=20
>> these derived classes needs, except the derived classes may decide to=20
>> override the getter to do lazy loading (Again I'm oversimplifying for th=
e=20
>> sake of brevity and clarity; they can override any number of methods for=
=20
>> their needs, but this is the gist).=20
>>
>>  If I have some code that takes a `const VectorWrapper<int, false>&`, I=
=20
>>> won't be able to take your `LazyIntLoader` type, since it uses a=20
>>> `VectorWrapper<int, true>` as its base class
>>
>>
>> This is a good point. I will mention that in our project this is not=20
>> generally an issue because we don't typically deal with the base class=
=20
>> directly. Also, whether or not the data member is mutable or not might=
=20
>> instead depend on a type trait (or whether a member function exists)=20
>> provided by the derived class, leading us to use a bit of CRTP (class=20
>> DomainObject A : public VectorWrapper<DomainObjectA<DomainObjectB>> for=
=20
>> example)
>>
>> Of course we could always use composition
>>
>> class DomainObjectA
>> {
>>     mutable VectorWrapper<DomainObjectB> b_data;
>>
>>     public:
>>     VectorWrapper<DomainObjectB>& Get();
>> };
>>
>>
>> class DomainObjectB
>> {
>>    VectorWrapper<DomainObjectC> c_data;
>>
>>    public:
>>    VectorWrapper<DomainObjectC>& Get();
>> };
>>
>>
>> But this introduces a level of indirection that makes it slightly harder=
=20
>> to deal with. Maybe we could get around that by forcing some kind of=20
>> interface. Or a proxy pattern. Or any number of template metaprogramming=
=20
>> techniques. Yes, there are ways to make it work,  but the inheritance=20
>> approach is very easy to read and write. This is especially important in=
 a=20
>> codebase that consistently receives programmers new to C++ who want to g=
et=20
>> going as quickly as possible.
>>
>> Perhaps this situation is atypical or a "wrong" way to go about things,=
=20
>> but that hasn't been my experience. I'm not arguing that we dumb everyth=
ing=20
>> down for the sake of new developers, but I feel like conditional mutabil=
ity=20
>> would be both simple and expressive.
>>
>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> 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=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/41b5ae72-bc=
96-4b46-b8cd-4e10a214622f%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/41b5ae72-b=
c96-4b46-b8cd-4e10a214622f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
>

--=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/90aeb2d0-cb3e-490f-9fd0-d00aa5a0f9bd%40isocpp.or=
g.

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

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px=
 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">=
Could you make a</blockquote><div class=3D"prettyprint" style=3D"background=
-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style:=
 solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Mutable</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> cond_mutable_holder </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 T value</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> cond_mutable_holder</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">true</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">mutabl=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T value<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br></span></div></code></div>=
<div><br><font face=3D"monospace, monospace">In my original post I did prec=
isely that :-)=C2=A0</font></div><div><font face=3D"monospace, monospace"><=
br></font></div><div><font face=3D"monospace, monospace">It is easy to use,=
 but I argued that it introduced, in my opinion, a level of indirection tha=
t should not be necessary. It&#39;s almost like what we had to do for const=
expr if before constexpr if was invented.</font></div><div><font face=3D"mo=
nospace, monospace"><br></font></div><div><blockquote class=3D"gmail_quote"=
 style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 2=
04); padding-left: 1ex;">I think maybe if we got conditional-keywords every=
where else possible</blockquote><font face=3D"monospace, monospace"><br></f=
ont></div><div><font face=3D"monospace, monospace">Yeah, let&#39;s do that.=
 Just go for broke, eh ;-)</font></div><div><font face=3D"monospace, monosp=
ace"><br></font></div><div><font face=3D"monospace, monospace"><br></font><=
/div><div><font face=3D"monospace, monospace"><br></font></div><br>On Wedne=
sday, July 4, 2018 at 7:23:04 AM UTC-5, Ga=C5=A1per A=C5=BEman wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Could you make a<di=
v><br></div><div><font face=3D"monospace, monospace">template &lt;typename =
T, bool Mutable&gt;</font></div><div><font face=3D"monospace, monospace">st=
ruct cond_mutable_holder {</font></div><div><font face=3D"monospace, monosp=
ace">=C2=A0 =C2=A0 T value;</font></div><div><font face=3D"monospace, monos=
pace">};</font></div><div><font face=3D"monospace, monospace">template &lt;=
typename T&gt;</font></div><div><font face=3D"monospace, monospace">struct =
cond_mutable_holder&lt;T, true&gt; {</font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 mutable T value;</font></div><div><font face=
=3D"monospace, monospace">};</font></div><div><br></div><div>and use=C2=A0<=
/div><div><font face=3D"monospace, monospace"><br></font></div><div><font f=
ace=3D"monospace, monospace">cond_mutable_holder&lt;<wbr>VectorWrapper&lt;D=
omainObjectC&gt;, Mutable&gt; m_data;</font></div><div><br></div><div>as yo=
ur member, using <font face=3D"monospace, monospace">m_data.value</font> in=
stead of plain <font face=3D"monospace, monospace">m_data </font><font face=
=3D"arial, helvetica, sans-serif">in your class.</font></div><div><br></div=
><div>That gives you a general-purpose widget for conditional mutability wi=
thout requiring a language feature. Am I missing something? Conditional noe=
xcept and constexpr are needed because they are necessary for function anno=
tations - this one isn&#39;t.</div><div><br></div><div><br><div class=3D"gm=
ail_quote">On Wed, Jul 4, 2018 at 2:48 AM, Andrew Giese <span dir=3D"ltr">&=
lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"n4HKz=
XqDCQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;=
return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">gi=
es...@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr">I appreciate all the concerns, everyone. Please allow me to e=
laborate a little further.<div><br></div><div>In the domain/project I&#39;m=
 working on, class ownership is fairly nested. Most classes are thought of =
as &quot;just containers for&quot; another class(s), and should act as such=
 (inheritance).</div><div><br></div><div>For example: DomainObjectA &quot;i=
s just a container of&quot; DomainObjectB and DomainObjectB is &quot;just a=
 container of&quot; DomainObjectC. &quot;DomainObjectA&quot; also=C2=A0</di=
v><div><br></div><div>Each DomainObject may have different serialization/de=
serialization semantics (e.g. from database, to binary, to flat files) that=
 are specific to that type and as such are implemented on a per-class basis=
.. Whether or not they&#39;re lazily loaded or not is on a per type basis.</=
div><div><br></div><div>So we would have something like so:</div><div><br><=
/div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><di=
v><span style=3D"color:#008">class</span><span style=3D"color:#000"> </span=
><span style=3D"color:#606">DomainObjectA</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">:</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">public</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#606">VectorWrapper</span><span style=3D"color:#660=
">&lt;</span><span style=3D"color:#606">DomainObjectB</span><span style=3D"=
color:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</span><sp=
an style=3D"color:#800">// override the getter to lazily load my actual dat=
a from disk</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</span><span =
style=3D"color:#008">mutable</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#606">VectorWrapper</span><span style=3D"color:#660">&lt;</=
span><span style=3D"color:#606">DomainObjectD</span><span style=3D"color:#6=
60">&gt;</span><span style=3D"color:#000"> d_data</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">// secondary information that is also lazily loaded, but A isn&#39;t tho=
ught of directly &quot;as a&quot; container of DomainObjectD</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">};</span><span sty=
le=3D"color:#000"><br><br><br></span><span style=3D"color:#008">class</span=
><span style=3D"color:#000"> </span><span style=3D"color:#606">DomainObject=
B</span><span style=3D"color:#000"> </span><span style=3D"color:#660">:</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">public</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#606">VectorWrap=
per</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#606">=
DomainObjectC</span><span style=3D"color:#660">&gt;</span><span style=3D"co=
lor:#000"><br></span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"><br>=C2=A0 </span><span style=3D"color:#800">// on construction, mi=
ght immediately load all DomainObjectC =C2=A0</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#660">};</span></div></code></div><div>=
<br></div><div>So the base class provides us almost all of the functionalit=
y each of these derived classes needs, except the derived classes may decid=
e to override the getter to do lazy loading (Again I&#39;m oversimplifying =
for the sake of brevity and clarity; they can override any number of method=
s for their needs, but this is the gist).=C2=A0</div><span><div><br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft:1px solid rgb(204,204,204);padding-left:1ex">=C2=A0If I have some code =
that takes a `const VectorWrapper&lt;int, false&gt;&amp;`, I won&#39;t be a=
ble to take your `LazyIntLoader` type, since it uses a `VectorWrapper&lt;in=
t, true&gt;` as its base class</blockquote><div><br></div></span><div>This =
is a good point. I will mention that in our project this is not generally a=
n issue because we don&#39;t typically deal with the base class directly. A=
lso, whether or not the data member is mutable or not might instead depend =
on a type trait (or whether a member function exists) provided by the deriv=
ed class, leading us to use a bit of CRTP (class DomainObject A : public Ve=
ctorWrapper&lt;DomainObjectA&lt;<wbr>DomainObjectB&gt;&gt; for example)</di=
v><div><br></div><div>Of course we could always use composition</div><div><=
br></div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(1=
87,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code=
><div><span style=3D"color:#008">class</span><span style=3D"color:#000"> </=
span><span style=3D"color:#606">DomainObjectA</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#660">{</span><span style=3D"color:#000=
"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">mutable</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#606">VectorWrapper</span>=
<span style=3D"color:#660">&lt;</span><span style=3D"color:#606">DomainObje=
ctB</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000">=
 b_data</span><span style=3D"color:#660">;</span><span style=3D"color:#000"=
><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">public</span><font=
 color=3D"#000000"><span style=3D"color:#660">:</span><span style=3D"color:=
#000"><br></span></font><span style=3D"color:#000">=C2=A0 =C2=A0 </span><sp=
an style=3D"color:#606">VectorWrapper</span><span style=3D"color:#660">&lt;=
</span><span style=3D"color:#606">DomainObjectB</span><span style=3D"color:=
#660">&gt;</span><font color=3D"#000000"><span style=3D"color:#660">&amp;</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">Get</spa=
n><span style=3D"color:#660">();</span></font><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br=
><br><br></span><span style=3D"color:#008">class</span><span style=3D"color=
:#000"> </span><span style=3D"color:#606">DomainObjectB</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0</span><span style=3D"color:#606">VectorWr=
apper</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#606=
">DomainObjectC</span><span style=3D"color:#660">&gt;</span><span style=3D"=
color:#000"> c_data</span><span style=3D"color:#660">;</span><span style=3D=
"color:#000"><br><br>=C2=A0 =C2=A0</span><span style=3D"color:#008">public<=
/span><span style=3D"color:#660">:</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0</span><span style=3D"color:#606">VectorWrapper</span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#606">DomainObjectC</span><=
span style=3D"color:#660">&gt;&amp;</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#606">Get</span><span style=3D"color:#660">();</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#660">};</span>=
<span style=3D"color:#000"><br><br></span></div></code></div><div><br>But t=
his introduces a level of indirection that makes it slightly harder to deal=
 with. Maybe we could get around that by forcing some kind of interface. Or=
 a proxy pattern. Or any number of template metaprogramming techniques. Yes=
, there are ways to make it work,=C2=A0 but the inheritance approach is ver=
y easy to read and write. This is especially important in a codebase that c=
onsistently receives programmers new to C++ who want to get going as quickl=
y as possible.</div><div><br></div><div>Perhaps this situation is atypical =
or a &quot;wrong&quot; way to go about things, but that hasn&#39;t been my =
experience. I&#39;m not arguing that we dumb everything down for the sake o=
f new developers, but I feel like conditional mutability would be both simp=
le and expressive.</div><div><br></div></div><span>

<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"=
n4HKzXqDCQAJ" 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"n4HKzXqDCQAJ" 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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/41b5ae72-bc96-4b46-b8cd-4e10a214622f%=
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/41b5ae72-bc96-4b46-b8cd-4e10a214622f%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/41b5ae72-bc96-4b46-b8cd-4e10a214622f%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/41b5ae72-bc96-4b46-<wbr>b8cd-=
4e10a214622f%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/90aeb2d0-cb3e-490f-9fd0-d00aa5a0f9bd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/90aeb2d0-cb3e-490f-9fd0-d00aa5a0f9bd=
%40isocpp.org</a>.<br />

------=_Part_33652_660762940.1530721850508--

------=_Part_33651_1135699551.1530721850508--

.


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Wed, 4 Jul 2018 09:39:57 -0700 (PDT)
Raw View
------=_Part_60777_1658564506.1530722397872
Content-Type: multipart/alternative;
 boundary="----=_Part_60778_1244115318.1530722397872"

------=_Part_60778_1244115318.1530722397872
Content-Type: text/plain; charset="UTF-8"


On Tuesday, July 3, 2018 at 5:00:55 PM UTC-5, Tony V E wrote:
>
> In particular, mutable isn't a often used/needed keyword.  So there is low
> incentive to improve it.
>
> I think maybe if we got conditional-keywords everywhere else possible, and
> mutable was the last one, then sure, do it for completeness.
>
> (ie conditional const on member functions, etc)
>
> And I don't know if those other places have any motivation either, but at
> least they are used a lot.
>
>
The only other one that I could think of as being motivated was conditional
delete. There are plenty of scenarios where you want something like (and
I'll use concepts for brevity):

template <typename T> requires C<T>
void foo(T ) { /* stuff */ }

template <typename T>
void foo(T ) = delete;

 That's a pattern that crops up regularly. Sometimes you just want to
constrain foo, but sometimes you also want to delete the unconstrained one.
But this *really* doesn't work syntactically with the conditional syntax -
since conditional explicit and conditional noexcept are both like, paste
this keyword or not (kind of) whereas in this case, it's do one thing or
this entirely different thing.

I mean, this looks ridiculous right?

template <typename T>
void foo(T ) = delete(!C<T>)
{ /* stuff */ }

Conditional default is less common but definitely exists, and has the same
problem of how do you even syntactically express this?

I couldn't think of any scenarios where you'd want something that is
conditionally static, or conditionally virtual, or conditionally public, or
....

--
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/752f7920-abfc-4697-bac8-5b2fa3fb701d%40isocpp.org.

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

<div dir=3D"ltr"><br>On Tuesday, July 3, 2018 at 5:00:55 PM UTC-5, Tony V E=
 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"><div>I=
n particular, mutable isn&#39;t a often used/needed keyword.=C2=A0 So there=
 is low incentive to improve it.</div><div><br></div><div>I think maybe if =
we got conditional-keywords everywhere else possible, and mutable was the l=
ast one, then sure, do it for completeness.</div><div><br></div><div>(ie co=
nditional const on member functions, etc)</div><div><br></div><div>And I do=
n&#39;t know if those other places have any motivation either, but at least=
 they are used a lot.<br></div><div><br></div></div></blockquote><div><br><=
/div><div>The only other one that I could think of as being motivated was c=
onditional delete. There are plenty of scenarios where you want something l=
ike (and I&#39;ll use concepts for brevity):</div><div><br></div><div><div =
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wr=
ap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<font color=3D"#660066"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> requires C</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">T </span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">/* stuff */</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">template</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">ty=
pename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">T </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></font=
></div></code></div><br>=C2=A0That&#39;s a pattern that crops up regularly.=
 Sometimes you just want to constrain foo, but sometimes you also want to d=
elete the unconstrained one. But this <i>really</i>=C2=A0doesn&#39;t work s=
yntactically with the conditional syntax - since conditional explicit and c=
onditional noexcept are both like, paste this keyword or not (kind of) wher=
eas in this case, it&#39;s do one thing or this entirely different thing.</=
div><div><br></div><div>I mean, this looks ridiculous right?</div><div><br>=
</div><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wid=
th: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"=
subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
emplate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">T </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><font color=3D"#666600"><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">del=
ete</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">C</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">/* stuff */</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>}</span></font><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span></div></code></div><br>Conditional default is less common but def=
initely exists, and has the same problem of how do you even syntactically e=
xpress this?</div><div><br></div><div>I couldn&#39;t think of any scenarios=
 where you&#39;d want something that is conditionally static, or conditiona=
lly virtual, or conditionally public, or ...</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/752f7920-abfc-4697-bac8-5b2fa3fb701d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/752f7920-abfc-4697-bac8-5b2fa3fb701d=
%40isocpp.org</a>.<br />

------=_Part_60778_1244115318.1530722397872--

------=_Part_60777_1658564506.1530722397872--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 4 Jul 2018 10:04:20 -0700 (PDT)
Raw View
------=_Part_61251_70155687.1530723860738
Content-Type: multipart/alternative;
 boundary="----=_Part_61252_506642398.1530723860739"

------=_Part_61252_506642398.1530723860739
Content-Type: text/plain; charset="UTF-8"

On Wednesday, July 4, 2018 at 12:39:58 PM UTC-4, Barry Revzin wrote:
>
> On Tuesday, July 3, 2018 at 5:00:55 PM UTC-5, Tony V E wrote:
>>
>> In particular, mutable isn't a often used/needed keyword.  So there is
>> low incentive to improve it.
>>
>> I think maybe if we got conditional-keywords everywhere else possible,
>> and mutable was the last one, then sure, do it for completeness.
>>
>> (ie conditional const on member functions, etc)
>>
>> And I don't know if those other places have any motivation either, but at
>> least they are used a lot.
>>
>>
> The only other one that I could think of as being motivated was
> conditional delete. There are plenty of scenarios where you want something
> like (and I'll use concepts for brevity):
>
> template <typename T> requires C<T>
> void foo(T ) { /* stuff */ }
>
> template <typename T>
> void foo(T ) = delete;
>
>
Assuming there are no other viable overloads for `foo`, why do you need the
`= delete` part? If the given `T` doesn't satisfy `C`, you get a compile
error due to the lack of a `foo`.

So what does deleting the unconstrained version do for you?

--
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/118b9c7e-c9fb-4889-8bdc-c6452be6f49d%40isocpp.org.

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

<div dir=3D"ltr">On Wednesday, July 4, 2018 at 12:39:58 PM UTC-4, Barry Rev=
zin 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, July 3, 2018 at 5:00:55 PM UTC-5, Tony V E 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"><div>In particular, mutable isn&#39=
;t a often used/needed keyword.=C2=A0 So there is low incentive to improve =
it.</div><div><br></div><div>I think maybe if we got conditional-keywords e=
verywhere else possible, and mutable was the last one, then sure, do it for=
 completeness.</div><div><br></div><div>(ie conditional const on member fun=
ctions, etc)</div><div><br></div><div>And I don&#39;t know if those other p=
laces have any motivation either, but at least they are used a lot.<br></di=
v><div><br></div></div></blockquote><div><br></div><div>The only other one =
that I could think of as being motivated was conditional delete. There are =
plenty of scenarios where you want something like (and I&#39;ll use concept=
s for brevity):</div><div><br></div><div><div style=3D"background-color:rgb=
(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width=
:1px;word-wrap:break-word"><code><div><font color=3D"#660066"><span style=
=3D"color:#008">template</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span><spa=
n style=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><span=
 style=3D"color:#000"> requires C</span><span style=3D"color:#660">&lt;</sp=
an><span style=3D"color:#000">T</span><span style=3D"color:#660">&gt;</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">void</spa=
n><span style=3D"color:#000"> foo</span><span style=3D"color:#660">(</span>=
<span style=3D"color:#000">T </span><span style=3D"color:#660">)</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#800">/* stuff */</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span sty=
le=3D"color:#000"><br><br></span><span style=3D"color:#008">template</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><s=
pan style=3D"color:#008">typename</span><span style=3D"color:#000"> T</span=
><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#008">void</span><span style=3D"color:#000"> foo</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#000">T </span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">delete</span><span style=3D"color:#660">;</span></font></=
div></code></div><br></div></div></blockquote><div><br></div><div>Assuming =
there are no other viable overloads for `foo`, why do you need the `=3D del=
ete` part? If the given `T` doesn&#39;t satisfy `C`, you get a compile erro=
r due to the lack of a `foo`.</div><div><br></div><div>So what does deletin=
g the unconstrained version do for you?<br></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/118b9c7e-c9fb-4889-8bdc-c6452be6f49d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/118b9c7e-c9fb-4889-8bdc-c6452be6f49d=
%40isocpp.org</a>.<br />

------=_Part_61252_506642398.1530723860739--

------=_Part_61251_70155687.1530723860738--

.


Author: Andrew Giese <gieseanw@gmail.com>
Date: Tue, 25 Sep 2018 09:31:50 -0700
Raw View
--0000000000004e496a0576b4a52f
Content-Type: text/plain; charset="UTF-8"

Sitting at CppCon listening to Kate Gregory's (wonderful) talk "What do we
mean when we say nothing at all" reminds me of this.

A big motivating example for "bool'ing" keywords like mutable and
"explicit" is understandability.

We can make it very clear we intended to have an implicit constructor or a
non-mutable member variable if we had these.

She goes as far as to say even const(false) is useful on member functions,
and it's pretty compelling.

Regards,
Andy

--
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/CAO8_tC7D6a80x-kBnQZ0mx3tXQQFQqnPBJEqLuxkSSknbXkZ0Q%40mail.gmail.com.

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

<div dir=3D"auto">Sitting at CppCon listening to Kate Gregory&#39;s (wonder=
ful) talk &quot;What do we mean when we say nothing at all&quot; reminds me=
 of this.<div dir=3D"auto"><br></div><div dir=3D"auto">A big motivating exa=
mple for &quot;bool&#39;ing&quot; keywords like mutable and &quot;explicit&=
quot; is understandability.</div><div dir=3D"auto"><br></div><div dir=3D"au=
to">We can make it very clear we intended to have an implicit constructor o=
r a non-mutable member variable if we had these.=C2=A0</div><div dir=3D"aut=
o"><br></div><div dir=3D"auto">She goes as far as to say even const(false) =
is useful on member functions, and it&#39;s pretty compelling.</div><div di=
r=3D"auto"><br></div><div dir=3D"auto">Regards,</div><div dir=3D"auto">Andy=
</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/CAO8_tC7D6a80x-kBnQZ0mx3tXQQFQqnPBJEq=
LuxkSSknbXkZ0Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAO8_tC7D6a80x-kB=
nQZ0mx3tXQQFQqnPBJEqLuxkSSknbXkZ0Q%40mail.gmail.com</a>.<br />

--0000000000004e496a0576b4a52f--

.


Author: Andrew Giese <gieseanw@gmail.com>
Date: Tue, 25 Sep 2018 09:48:34 -0700
Raw View
--0000000000002e22db0576b4e1e0
Content-Type: text/plain; charset="UTF-8"

I didn't realize when I'd sent this that we are already getting explicit
(expression) in C++20.

I think this serves to provide more momentum to upgrade our other keywords,
even "virtual".



On Tue, Sep 25, 2018, 9:31 AM Andrew Giese <gieseanw@gmail.com> wrote:

> Sitting at CppCon listening to Kate Gregory's (wonderful) talk "What do we
> mean when we say nothing at all" reminds me of this.
>
> A big motivating example for "bool'ing" keywords like mutable and
> "explicit" is understandability.
>
> We can make it very clear we intended to have an implicit constructor or a
> non-mutable member variable if we had these.
>
> She goes as far as to say even const(false) is useful on member functions,
> and it's pretty compelling.
>
> Regards,
> Andy
>

--
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/CAO8_tC5ox0_RPrT3xBUbcCW%2BZE908voNPa1bHh07JzByDfmPiw%40mail.gmail.com.

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

<div dir=3D"auto">I didn&#39;t realize when I&#39;d sent this that we are a=
lready getting explicit (expression) in C++20.<div dir=3D"auto"><br></div><=
div dir=3D"auto">I think this serves to provide more momentum to upgrade ou=
r other keywords, even &quot;virtual&quot;.</div><div dir=3D"auto"><br></di=
v><div dir=3D"auto"><br></div></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr">On Tue, Sep 25, 2018, 9:31 AM Andrew Giese &lt;<a href=3D"mailto:g=
ieseanw@gmail.com">gieseanw@gmail.com</a>&gt; wrote:<br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex"><div dir=3D"auto">Sitting at CppCon listening to Kate Gre=
gory&#39;s (wonderful) talk &quot;What do we mean when we say nothing at al=
l&quot; reminds me of this.<div dir=3D"auto"><br></div><div dir=3D"auto">A =
big motivating example for &quot;bool&#39;ing&quot; keywords like mutable a=
nd &quot;explicit&quot; is understandability.</div><div dir=3D"auto"><br></=
div><div dir=3D"auto">We can make it very clear we intended to have an impl=
icit constructor or a non-mutable member variable if we had these.=C2=A0</d=
iv><div dir=3D"auto"><br></div><div dir=3D"auto">She goes as far as to say =
even const(false) is useful on member functions, and it&#39;s pretty compel=
ling.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Regards,</div><div=
 dir=3D"auto">Andy</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/CAO8_tC5ox0_RPrT3xBUbcCW%2BZE908voNPa=
1bHh07JzByDfmPiw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAO8_tC5ox0_RPr=
T3xBUbcCW%2BZE908voNPa1bHh07JzByDfmPiw%40mail.gmail.com</a>.<br />

--0000000000002e22db0576b4e1e0--

.


Author: Nicolas Lesser <blitzrakete@gmail.com>
Date: Tue, 25 Sep 2018 20:14:30 +0200
Raw View
--0000000000008892cf0576b6141a
Content-Type: text/plain; charset="UTF-8"

I disagree. We shouldn't just add keyword(expression) for everything just
because we can. What does a conditional virtual even mean? I haven't seen
the talk yet, but a conditional const is also meaningless IMO.  I don't
want my member functions to look like this:

virtual(false) void foo() noexcept(true) const(true) volatile(false);

It's a bit of an extreme example, but I don't see the need to be soooo
explicit about *everything*. I don't really like explicit(expr), but it
solves a specific use case. That it also allows explicit(false) to be more
explicit is a minor point. I won't recommend doing that, but if you want
to, I won't stop you. But this can't be the primary motivation to add such
a conditional IMO.

On Tue, Sep 25, 2018 at 6:48 PM Andrew Giese <gieseanw@gmail.com> wrote:

> I didn't realize when I'd sent this that we are already getting explicit
> (expression) in C++20.
>
> I think this serves to provide more momentum to upgrade our other
> keywords, even "virtual".
>
>
>
> On Tue, Sep 25, 2018, 9:31 AM Andrew Giese <gieseanw@gmail.com> wrote:
>
>> Sitting at CppCon listening to Kate Gregory's (wonderful) talk "What do
>> we mean when we say nothing at all" reminds me of this.
>>
>> A big motivating example for "bool'ing" keywords like mutable and
>> "explicit" is understandability.
>>
>> We can make it very clear we intended to have an implicit constructor or
>> a non-mutable member variable if we had these.
>>
>> She goes as far as to say even const(false) is useful on member
>> functions, and it's pretty compelling.
>>
>> Regards,
>> Andy
>>
> --
> 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/CAO8_tC5ox0_RPrT3xBUbcCW%2BZE908voNPa1bHh07JzByDfmPiw%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAO8_tC5ox0_RPrT3xBUbcCW%2BZE908voNPa1bHh07JzByDfmPiw%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/CALmDwq2k6fgN7qv-4wBZOq_aqAbq9Jd7A10udkqocxacxdNM0g%40mail.gmail.com.

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

<div dir=3D"ltr">I disagree. We shouldn&#39;t just add keyword(expression) =
for everything just because we can. What does a conditional virtual even me=
an? I haven&#39;t seen the talk yet, but a conditional const is also meanin=
gless IMO.=C2=A0 I don&#39;t want my member functions to look like this:<di=
v><br></div><div>virtual(false) void foo() noexcept(true) const(true) volat=
ile(false);</div><div><br></div><div>It&#39;s a bit of an extreme example, =
but I don&#39;t see the need to be soooo explicit about *everything*. I don=
&#39;t really like explicit(expr), but it solves a specific use case. That =
it also allows explicit(false) to be more explicit is a minor point. I won&=
#39;t recommend doing that, but if you want to, I won&#39;t stop you. But t=
his can&#39;t be the primary motivation to add such a conditional IMO.=C2=
=A0</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Tue, Sep =
25, 2018 at 6:48 PM Andrew Giese &lt;<a href=3D"mailto:gieseanw@gmail.com">=
gieseanw@gmail.com</a>&gt; wrote:<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"auto">I didn&#39;t realize when I&#39;d sent this that we are al=
ready getting explicit (expression) in C++20.<div dir=3D"auto"><br></div><d=
iv dir=3D"auto">I think this serves to provide more momentum to upgrade our=
 other keywords, even &quot;virtual&quot;.</div><div dir=3D"auto"><br></div=
><div dir=3D"auto"><br></div></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr">On Tue, Sep 25, 2018, 9:31 AM Andrew Giese &lt;<a href=3D"mailto:g=
ieseanw@gmail.com" target=3D"_blank">gieseanw@gmail.com</a>&gt; wrote:<br><=
/div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"auto">Sitting at CppCon lis=
tening to Kate Gregory&#39;s (wonderful) talk &quot;What do we mean when we=
 say nothing at all&quot; reminds me of this.<div dir=3D"auto"><br></div><d=
iv dir=3D"auto">A big motivating example for &quot;bool&#39;ing&quot; keywo=
rds like mutable and &quot;explicit&quot; is understandability.</div><div d=
ir=3D"auto"><br></div><div dir=3D"auto">We can make it very clear we intend=
ed to have an implicit constructor or a non-mutable member variable if we h=
ad these.=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">She goes=
 as far as to say even const(false) is useful on member functions, and it&#=
39;s pretty compelling.</div><div dir=3D"auto"><br></div><div dir=3D"auto">=
Regards,</div><div dir=3D"auto">Andy</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" 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/CAO8_tC5ox0_RPrT3xBUbcCW%2BZE908voNPa=
1bHh07JzByDfmPiw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAO8_tC5ox0_RPrT3xBUbcCW%2BZE908voNPa1bHh07JzByDfmPiw%40mail.gmail.c=
om</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/CALmDwq2k6fgN7qv-4wBZOq_aqAbq9Jd7A10u=
dkqocxacxdNM0g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALmDwq2k6fgN7qv-=
4wBZOq_aqAbq9Jd7A10udkqocxacxdNM0g%40mail.gmail.com</a>.<br />

--0000000000008892cf0576b6141a--

.


Author: Andrew Giese <gieseanw@gmail.com>
Date: Tue, 25 Sep 2018 16:48:43 -0700
Raw View
--000000000000bb4d320576babf57
Content-Type: text/plain; charset="UTF-8"

You forgot override (true) final (false) :-)


I agree in principle; being more explicit cannot be the *only* reason. (Nor
can "because we can").

However, I think that being more explicit is an *additional* reason. At
least, in my specific desire for "mutable (expression)".

We have a number of derived class types in our codebase where they'd like
to extend the behavior of the base for lazily loading the stored data.
There are solutions around this in the language, but they increase noise
(thereby reducing readability and understandability), and arguably increase
compile times (thanks to additional template instantiation).

--
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/CAO8_tC5QK2OKeoFNa%2BqDKhEODkOqUgzovVe_6kJBTTnDqcVGgQ%40mail.gmail.com.

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

<div dir=3D"auto">You forgot override (true) final (false) :-)<div dir=3D"a=
uto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto">I agree in pri=
nciple; being more explicit cannot be the *only* reason. (Nor can &quot;bec=
ause we can&quot;).=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto=
">However, I think that being more explicit is an *additional* reason. At l=
east, in my specific desire for &quot;mutable (expression)&quot;.=C2=A0</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto">We have a number of derived=
 class types in our codebase where they&#39;d like to extend the behavior o=
f the base for lazily loading the stored data. There are solutions around t=
his in the language, but they increase noise (thereby reducing readability =
and understandability), and arguably increase compile times (thanks to addi=
tional template instantiation).</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/CAO8_tC5QK2OKeoFNa%2BqDKhEODkOqUgzovV=
e_6kJBTTnDqcVGgQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAO8_tC5QK2OKeo=
FNa%2BqDKhEODkOqUgzovVe_6kJBTTnDqcVGgQ%40mail.gmail.com</a>.<br />

--000000000000bb4d320576babf57--

.