Wednesday, December 26, 2018

Digest for comp.lang.c++@googlegroups.com - 20 updates in 6 topics

woodbrian77@gmail.com: Dec 26 12:56PM -0800

Shalom Here's my 2019 wish list:
 
1. Clang and Gcc keep supporting #import.
 
2. Microsoft makes it so you don't have to
call WSAStartup(). By the grace of G-d, I've
made this:
https://github.com/Ebenezer-group/onwards/blob/master/src/cmw/tiers/genz.cc
 
into a nice little program. One of few warts
remaining in it is the call to "winStart" that
wraps the call to WSAStartup(). On FreeBSD and
Linux, winStart() is a no-op. 2019 would be a
good time to clean that up!
 
3. A compiler (Gcc?) with support for static exceptions.
I'll be able to start taking advantage of static
exceptions in the closed-source part of my work.
 
4. Std::string_view is back-ported to 2011 C++
and std::span is back-ported to 2017 C++.
 
These things would go a long way to making 2019
even better than 2018.
 
 
Brian
Ebenezer Enterprises - Enjoying programming again.
https://github.com/Ebenezer-group/onwards
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 26 09:55PM

> wraps the call to WSAStartup(). On FreeBSD and
> Linux, winStart() is a no-op. 2019 would be a
> good time to clean that up!
 
Just use boost.asio.
 
[snip]
 
/Flibble
 
--
"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," Bryne 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."
ViralTaco <kiiwy112@gmail.com>: Dec 26 12:33PM -0800

On Wednesday, December 12, 2018 at 9:49:04 PM UTC+1, JiiPee wrote:
> when resizing to zero. So I guess its undefined what happens to capacity
> after deleting elements?
 
> Or any alternative good way implementing this?
 
std::array can be created with a fixed size.
If you don't want any extra memory allocation once you've initialised the vector (ie: it stays in it's bounds all the time)
you can use the reserve() function from the std::vector library on your vector. Ie:
`std::vector<int> foo; foo.reserve(128);` But be careful not to go above that reserve.
Here is why: https://en.cppreference.com/w/cpp/container/vector/reserve
jameskuyper@alumni.caltech.edu: Dec 26 01:35PM -0800

On Wednesday, December 26, 2018 at 3:34:01 PM UTC-5, ViralTaco wrote:
> > when resizing to zero. So I guess its undefined what happens to capacity
> > after deleting elements?
 
> > Or any alternative good way implementing this?
 
You should generally review previous answers before posting a new one of
your own. Both of the answers you given have already been mentioned
several times apiece.
 
> std::array can be created with a fixed size.
 
He's already indicated a desire to perform push_back(), remove(),
insert(), and clear(), operations that are not supported for
std::array<>.

> If you don't want any extra memory allocation once you've initialised the vector (ie: it stays in it's bounds all the time)
> you can use the reserve() function from the std::vector library on your vector.
 
He seems doubtful about whether "no reallocation" is absolutely
guaranteed in that case. There's some basis for his concern: that
guarantee is only provided for inserts, not deletions. The requirements
for the validity of interators, pointers, and references to the elements
of a std::vector<> effectively prohibit reallocation during most
deletions, but allow it if one of the elements being deleted is the
first element of the array. The only protection he has against such a
reallocation is that there's no apparent reason for one to occur in that
situation.
ViralTaco <kiiwy112@gmail.com>: Dec 26 12:27PM -0800

On Thursday, December 20, 2018 at 3:31:44 AM UTC+1, Rick C. Hodgin wrote:
> of the hierarchy it is then unique.
 
> --
> Rick C. Hodgin
 
TL;DR: I think this is way too confusing.
 
Remember we have `using` and smart pointers.
Also typically this when you use the dreaded getters and setters Java devs love so much.
Also also structs, like classes can have constructors.
For example I use one in my latest project: https://git.io/fhT9f
 
Not that my code should be used as an example. I'm just trying hard but I'm a noob.
ViralTaco <kiiwy112@gmail.com>: Dec 26 12:19PM -0800

On Sunday, December 23, 2018 at 7:05:14 PM UTC+1, Paul wrote:
 
> Any suggestions? This forum has always been fantastic in response to my queries.
 
> Many thanks,
 
> Paul
 
Alright the problem here is that `f()` might be undefined.
Here is how I would do it:
```(header.hpp)
 
#pragma once

namespace { // Global namespace in this case.
void f();
}
```
```(header.cpp)
#pragma once
#include "header.hpp"
#include <iostream>
 
void f() {
std::cout << "fine";
}
```
```(main.cpp)
#include "header.cpp"
 
int main() {
f();
} // This returns 0
```
 
 
Alternatively just one header:
```(header.hpp)
#pragma once
#include <iostream>
 
namespace { // Global namespace
void f() {
std::cout << "fine";
}
}
```
```(main.cpp)
#include "header.hpp"

int main {
f();
}
```
 
Hope that helps.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Dec 26 10:29AM -0800

On Wednesday, December 26, 2018 at 1:11:31 PM UTC-5, Mr Flibble wrote:
> supposed gay friends think? And if you don't agree with Jesus that
> homosexuals should be put to death then that shows an inconsistency in
> your faith which is revealed to be a house built on sand.
 
This is why I don't answer your question. You already have the
courses and paths for your yes/no answers mapped out. These
were prepared for you literally by Satan, or one of his demon
imps, so that no matter what I would reply in direct answer to
your query, you have a way to stay where you are and not advance.
 
The enemy wants you wallowing in ignorance, Leigh. This is what
I'm trying to teach you.
 
The truth is far more complex, more interesting, and it has the
added benefit of being the truth.
 
If you want to know the truth ... you can. It is different than
you think, more amazing, more complete, given to understanding
and full knowledge. It's not a blind "do pickles have the same
skin as toads" type question simply because they look that way
at a quick cursory glance without any real investigation. You
have to dig deeper, Leigh. You can't go by what you think you
know, because there's an active enemy at work against you who
owns your thinking, and until you seek the truth he'll deceive
you continually. But when you seek the truth, God steps into
your life and guides you to that which you cannot find on your
own. He defeats Satan for you, and opens up your understanding.
 
It's time to grow up, Leigh. It's time to shun childish hard-
headedness and ignorance, and mature into someone who is truly
looking at things as they are, who is truly truth-seeking.
 
--
Rick C. Hodgin
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 26 06:33PM

On 26/12/2018 18:29, Rick C. Hodgin wrote:
 
> It's time to grow up, Leigh. It's time to shun childish hard-
> headedness and ignorance, and mature into someone who is truly
> looking at things as they are, who is truly truth-seeking.
 
Jesus believed the Old Testament was the commandment of God (Matthew 15:3)
ergo Jesus believed that homosexuals should be put to death (Leviticus 20:13).
 
Do you agree with Jesus that homosexuals should be put to death or not? If
Jesus is wrong about putting homosexuals to death then what else is Jesus
wrong about? I thought gods were supposed to be infallible.
 
/Flibble
 
--
"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," Bryne 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" <rick.c.hodgin@gmail.com>: Dec 26 10:38AM -0800

On Wednesday, December 26, 2018 at 1:34:03 PM UTC-5, Mr Flibble wrote:
 
> Do you agree with Jesus that homosexuals should be put to death or not? If
> Jesus is wrong about putting homosexuals to death then what else is Jesus
> wrong about? I thought gods were supposed to be infallible.
 
God will answer your question... either in this world (I pray),
or in the one to come.
 
--
Rick C. Hodgin
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 26 06:50PM

On 26/12/2018 18:38, Rick C. Hodgin wrote:
>> wrong about? I thought gods were supposed to be infallible.
 
> God will answer your question... either in this world (I pray),
> or in the one to come.
 
That is not an acceptable response as it presupposes an a priori agreement
that your god exists. I know for a fact that your god doesn't exist.
 
Disregard the e-mail I sent to you in error.
 
/Flibble
 
--
"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," Bryne 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" <rick.c.hodgin@gmail.com>: Dec 26 01:59PM -0500

On 12/26/2018 1:50 PM, Mr Flibble wrote:
>> or in the one to come.
 
> That is not an acceptable response as it presupposes an a priori agreement
> that your god exists.  I know for a fact that your god doesn't exist.
 
The truth is as the truth is, Leigh.
 
I used to believe as you do. Something I could never have accepted
before it happened to me ... happened to me. Now I sit on this side
of that transformation teaching you that it exists.
 
You'll never be able to believe it or receive it ... until you set
your sights on the truth and God transforms you from the inside out.
 
-----
Happy living, Leigh. I wish you nothing but success in your dreams.
And I further wish salvation for your soul.
 
--
Rick C. Hodgin
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 26 07:25PM

On 26/12/2018 18:59, Rick C. Hodgin wrote:
 
> -----
> Happy living, Leigh.  I wish you nothing but success in your dreams.
> And I further wish salvation for your soul.
 
You think you are teaching me? You really are a pompous, sanctimonious,
self righteous cockwomble. You remind me of that Christian missionary
John Chau who was killed by an isolated Indian tribe recently. He paid the
ultimate sacrifice for not being able to take a hint. Beware the bows and
arrows mate as not everyone wants to be "taught" your flavour of bullshit.
 
No need to reply (if you do I will add you to my spam filter).
 
/Flibble
 
--
"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," Bryne 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" <rick.c.hodgin@gmail.com>: Dec 26 02:31PM -0500

On 12/26/2018 2:25 PM, Mr Flibble wrote:
> You think you are teaching me?
 
Trying to teach you. And not to listen to me, but to go to the source
and read and learn and seek to understand.
 
All I ask is that you set your heart on knowing the truth truly, without
any deception or falseness. Resolve to do this in your heart, and then
proceed with looking at Jesus, the Bible, and other such things.
 
It's the true seeking the truth that makes the difference, and allows
the change to come.
 
--
Rick C. Hodgin
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 26 07:34PM

On 26/12/2018 19:31, Rick C. Hodgin wrote:
> proceed with looking at Jesus, the Bible, and other such things.
 
> It's the true seeking the truth that makes the difference, and allows
> the change to come.
 
*plonk*
 
 
--
"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," Bryne 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" <rick.c.hodgin@gmail.com>: Dec 26 02:54PM -0500

On 12/26/2018 2:34 PM, Mr Flibble wrote:
 
>> It's the true seeking the truth that makes the difference, and allows
>> the change to come.
 
> *plonk*
 
May the C++ channel now enjoy far greater peace.
 
--
Rick C. Hodgin
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Dec 26 11:58AM -0800

On 12/24/2018 4:54 PM, Rick C. Hodgin wrote:
> Is there an equivalent of a multi-channel rand() function that enables
> multiple simultaneous separate pseudo-random number generators by some-
> thing like a handle or instance of each in the standard library?
 
Fwiw, take a deep look at:
 
https://en.wikipedia.org/wiki/Linear_congruential_generator
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Dec 26 12:00PM -0800

On 12/26/2018 11:54 AM, Rick C. Hodgin wrote:
>>> the change to come.
 
>> *plonk*
 
> May the C++ channel now enjoy far greater peace.
 
Jesus told me to tell you about:
 
https://en.wikipedia.org/wiki/Permuted_congruential_generator
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Dec 26 03:13PM -0500

On 12/26/2018 3:00 PM, Chris M. Thomasson wrote:
> Jesus told me to tell you about:
> https://en.wikipedia.org/wiki/Permuted_congruential_generator
 
Then I'll thank Jesus for that. And you for being obedient. :-)
 
--
Rick C. Hodgin
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 26 04:31AM +0100

On 26.12.2018 03:47, AL.GleeD NICE wrote:
> ucioption.cpp:42:35: warning: unused parameter 'o' [-Wunused-parameter]
> void on_large_pages(const Option& o) { TT.resize(0); } // warning is ok, will be removed
 
You get the warning because `o` is not used.
 
The traditional solution has been to either drop the argument name,
 
void on_large_pages( const Option& )
 
... or to pseudo-use it in an expression casted to `void`:
 
void on_large_pages( const Option& o )
{
(void) o;
// more code
}
 
To be sure that that doesn't dis-inform a reader after some maintainer
has introduced some actual use of `o`, you can inhibit further use by
shadowing the name, e.g.
 
void on_large_pages( const Option& o )
{
(void) o; struct o;
// more code, that just can't access `o`
}
 
There are two main problems with that, though: (A) some programmers may
not understand what the heck that's about, even if you encapsulate it in
a macro with self-describing name, and (B) the compiler's diagnostics
when some maintainer inadvertently uses `o` with removing that line, and
be pretty ungrokable and misleading.
 
---
 
C++17 introduced an attribute for this,
 
void on_large_pages( [[maybe_unused]] const Option& o )
 
And I think it was from C++14 there is something like dummy assign in
the standard library, but I'm unable to find it now. I just noted it
when I saw it, once, that hey that's cool, I'll start using that. And
then I forgot all about it.
 
 
Cheers!,
 
- Alf
ViralTaco <kiiwy112@gmail.com>: Dec 26 12:07PM -0800

On Wednesday, December 26, 2018 at 3:47:52 AM UTC+1, AL.GleeD NICE wrote:
> void on_large_pages(const Option& o) { TT.resize(0); } // warning is ok, will be removed
 
> --------
> I do not know the direct cause. And the associated curve
 
Hey,
Like Alf mentioned I suggest using the attribute `[[maybe_unused]]`
Note that `[[unused]]` may also exist but isn't standard in C++17 as far as I know. (And won't work on the latest version of msvc I tried)…
ie:
void foo([[maybe_unused]] const Option& o) /* const noexcept(true) */ {
// function body;
}
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: