Saturday, August 22, 2020

Digest for comp.lang.c++@googlegroups.com - 15 updates in 4 topics

James Kuyper <jameskuyper@alumni.caltech.edu>: Aug 22 09:01AM -0400

>>>> such an issue.
 
>>> Thanks Jorgen. Problem partially solved, compile time at least. I thought any
>>> user copy assignment operator would disable the default one as the constructor
 
"If the class definition does not explicitly declare a copy assignment
operator, one is declared implicitly." 15.8.2p2.
You declared an assignment operator, but you did not declare a copy
assignment operator.
 
> test2.cpp:16:35: warning: implicitly-declared 'DxInt<unsigned int>& DxInt<unsigned int>::operator=(const DxInt<unsigned int>&)' is deprecated [-Wdeprecated-copy]
> 16 | DxInt(const DxInt& s) { *this=s; };
> | ^
 
So the code you're talking about is not the code that you quoted from
the message you responded to. Instead, it's code from a different branch
of this discussion. You should have posted this comment on that branch,
not here.
 
This warning is occurring inside the copy constructor, because you don't
have a user-declared copy assignment operator. -Wextra turns on
-Wdeprecated-copy, which will warn you if you provide a copy constructor
and rely upon an implicitly declared copy assignment operator, or if you
provide a user-declared copy assignment operator and rely upon an
implicitly-declared copy constructor. Note that this is only a warning.
You don't have to turn it on (I personally recommend against using
-Wextra), and you don't have to pay attention to it if you don't want to.
 
The warning is correct - the standard does deprecate such code:
 
"If the class definition does not explicitly declare a copy constructor,
a non-explicit one is declared implicitly.
If the class definition declares a move constructor or move assignment
operator, the implicitly declared copy constructor is defined as
deleted; otherwise, it is defined as defaulted (11.4). The latter case
is deprecated if the class has a user-declared copy assignment operator
..." (15.8.1p6)
 
"If the class definition does not explicitly declare a copy assignment
operator, one is declared implicitly.
If the class definition declares a move constructor or move assignment
operator, the implicitly declared copy assignment operator is defined as
deleted; otherwise, it is defined as defaulted (11.4). The latter case
is deprecated if the class has a user-declared copy constructor ..."
(15.8.2p2).
 
The idea behind those deprecations is that it is generally not
reasonable to use the implicitly-defined version of one of those
functions, while explicitly defining the other. Either the
implicitly-defined version of both functions should be acceptable, or
explicit definitions for both are needed.
 
Your copy constructor is implemented by calling the copy-assignment
operator which you have not explicitly declared, so one is implicitly
declared and implicitly defined, which is what triggers the warning.
That's unnecessary - an implicitly declared copy constructor would do
exactly the right thing with your class.
 
Note: reinterpret_cast<> is dangerous, and should be avoided if
possible. It's quite easy to avoid it in this case by using a union, and
the code gets significantly simpler if you use that approach.
wyniijj@gmail.com: Aug 22 12:34PM -0700

James Kuyper於 2020年8月22日星期六 UTC+8下午9時01分28秒寫道:
 
> Note: reinterpret_cast<> is dangerous, and should be avoided if
> possible. It's quite easy to avoid it in this case by using a union, and
> the code gets significantly simpler if you use that approach.
 
I'd like to share your idea avoiding reinterpret_cast<> in the type
conversion operator and about implement of DxInt<T> (T is unsigned type)
James Kuyper <jameskuyper@alumni.caltech.edu>: Aug 22 04:56PM -0400

> James Kuyper於 2020年8月22日星期六 UTC+8下午9時01分28秒寫道:
...
>> the code gets significantly simpler if you use that approach.
 
> I'd like to share your idea avoiding reinterpret_cast<> in the type
> conversion operator and about implement of DxInt<T> (T is unsigned type)
 
I'm going to assume that "I'd like to share your idea ..." was actually
intended to be "I'd like you to share your idea ...". If so, here's your
class re-written along those lines:
 
#include <cstdint>
template <typename T> class DxInt;
 
typedef uint32_t T;
typedef uint64_t TT;
 
template <> class DxInt<T> {
union {
TT ui64;
T arr[2];
} u;
 
public:
DxInt() { u.ui64 = 0; };
DxInt(const DxInt& s) { u.ui64 = s.u.ui64; };
DxInt(TT v) { u.ui64 = v; };
 
inline const T& lo() const { return u.arr[0]; };
inline T& lo() { return u.arr[0]; };
inline const T& hi() const { return u.arr[1]; };
inline T& hi() { return u.arr[1]; };
 
inline DxInt& operator=(TT rhs) {
u.ui64 = rhs;
return *this;
};
 
operator TT& () { return u.ui64; };
operator const TT& () const { return u.ui64; };
};
boltar@nowhere.co.uk: Aug 22 08:18AM

On Fri, 21 Aug 2020 19:53:59 -0300
>problem was solved using std::string and some library algorithms). But
>yes, any regex library (especially the one from standard library) would
>have been better.
 
Your problem is your compiling to web assembly. Serious programs do not
run in a browser.
Bonita Montero <Bonita.Montero@gmail.com>: Aug 22 10:42AM +0200

> What you do not understand is that it DOES matter. Code size slows down
> the program because it fills the code cache with irrelevant stuff!
 
That's actually not relevant because i-caches are large enough to hold
the hot-spots.
"Öö Tiib" <ootiib@hot.ee>: Aug 22 07:19AM -0700

> >have been better.
 
> Your problem is your compiling to web assembly. Serious programs do not
> run in a browser.
 
You mean PC computer games? Big part of tools that people use to
do their everyday work have front end in web browser.
boltar@nowhere.co.uk: Aug 22 06:06PM

On Sat, 22 Aug 2020 07:19:56 -0700 (PDT)
>> Your problem is your compiling to web assembly. Serious programs do not
>> run in a browser.
 
>You mean PC computer games? Big part of tools that people use to
 
Yes, computer games that might have been state of the art 15 years ago
can now run in a browser. BFD.
 
>do their everyday work have front end in web browser.=20
 
Front end yes, but you're writing a blockchain processor it would seem and
running that in a browser is a fuckwitted idea.
jacobnavia <jacob@jacob.remcomp.fr>: Aug 22 09:43PM +0200

Le 22/08/2020 à 10:42, Bonita Montero a écrit :
>> down the program because it fills the code cache with irrelevant stuff!
 
> That's actually not relevant because i-caches are large enough to hold
> the hot-spots.
 
Sure, but in bloated code the "hot" spots are luke warm, since they are
diluted iin all kind of rubbish the processor has to do. In general,
bulky code does thing that are irrelevant to the task at hand, what
makes it quite slow.
 
Bulky code is diluted. The algorithm is a few percentage points of all
the work the machine has to do.
 
To be clear, suppose that you write a function:
 
int add(int a,int b) { return a+b;}
 
Here, we have the overhead of establishing a function frame, and
destroying it, of passing the arguments and retrieving the result, what
is far bigger than the single instruction needed to actually do the
addition!
 
Of course, you will argue, that function will be inlined, but that is an
EXAMPLE of how things go wrong. In a convoluted regexp library most of
the time will be spent doing other things than matching
rick.c.hodgin@gmail.com: Aug 21 06:50PM -0700

On Thursday, August 20, 2020 at 6:57:47 PM UTC-4, Mr Flibble wrote:
> "Snakes didn't evolve, instead talking snakes with legs changed into snakes."
> - Rick C. Hodgin
 
You misquote me, and have a substantial misunderstanding of the process.
The "talking snakes with legs" weren't snakes. They were called the
"serpent" in scripture, and referred to a creature that was not like
what we see with snakes today. They also didn't "change into snakes,"
but rather God ripped out their ability to have legs, and changed
their form to such an extent that they are little more than tubes
now. If we ever get to the point where we understand DNA sufficiently,
it will reveal exactly how God did it, and how the creature would ap-
pear if those changes were removed.
 
In addition, Fry has it wrong. God didn't create a world with bone
cancer. He created a perfect world. Man disobeying God let the
enemy of God (Satan) enter in to this world, and become the lower-
case-g god of it. He is the reason for bone cancer and every form
of evil that exists. Jesus is the cure, as He takes all of that
away and sets us back on the path to God's perfect plans before sin
entered in and destroyed everything.
 
If you care about truth this will mean something to you.
 
-----
Remember:
 
God is not mocked. Even if we don't seem to be receiving punishment
for our disobedience and sin, that punishment is not escaping us. It
is recorded, and the full measure of God's wrath will be poured out
for everyone who does not repent and ask Jesus to forgive their sin.
 
You proceed from false positions, Leigh. You assert wrong premises,
and then proceed to build an entire belief system around them. I
point this out to you so you can course-correct while there's still
time.
 
There's more to life and living than you accept. Be willing to hear
the truth, even if it takes you in a new direction you never would've
thought possible.
 
--
Rick C. Hodgin
Learn something: https://tinyurl.com/proto-earths
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Aug 21 08:07PM -0700

On 8/20/2020 3:57 PM, Mr Flibble wrote:
> Dark theme? All the dagnabbiting colour themes!
> https://www.youtube.com/watch?v=eIpcqNcoK60&feature=youtu.be
 
Nice work! :^)
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 22 06:13AM +0100


> There's more to life and living than you accept. Be willing to hear
> the truth, even if it takes you in a new direction you never would've
> thought possible.
 
Oh really spammer? Then consider this:
 
Jesus: "Do you see that man over there Timmy?"
Timmy: "Yes Jesus, I see him."
Jesus: "That's the man that murdered you and your family while you were sleeping. He repented and asked for forgiveness. Now he's here in paradise, with us. Go say hello."
 
Timmy is four years old.
 
You, your fucktarded religion and your fucktarded, evil fictional god can all fuck off, spammer.
 
/Flibble.
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 22 06:48AM +0100

On 22/08/2020 04:07, Chris M. Thomasson wrote:
> On 8/20/2020 3:57 PM, Mr Flibble wrote:
>> Dark theme? All the dagnabbiting colour themes! https://www.youtube.com/watch?v=eIpcqNcoK60&feature=youtu.be
 
> Nice work! :^)
 
Thanks. I've updated the video: new URL: https://youtu.be/GBdnFjDQ8tg
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
rick.c.hodgin@gmail.com: Aug 21 10:54PM -0700

On Saturday, August 22, 2020 at 1:13:28 AM UTC-4, Mr Flibble wrote:
> Timmy: "Yes Jesus, I see him."
> Jesus: "That's the man that murdered you and your family while you were sleeping. He repented and asked for forgiveness. Now he's here in paradise, with us. Go say hello."
 
> Timmy is four years old.
 
How long is eternity?
How long is 70 or 80 or 120 years on this planet compared to eternity?
 
Timmy is in Heaven with God for eternity.
The repentant sinner is in Heaven with God for eternity.
 
The sin which caused the man to murder, Jesus destroyed it at the
cross. The enemy who tempts people to sin, Jesus destroyed him at
the cross. The temporary temporal nature of this world means no
tragedies will endure. And God made salvation free so nobody is
excluded save those who purposefully, consciously exclude them-
selves.
 
You look at this temporary world as though it's everything. It's
not. Nothing here will endure.
 
What does endure is everything tied to Jesus and forgiveness in
love.
 
No more death.
No more pain.
The former things of this world pass away.
God reveals to us highlights of the new things to come.
 
Your focus is on the wrong place, and the wrong things. You focus
where the enemy lives. Focus on where God lives and overcome that
enemy by the grace of the lamb of God, Jesus, who is Christ.
 
He has victory over death, Hell, and the grave. For Timmy. For
the murderer. And for you.
 
--
Rick C. Hodgin
 
Learn something: http://tinyurl.com/proto-earths
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 22 06:58AM +0100

> enemy by the grace of the lamb of God, Jesus, who is Christ.
 
> He has victory over death, Hell, and the grave. For Timmy. For
> the murderer. And for you.
 
Or alternatively everything you just wrote is meaningless drivel, spammer.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
David Brown <david.brown@hesbynett.no>: Aug 22 02:45AM +0200

On 21/08/2020 20:41, Keith Thompson wrote:
> Saturday,
> Sunday, lastday=Sunday
> };
 
That might help in some cases. But again, "firstday" and "lastday" are
not part of the logical list of days. When I have a "real" enum (as
distinct from just using enum as a convenient way of making some
constants), I want it to contain only the elements that are logically
part of that group.
 
So I'd rather write:
 
enum days {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday,
};
constexpr days firstday = Monday;
constexpr days lastday = Sunday;
 
That works for me here. It's one more thing you can get wrong if you
add more to the enum type later (unlikely for days, but plausible for
other enums).
 
And it would be /vastly/ nicer if I could just write:
 
constexpr days firstday = first(days);
constexpr days lastday = last(days);
 
or some similar general syntax.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: