Sunday, July 12, 2020

Digest for comp.lang.c++@googlegroups.com - 16 updates in 8 topics

Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Jul 12 05:35PM -0400

Daniel P wrote:
 
> It compiles with earlier versions of vs.
 
> Thanks,
> Daniel
 
Daniel, I think it should compiler. To fix, I would try to replace
std::string with explicit specialization just in case Microsoft messed
it up with an additional template parameter or such (I do not have
VS2019 handy so cannot check myself). HTH. -Pavel
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jul 12 02:20PM -0700

Some context: read all
 
https://groups.google.com/forum/#!original/comp.arch/k1Qr520dcDk/4vl_jiVRBQAJ
 
within the following thread:
 
https://groups.google.com/d/topic/comp.arch/k1Qr520dcDk/discussion
 
 
I need to find an older post I made that has a test for this using
threads. Remember coding it up in Relacy. Anyway, here is a _highly_
_crude_ little implementation. It should compile right up.
_____________________________
#include <iostream>
#include <atomic>
#include <thread>
 
 
struct user_payload
{
int m_foo;
 
user_payload(int foo) : m_foo(foo) {}
 
user_payload(const user_payload& rhs) : m_foo(rhs.m_foo) {}
 
void process()
{
std::cout << this << "->user_payload::process() " << m_foo << "\n";
std::this_thread::yield();
}
};
 
 
namespace ct
{
 
static struct node* node_wait_next(node*);
 
struct node
{
std::atomic<node*> m_next;
user_payload m_payload;
 
 
node(user_payload const& payload) : m_next(nullptr),
m_payload(payload)
{
std::cout << this << "->node::node()" << "\n";
}
 
~node()
{
std::cout << this << "->node::~node()" << "\n";
}
 
 
static void process(node* head)
{
node* cur = head;
 
while (cur)
{
// user processing first!
cur->m_payload.process();
 
// now, we see if we need to wait...
node* next = node_wait_next(cur);
 
delete cur;
 
cur = next;
}
}
};
 
 
static node g_special_wait_node(0);
 
 
#define CT_SPECIAL (&ct::g_special_wait_node)
 
 
node* node_wait_next(node* n)
{
node* next = nullptr;
while ((next = n->m_next.load(std::memory_order_relaxed))
== CT_SPECIAL) std::this_thread::yield();
return next;
}
 
struct stack
{
std::atomic<node*> m_head;
 
stack() : m_head(nullptr) {}
 
void push(node* n)
{
n->m_next.store(CT_SPECIAL, std::memory_order_relaxed);
node* prev = m_head.exchange(n, std::memory_order_release);
n->m_next.store(prev, std::memory_order_relaxed);
}
 
 
node* flush()
{
return m_head.exchange(nullptr, std::memory_order_acquire);
}
};
}
 
 
int main()
{
std::cout << "\nCT_SPECIAL = " << CT_SPECIAL << "\n\n";
 
{
ct::stack alist;
 
alist.push(new ct::node(789));
alist.push(new ct::node(456));
alist.push(new ct::node(123));
 
ct::node* work = alist.flush();
 
ct::node::process(work);
 
 
alist.push(new ct::node(321));
alist.push(new ct::node(654));
alist.push(new ct::node(987));
 
work = alist.flush();
 
ct::node::process(work);
}
 
return 0;
}
_____________________________
 
 
Can you get it to work? Fwiw, I get the following output:
_____________________________
0x6021c0->node::node()
 
CT_SPECIAL = 0x6021c0
 
0x17a0280->node::node()
0x17a02a0->node::node()
0x17a02c0->node::node()
0x17a02c8->user_payload::process() 123
0x17a02c0->node::~node()
0x17a02a8->user_payload::process() 456
0x17a02a0->node::~node()
0x17a0288->user_payload::process() 789
0x17a0280->node::~node()
0x17a0280->node::node()
0x17a02a0->node::node()
0x17a02c0->node::node()
0x17a02c8->user_payload::process() 987
0x17a02c0->node::~node()
0x17a02a8->user_payload::process() 654
0x17a02a0->node::~node()
0x17a0288->user_payload::process() 321
0x17a0280->node::~node()
0x6021c0->node::~node()
_____________________________
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Jul 12 04:52PM -0400

> return std::max(rand(), bar::foo);
> }
 
> It requires C++17, which I have but some of the people I am working with can not have, so I am not sure if I'm going to apply it right now. But that's my problems, not of C++ standard.
 
They should still be able to initialize in class definition as long as
compiler allows; to avoid linker error just define the variable
somewhere else (without initialization, if they initialize in class
definition). I.e.
 
/* this goes to header file i.e. can be included in multiple compilation
units */
struct bar {
static const int foo = 42;
};
 
const int bar::foo; // this should only be in one compilation unit
 
HTH
-Pavel
already5chosen@yahoo.com: Jul 12 02:08PM -0700

On Sunday, July 12, 2020 at 11:52:25 PM UTC+3, Pavel wrote:
 
> const int bar::foo; // this should only be in one compilation unit
 
> HTH
> -Pavel
 
I know.
This method does not satisfy my above mentioned requirement "don't come in conflict with basic DRY principle".
woodbrian77@gmail.com: Jul 12 12:52PM -0700

Shalom
 
The following is from one of the replies in this thread:
 
https://www.reddit.com/r/cpp/comments/hpw6az/memory_readwrite_library/
 
if (auto code = read_process_mem(...); code == mem_hengst::succes)//c++20 if init
{ //succes } else { //failure }
 
 
My question is regarding the comment:
//c++20 if init
 
. I thought that was part of 2017 C++. Was
something tweaked in 2020 C++ in that area or
is the comment wrong? Thanks in advance.
 
 
Brian
Ebenezer Enterprises - Enjoying programming again.
https://github.com/Ebenezer-group/onwards
"Öö Tiib" <ootiib@hot.ee>: Jul 12 02:07PM -0700


> . I thought that was part of 2017 C++. Was
> something tweaked in 2020 C++ in that area or
> is the comment wrong? Thanks in advance.
 
Yes you are correct that the pointless optional init statement
was added by C++17 into if but also "succes" is not a word
and // comment goes until end of line. So the whole thing there
screams that it is some quick pseudo-code garbage.
aminer68@gmail.com: Jul 12 10:34AM -0700

Hello,
 
 
Don't bother too much, because i am posting just very few posts here.
 
 
Thank you,
Amine Moulay Ramdane.
Scott Newman <scott69@gmail.com>: Jul 12 08:07PM +0200

> Hello,
> Don't bother too much, because i am posting just very few posts here.
 
Your posts are always welcome.
You're a genius.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 12 07:21PM +0100

On 12/07/2020 19:07, Scott Newman wrote:
>> Don't bother too much, because i am posting just very few posts here.
 
> Your posts are always welcome.
> You're a genius.
 
Fuck. Off.
 
/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."
gazelle@shell.xmission.com (Kenny McCormack): Jul 12 08:02PM

In article <refjg9$kfg$1@dont-email.me>,
>> Don't bother too much, because i am posting just very few posts here.
 
>Your posts are always welcome.
>You're a genius.
 
Kudos to you, Scott. Correct spelling of your/you're/yore - twice!
 
Well done. Most folks fail on this at least once.
 
How are you on there/their/they're ?
 
--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/LadyChatterley
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 12 03:57PM +0100

Hi!
 
neoGFX now includes a generic and extensible settings system with a standard settings dialog for which custom setting widgets can be created for custom setting types.
 
register_category("environment"_s, "Environment"_t);
register_group("environment.general"_s, "General"_t);
register_group("environment.accounts_and_licensing"_s, "Accounts and Licensing"_t);
register_group("environment.documents"_s, "Documents"_t);
register_group("environment.fonts_and_colors"_s, "Fonts and Colors"_t);
register_group("environment.workspace"_s, "Workspace"_t);
register_group("environment.keyboard"_s, "Keyboard"_t);
register_group("environment.tabs_and_windows"_s, "Tabs and Windows"_t);
register_category("text_editor"_s, "Text Editor"_t);
register_group("text_editor.general"_s, "General"_t);
register_group("text_editor.advanced"_s, "Advanced"_t);
register_group("text_editor.tabs_and_indentation"_s, "Tabs and Indentation"_t);
register_group("text_editor.syntax_highlighting"_s, "Syntax Highlighting"_t);
register_category("node_editor"_s, "Node Editor"_t);
register_category("scripting"_s, "Scripting"_t);
register_category("debugging"_s, "Debugging"_t);
register_category("projects"_s, "Projects"_t);
register_category("source_control"_s, "Source Control"_t);
register_category("team"_s, "Team"_t);
register_category("plugins"_s, "Plugins"_t);
 
register_setting<color>("environment.general.theme"_s, service<i_app>().current_style().palette().color(color_role::Theme), "Theme color: %?%"_t);
register_setting<workspace_grid>("environment.workspace.grid_type"_s, workspace_grid::Lines, "Grid type : %?% Grid size: %environment.workspace.grid_size:?%"_t);
register_setting<uint32_t>("environment.workspace.grid_size"_s, 20, ng::setting_constraints<uint32_t>{ false, false, 2, 64, 2 });
register_setting<gradient>("environment.workspace.grid_color"_s, gradient{ service<i_app>().current_style().palette().color(color_role::Theme).with_alpha(0.25) }, { true }, "Grid color: %?%"_t);
 
Video:
 
https://www.youtube.com/watch?v=1ByxyyPIh-o
 
neoGFX - the cheaper, superior alternative to the currently most popular C++ GUI toolkit .. coming soon!
 
/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."
Juha Nieminen <nospam@thanks.invalid>: Jul 12 06:14AM

> Read again, i correct about Delphi and Freepascal and volatile and safety..
 
Are you going to keep spamming thew newsgroup by posting the same
thing again and again and again, fixing some missed comma?
 
Posting the same thing again and again is the exact definition of
spamming. Why don't you go spam somewhere else?
Scott Newman <scott69@gmail.com>: Jul 12 09:09AM +0200

Thank you for your enriching thoughts.
I would like to read more of you here.
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Jul 12 02:57AM -0700

>> Read again, i correct about Delphi and Freepascal and volatile and safety..
 
> Are you going to keep spamming thew newsgroup by posting the same
> thing again and again and again, fixing some missed comma?
 
Yes, he is. He's been doing it for years. I don't see it,
because he's in my killfile. Please don't waste time replying.
(As far as I know his email address is valid; you can contact him
that way without bothering anyone else.)
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
aminer68@gmail.com: Jul 11 05:08PM -0700

Hello..
 
 
About safety and parallel programming..
 
In Delphi for windows and Freepascal non-local memory is always considered volatile, so Freepascal has needed by this to simplify parallel
programming, and i think this is good for safety in parallel programming, so i think the best way is to provide this safety by default in C++ and Rust and C# and Swift, so for example Rust and C++ have to abandon on performance to be able to be this high level safety.
 
 
Thank you,
Amine Moulay Ramdane.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jul 12 01:28AM +0100


> About safety and parallel programming..
 
> In Delphi for windows and Freepascal non-local memory is always considered volatile, so Freepascal has needed by this to simplify parallel
> programming, and i think this is good for safety in parallel programming, so i think the best way is to provide this safety by default in C++ and Rust and C# and Swift, so for example Rust and C++ have to abandon on performance to be able to be this high level safety.
 
What the fuck are you talking about?
 
/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."
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: