Saturday, December 31, 2016

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

Tim Rentsch <txr@alumni.caltech.edu>: Dec 31 01:12PM -0800

> can be encoded in just 2 bits, e.g., for joy-joy hacking delight, in
> the least significant bits of the pointers ? but I'm not going to do
> that. :)
 
The code still doesn't discard (or simply count) duplicate values.
I really recommend that you do that, especially before you get to
rebalancing. (I have no other specific comments on that version
of the code so I snipped it.)
 
 
> ----------------------------------------------------------------------
 
> An implementation of Tim's suggested O(1) memory updating, which as I
> understand it is a common implementation:
 
It corresponds to what is done in the AVL algorithm given in
Knuth. I don't know how common it is, only that I thought it
worth pointing out.
 
> node = (go_left? node->left : node->right);
> }
> }
 
Another way the termination test could be done is to pass in the
address of the newly created leaf node, and compare for it. That
would make the while() loop be something like
 
while( node != new_leaf ) ...
 
and it would allow the updating of node->height_diff to be lifted
up a level rather than being inside an if().
 
 
> I haven't measured these but the O(1) memory scheme avoids any dynamic
> allocation even for the most naive direct implementation, so for the
> case of non-optimized code it should be faster.
 
A downside of this approach is that the value comparisons (or some
of them anyway) are done a second time. An intermediate scheme,
which I kind of like, is to have a "stack" of bits reflecting the
left/right choices made past the point of the tipping point node.
The "stack" of bits can be stored in 2 or 3 'unsigned long' words,
which is more than enough to handle any feasible tree.
 
Incidentally, kind of a side comment, I find the code composition
style shown to be somewhat cumbersome. I don't know if you have
changed your normal style for tutorial reasons, and it's really
tangential to the main discussion anyway, but I thought it might
be good to mention it.
 
> It brings more complexity to the `add` member function, and simplifies
> the `update_height_differences`... function.
 
It turns out some sort of tracking like this will be important
when we get to rebalancing, so it's probably better to introduce
it now.
 
Also, you may find it helpful to split off the special case of
adding a value to an empty tree. The general case code has an
easier time of it if that code doesn't have to deal with the tree
being completely empty.
 
> ----------------------------------------------------------------------
 
> My thinking about balancing.
 
> I've yet to read up on this in Wikipedia. [...]
 
For those who are interested I will try to walk through a general
outline. If anyone wants to figure it out on their own then stop
reading here.
 
Here is a canonical tree that may need rebalancing after a new
value is inserted (and obviously there are the corresponding
mirror image cases):
 
20
/ \
/ \
10 40
/ \
/ \
30 50

Note: the tree is shown as complete, with '20' at the top, but
that isn't actually necessary for what follows. The '20' node
could be in the middle of the tree, and there could be additional
subtrees below the '10', '30', and '50' nodes, as long as:
 
one: the height of those three leaf nodes is all the same; and
two: all nodes after '20' along the insertion path are "level",
ie, their left and right subtrees have equal heights.
 
So, if we're going to insert a new value, there are three cases:
somewhere under the 10 (eg, 5 or 15), somewhere under the 30 (eg,
25 or 35), or somewhere under the 50 (eg 45 or 55). Let's look at
the "under 10" case first. The new tree looks like this:
 
20
/ \
/ \
10 40
.... / \
/ \
30 50

where the .... means something got added somewhere in the left or
right subtree of the 10. The "balance" factor of the 10 node will
have been adjusted already, by virtue of being downstream from the
"tipping point" node, which is the 20 node in this case. The
height of 20's left side has grown by one, so the 20 node needs to
be marked as "level", but nothing else needs to happen.
 
Now let's look at the "under 50" case. The new tree looks like
this:
 
20
/ \
/ \
10 40
/ \
/ \
30 50
....
 
For sure this tree needs to be rebalanced. After inserting a new
value, rebalancing an AVL tree is a local operation, involving
just a few nodes in the interior of the tree. Here we have the
easier of the two cases where rebalancing needs to happen.
Typically the transformation done is described as a "rotation".
Conceptually it could be described thusly:
 
one: move the 20 node down and to the left;
two: move the 40 node up to where the 20 node used to be;
three: change the left link in the 40 node to point to the
20 node, and set the right link of the 20 node (which
used to point to the 40 node) to point to the 30 node.
 
Here is the post-rotation picture:
 
40
/ \
/ \
20 50
/ \ ....
/ \
10 30
 
To adjust the balance factors, the 20 node and the 40 node both
need to be set to "level". (The balance on the 50 node will have
been adjusted already, according to whether the insertion happened
on the left or the right.) Whatever parent pointer used to point
to the 20 node needs to be set to point to the 40 node. The
parent pointer could be a left- or right- pointer in what was 20's
parent node, or it could the root_ pointer if the 20 node was at
the top of the tree.
 
Now let's look at the "under 30" case. Here is what the tree
looks like after the new value is inserted:
 
20
/ \
/ \
10 40
/ \
/ \
30 50
....
 
Suppose we try the same rotation we did for the "under 50" case.
The resulting tree would be:
 
40
/ \
/ \
20 50
/ \
/ \
10 30
....
 
Obviously that didn't help - the tree shown has the same out-of-
balance problem as the original, except on the left instead of on
the right. We need to do something different, but what?
 
It's common to see the transformation needed here described as a
"double rotation", but I think it might be easier to understand if
described like this:
 
one: reach down, grab the 30 node, pull it up to the top;
two: set 30's left link to point to the 20 node, 30's right
link to point to the 40 node;
three: set 20's right link to point to the original value of
30's left link, and 40's left link to point to the
original value of 30's right link
 
Here is the resulting picture:
 
30
/ \
/ \
20 40
/ .? ?. \
/ \
10 50
 
Note the .... that was under the 30 got split, with half of it put
under the 20, and half of it put under the 40. If the 30 node was
previously a leaf, only one of those two pointers will be
non-null.
 
For balance factors: the 30 node should be set level; the 20
node should be set level if the insertion happened down 30's left
side, and "leftish" otherwise; the 40 node should be set level if
the insertion happened down 30's right side, and "rightish"
otherwise.
 
And of course whatever parent node was previously pointing to 20
needs to be set to point to the 30 node.
 
NOTE: The discussion above assumes all nodes along the insertion
path and downstream of the 20 node have had their balance factors
adjusted already. Nodes upstream of the 20 node all keep the same
balance factors they had before the insertion.
Manfred <noname@invalid.add>: Dec 31 06:34PM +0100

On 12/23/2016 04:30 PM, Stefan Ram wrote:
>> dispatch method either.
 
> What is bothering you most about the dispatch methods that
> you have been using so far?
 
I still had to answer to this.
MFC uses message maps, which substantially work, but they are buried
within MFC, so they come with all of its burden (which Alf summarized well).
Moreover, from the language point of view, I think they substantially
are not C++. They are C with classes at best, IMHO - no object
connection, no polymorphism.
It results in the oddity (also IMHO), as per their functionality, that
in the era of C++17 they still use two map lookup: the window object and
the handler function. Microsoft has gone to considerable extent in
optimizing such lookup, but still every single message has to go through
them.
From the coding point of view, it is a minor issue but I find it
somewhat suboptimal that a handler for a single message has to be
declared twice: in the class and in the map.
Ian Darroy <iandarroy@gmail.com>: Dec 30 09:46PM -0800

Hello guys! Happy New Year comming!
 
I've got a design question about how to construct my application the right way.
 
I'm writing a small lisp interpreter and it consists of few classes: Reader, Evaluator, Environment, Symbol and Function. My design is bad because hardly all classes depend on each other this way:
 
Reader needs Symbol to parse input and wrap strings into Symbol's name.
Evaluator fulfills these Symbols with values (each Symbol has all types in it like Number, Function, String and List (I use vector of Symbols)).
Environment keeps map<Name, Symbol> to hold values so Evauator can ask it for them.
Functions devide on builtins and user-defined, all accept vector of Symbols and I've got inheritance for them.
 
All this is binded with Evaluator, it's like a hypervisor and knows about everything, what makes me sad.
 
Please, help to make a better design decision. If you know some recourses, I will be thankful!
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 31 07:04AM +0100

On 31.12.2016 06:46, Ian Darroy wrote:
> about everything, what makes me sad.
 
> Please, help to make a better design decision. If you know some
> recourses, I will be thankful!
 
General advice is to differentiate between interface and implementation
of something.
 
Two modules can depend on each other's interfaces without depending on
each other's implementations.
 
This is harder to do with header-only modules, so when you know there's
going to be little mess, separate compilation is probably a good idea.
 
 
Cheers!,
 
- Alf
Ian Darroy <iandarroy@gmail.com>: Dec 31 12:08AM -0800

Thank you
Jeff-Relf.Me <@.>: Dec 30 08:39PM -0800

ram@zedat.fu-berlin.de (Stefan Ram): Dec 31 12:49AM

>//CONST int ci = 0, &cj = ci;
>so does the const entitle every object after its created?
 
A simple-declaration is produced thus:
 
simple-declaration:
decl-specifier-seq init-declarator-list[opt] ;
 
. Above, »const int« is the decl-specifier-seq, and »ci = 0,
&cj = ci« is the init-declarator-list[opt].
 
So the »const«, as a part of the decl-specifier-seq, applies
to every of the following init-declarators.
 
>now that the const is in the middle, does it ignore the first
>object and create a const for everything in front of it?
>including the next object?
 
Here, the »const« only refers to the init-declarator-list
»int &k = i«.
 
The semicolon »;« terminates a full simple-declaration, and
the »const« cannot refer to other simple-declarations.
ram@zedat.fu-berlin.de (Stefan Ram): Dec 31 01:22AM

>start of the declaration. I think it's unfortunate, but all the examples
>in the Holy Standard use prefix `const`. The more general notation is
>needed for pointer and function declarations.
 
I repost a post of mine here:
 
|Newsgroups: comp.lang.c++
|Subject: const T vs T const
|From: ram@zedat.fu-berlin.de (Stefan Ram)
|Message-ID: <const-20160926184659@ram.dialup.fu-berlin.de>
|
| It was possibly in this newsgroup where the topic
| "const T vs T const" was discussed some months ago.
| (Or it might have been "comp.lang.c".)
|
| Dan Sacks famously wrote about it and recommended
| "T const" IIRC.
|
| I now found something new about this topic in the
| "Library Design Guidlines" for C++: quote
|
|const goes in the wrong place, i.e., to the left
|
| unquote. Thus, they acknowledge what Dan Sacks
| wrote by using "wrong", only to then recommend
| the opposite, i.e., "left".
|
| Why? Maybe because tradition dictates this. (No
| rationale is given there.)
 
The C++ Core Guidelines do not seem to discuss
this, but always seem to use const on the left.
 
The article by Dan Sacks is called »const T vs. T
const« and was or is at www.ultimeth.com/Feb1999.pdf.
 
(It is the same Dan Sacks who asked for a definition
of »type« recently.)
Momo N <ninetynineknights@gmail.com>: Dec 30 04:27PM -0800

so the question is this:
 
//CONST int ci = 0, &cj = ci;
 
so does the const entitle every object after its created? does this read "ci is a const int" and "cj is a reference to a const int" as well? or is &cj not a const and just means "a reference to ci"?
 
if the const DOES encompass the entire line, what about this...
 
//int j = i; CONST int &k = i; int *p = &i;
 
now that the const is in the middle, does it ignore the first object and create a const for everything in front of it? including the next object?
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 31 01:51AM +0100

On 31.12.2016 01:27, Momo N wrote:
 
> //CONST int ci = 0, &cj = ci;
 
> so does the const entitle every object after its created? does this
> read "ci is a const int" and "cj is a reference to a const int"
 
Yes.
 
> as well? or is &cj not a const and just means "a reference to ci"?
 
It couldn't be: a reference to non-const and be bound to a const object,
as that would allow you to modify a const object.
 
 
 
 
> now that the const is in the middle, does it ignore the first object
> and create a const for everything in front of it? including the next
> object?
 
First off, C++ is case-sensitive. It has to be `const`. Unless you
defined `CONST` as a macro, to be replaced with `const` by the preprocessor.
 
Semicolons are much stronger delimiters than commas.
 
The first example is a single declaration statement, with multiple
declarators.
 
The second example is three declaration statements.
 
`const T x;` is a shorthand for `T const x`, permitted only at the very
start of the declaration. I think it's unfortunate, but all the examples
in the Holy Standard use prefix `const`. The more general notation is
needed for pointer and function declarations.
 
For the general notation pointer declaration, just read it backwards. :)
 
E.g.
 
char const* p;
 
declares `p` as a mutable pointer to `const` char, while
 
char c;
char* const p = &c;
 
declares p as a constant pointer to mutable char.
 
 
Cheers & hth.,
 
- Alf
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.

Friday, December 30, 2016

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

woodbrian77@gmail.com: Dec 29 09:59PM -0800

On Thursday, December 29, 2016 at 4:25:45 PM UTC-6, Ian Collins wrote:
> > but against the baseless hatred in some "leaders"
 
> So how much do you know about the people and leaders of New Zealand?
> Enough to insult us?
 
G-d loves people from New Zealand, including the leaders. G-d
loved King Herod even though Herod murdered Yohanan the Immerser
(aka John the Baptist). But G-d sent Yohanan and Yeshua (aka
Jesus), in part, to stand up to Herod. Herod didn't respond
well to their rebuke. I'm afraid there's no shortage of corrupt
people like Herod in power today.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Dec 30 09:27PM +1300


>> So how much do you know about the people and leaders of New Zealand?
>> Enough to insult us?
 
> G-d loves people from New Zealand, including the leaders.
 
 
In other words, no. An apology would be appropriate.
 
--
Ian
David Brown <david.brown@hesbynett.no>: Dec 30 10:07AM +0100

> as a "radical individualist". I'm for people,
> but against the baseless hatred in some "leaders"
> -- Putin, Obama ...
 
So you claim to be /for/ the people (of USA, NZ, UK, Russia, etc.), and
against their leaders? Fair enough - there is nothing wrong with having
a political opinion (though it is always much better if it is /informed/
opinion, rather than just knee-jerk reaction).
 
So why do you then insult the /people/ (of USA, etc.) rather than their
leaders?
 
And why do you accuse them of "anti-semitism" - prejudice against Jews
either as a people or as members of a religion? Both the leaders and
the majority of the populace of these countries disapproves of Israel's
/leaders/ and political policies - they have nothing against either the
people of Israel, the Jewish religion, or anything else that could be
construed as anti-semitism. They just don't think that one country
should invade its neighbours and turn that country into a giant prison
camp while stealing their land and resources. The leaders and populace
of USA, etc., don't care if the tyrants behind this plan are Jewish,
Christian, Muslim, Martians, or whatever.
 
The hypocrisy behind your "thinking" is just astounding. It does not
matter how often you quote your old book, or complain about swearing -
you can't claim to be Christian if you don't understand basic humanity
and if you don't follow Jesus' most important rule - love thy neighbour.
 
 
> these "leaders" will have the trap they intended for
> Israel recoil on themselves. I'll be buying products
> from Taiwan and South Korea, rather than China or Japan.
 
Whoa, these countries are in for a shock! When they find out that Brian
is no longer buying products from China and Japan, their economies will
be collapsing in no time. Watch out for that "recoil"!
asetofsymbols@gmail.com: Dec 30 02:49AM -0800

The leaders are choosed many time from peoples but only
in a rose, or in a little set choosed
from elite...
So where is the choose people has?
asetofsymbols@gmail.com: Dec 30 03:17AM -0800

For me it is better leader is the
parliaments so many peoples
not just one...
More people there are in parlaments
better it is
woodbrian77@gmail.com: Dec 30 09:51AM -0800

On Friday, December 30, 2016 at 2:27:59 AM UTC-6, Ian Collins wrote:
 
> > G-d loves people from New Zealand, including the leaders.
 
> In other words, no. An apology would be appropriate.
 
If I were planning a trip to your part of the world, I'd
go to Australia.
 
"Australian Foreign Minister claims that if it had had a say,
Australia would not have voted for the recent "one-sided" UN resolution."
 
http://www.israelnationalnews.com/News/News.aspx/222531
 
I've never been to Australia or New Zealand, but
Austrailia is looking like they still have a heart.
 
 
Brian
Ebenezer Enterprises - Enjoy programming again.
http://webEbenezer.net
interval1066@gmail.com: Dec 30 10:43AM -0800

On Monday, December 26, 2016 at 1:51:38 PM UTC-8, Jeff-Relf.Me wrote:
> Macros are _good_, you should use them.
 
Sure. Microsoft created a whole language out of them. Its called MFC.
Wouter van Ooijen <wouter@voti.nl>: Dec 30 07:46PM +0100

> go to Australia.
 
> "Australian Foreign Minister claims that if it had had a say,
> Australia would not have voted for the recent "one-sided" UN resolution."
 
one-sided?
 
ROFL!
 
Wouter "Objects? No Thanks!" van Ooijen
Jeff-Relf.Me <@.>: Dec 30 02:17PM -0800

interval1066@gmail.com: Dec 30 11:10AM -0800

On Tuesday, December 27, 2016 at 3:16:37 AM UTC-8, Rick C. Hodgin wrote:
> one. You'll find every one holds up to the most intense scrutiny, and
> every aspect of observable science because it is the truth.
 
> Truth has a name, Ian: Jesus.
 
too busy to jump all over this guy flibble, or taking it easy for the holidays?
Mr Flibble <flibble@i42.co.uk>: Dec 29 11:26PM

On 29/12/2016 21:56, Tim Rentsch wrote:
> the order, so I guess there is no need to explain further.
 
> The problem of finding the middle element of a list while
> traversing the list once does make an amusing little exercise.
 
Yes I have thought about that problem and I am guessing it involves
powers of 2 if you know what I mean. :)
 
/Flibble
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 08:25PM -0800

>> traversing the list once does make an amusing little exercise.
 
> Yes I have thought about that problem and I am guessing it involves
> powers of 2 if you know what I mean. :)
 
I don't know about other folks but my solution involves
exactly two powers of 2 -- 2**0 and 2**1.
David Brown <david.brown@hesbynett.no>: Dec 30 09:48AM +0100

On 29/12/16 18:43, Gareth Owen wrote:
>> set), while the set
 
> That's not what we were taught re bounded and unbounded. The definition
> I was taught was to do with there being a metric, and that there was a
 
(You need an order, not a metric - though a metric can give you an order.)
 
 
> ∃r ∈ ℝ such that ||x|| < r ∀x ∈ S
 
The set {x ∈ ℝ : x > 0 and x < 1} is bounded within ℝ, but not as a
stand-alone set by itself, as the limits are not inside the set. That's
why we have to be careful about the details here.
 
So the set of non-negative integers is normally called "unbounded"
because it has no limit within the set. But viewed as ordinals, they
/have/ a limit - ω₀, so within the set of countable ordinals, the finite
ordinals are infinite but bounded.
 
 
It is a /long/ time since I was at university, so I can't be entirely
sure that my terminology is correct here. But I think you can
understand what I mean.
 
 
Gareth Owen <gwowen@gmail.com>: Dec 30 11:37AM


> The set {x ∈ ℝ : x > 0 and x < 1} is bounded within ℝ, but not as a
> stand-alone set by itself, as the limits are not inside the set. That's
> why we have to be careful about the details here.
 
Again, "contains all its limit points" is one of the usual equivalent
definitions of closed set. For that you don't need an order, but you do
need a topology.
 
> because it has no limit within the set. But viewed as ordinals, they
> /have/ a limit - ω₀, so within the set of countable ordinals, the finite
> ordinals are infinite but bounded.
 
Then we were taught different nomenclature.
 
> It is a /long/ time since I was at university, so I can't be entirely
> sure that my terminology is correct here. But I think you can
> understand what I mean.
 
Oh, I understand completely, you're just using different terms than I'm
used to. As you gave your definitions, it was totally comprehensible.
David Brown <david.brown@hesbynett.no>: Dec 30 01:23PM +0100

On 30/12/16 12:37, Gareth Owen wrote:
 
> Again, "contains all its limit points" is one of the usual equivalent
> definitions of closed set. For that you don't need an order, but you do
> need a topology.
 
It sounds like I am mixing up my definitions here, and I'm grateful to
you for stirring up my old memories and bringing them to the surface again.
 
When I had been talking about "bounded", I really meant /closed and
bounded/ - i.e., the bounds are within the set. But you are correct -
to be bounded, a set needs to have limits but the limits do not have to
be in the set.
 
>> /have/ a limit - ω₀, so within the set of countable ordinals, the finite
>> ordinals are infinite but bounded.
 
> Then we were taught different nomenclature.
 
No, you just remember it better :-)
 
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 30 07:41AM +0100

Part 3. This tutorial, if it works (it's an experiment), is intended to
work this way:
 
* I post some working code.
* Learner(s) study it and ask about things.
* Others answer questions and post critique or get bogged down in long
sub-threads about sausages and swearing.
 
Part 2 added logic to maintain a height difference value in each node.
Namely, height of right subtree minus height of left subtree. One nice
thing about a difference, as opposed to just storing the heights
directly, is that when balancing is introduced the diff can be encoded
in just 2 bits, e.g., for joy-joy hacking delight, in the least
significant bits of the pointers – but I'm not going to do that. :)
 
Tim Rentsch suggested an alternative way to do the updating, using O(1)
memory instead of O(log n) memory as in the code I posted. That's one
reason for this posting. Another reason is that I'd like comments on my
thoughts about balancing, outlined at the end here, before I code it up.
 
----------------------------------------------------------------------
 
The part 2 updating code, using O(log n) memory, looked like this:
 
// Called after a new node, the `p_new_child`, has been inserted:
void update_height_differences(
Node* const p_new_child,
stack<Node*> parent_nodes
)
{
Node* p_child = p_new_child;
while( not parent_nodes.empty() )
{
Node* const p_parent = popped_top_of(
parent_nodes );
int& height_diff = p_parent->height_diff;
int const old_height_diff = height_diff;
 
height_diff += (p_parent->right == p_child? +1 : -1);
 
bool const this_height_increased =
(abs( height_diff ) > abs( old_height_diff ));
if( not this_height_increased )
{
break;
}
p_child = p_parent;
}
}
 
void add( Value const& value )
{
stack<Node*> parent_nodes;
Node** p_ptr = &root_;
while( *p_ptr != nullptr )
{
Node*& ref_ptr = *p_ptr;
parent_nodes.push( ref_ptr );
p_ptr = &(value < ref_ptr->value? ref_ptr->left :
ref_ptr->right);
}
*p_ptr = new Node{ nullptr, nullptr, value, 0 };
update_height_differences( *p_ptr, move( parent_nodes ) );
}
 
An implementation of Tim's suggested O(1) memory updating, which as I
understand it is a common implementation:
 
// Called after a new node with value `new_value` has been inserted:
static void update_height_differences_down_from(
Node* const highest_node_with_change,
Value const& new_value
)
{
Node* node = highest_node_with_change;
while( node )
{
bool const go_left = (new_value < node->value);
bool const is_leaf_node = not(node->left or node->right);
if( not is_leaf_node )
{
node->height_diff += (go_left? -1 : +1);
}
node = (go_left? node->left : node->right);
}
}
 
void add( Value const& value )
{
Node** p_ptr = &root_;
Node* lowest_newheight_absorber = nullptr;
while( *p_ptr != nullptr )
{
Node*& ref_ptr = *p_ptr;
bool const go_left = (value < ref_ptr->value);
bool const go_right = not go_left;
bool const right_is_higher = (ref_ptr->height_diff > 0);
bool const left_is_higher = (ref_ptr->height_diff < 0);
 
if( go_left and right_is_higher or go_right and
left_is_higher )
{
lowest_newheight_absorber = ref_ptr;
}
 
p_ptr = &(go_left? ref_ptr->left : ref_ptr->right);
}
 
*p_ptr = new Node{ nullptr, nullptr, value, 0 };
update_height_differences_down_from(
lowest_newheight_absorber? lowest_newheight_absorber : root_,
value
);
}
 
I haven't measured these but the O(1) memory scheme avoids any dynamic
allocation even for the most naïve direct implementation, so for the
case of non-optimized code it should be faster.
 
It brings more complexity to the `add` member function, and simplifies
the `update_height_differences`... function.
 
----------------------------------------------------------------------
 
My thinking about balancing.
 
I've yet to read up on this in Wikipedia. Hopefully that won't be
necessary! :) I think the last I read about it was in Wirth's Algorithms
+ Data Structures = Programs, around 1984.
 
Basic idea for the situation at the left below, put current root at
maximum right of its left of subtree (its value is guaranteed greater):
 
|
40
/ |
30 → 30
/ / \
20 20 40
/ / \
10 10 30
 
How a naïve implementation can then produce an equally bad tree:
 
|
40
/ \ |
30 45 → 30
/ \ / \
20 35 20 35
/ / \
10 10 40
\
45
 
One fix is to make current root R = 40 the right subtree of its left
node N = 30, put current right subtree of N as left subtree of R:
 
|
40
/ \ |
30 45 → 30
/ \ / \
20 35 20 40
/ / / \
10 10 35 45
 
But is this all, modulo symmetry for the opposite imbalance?
 
 
Cheers!, & Happy New Year soon!,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 30 01:57AM +0100

On 29.12.2016 23:31, Tim Rentsch wrote:
> }
 
> So, for what it's worth, that is now the best suggestion I have
> to offer.
 
Oh, thanks! I need to really fasten that with duct tape back of my
skull, because it's not the first time! Some years ago I was enquiring
here about another difficult-for-me thing, a scheme for generating
extensions of options classes in a class derivation hierarchy
(essentially to do the same thing as passing named option values in e.g.
Python, especially for GUI stuff), and James Kanze suggested, hey, why
don't you just preprocess using a script?
 
Somehow the thought didn't enter my mind.
 
I ended up doing a different all C++ complicated template thing, which I
subsequently wrote a DDJ article about, but I think that was mostly
because I had such a momentum in that direction, not really a free
choice. The preprocessing is the rational thing to do. Thanks!
 
 
Cheers!,
 
- Alf
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 08:31PM -0800

> (essentially to do the same thing as passing named option values in
> e.g. Python, especially for GUI stuff), and James Kanze suggested,
> hey, why don't you just preprocess using a script?
 
You are most welcome sir. It's always nice to hear that a
suggestion is found to be both helpful and appreciated. :)
Ben Bacarisse <ben.usenet@bsb.me.uk>: Dec 30 02:23AM

Tim Rentsch <txr@alumni.caltech.edu> writes:
<snip>
> or 40 years ago. A good starting point is the paper by
> James Morris, "Types are not Sets":
 
> http://dl.acm.org/citation.cfm?id=582168
 
That seems to be the wrong link. I find it at:
 
http://dl.acm.org/citation.cfm?doid=512927.512938
 
--
Ben.
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 08:27PM -0800


>> http://dl.acm.org/citation.cfm?id=582168
 
> That seems to be the wrong link. I find it at:
 
> http://dl.acm.org/citation.cfm?doid=512927.512938
 
Yes, thank you, that's the link I meant. Somehow I mistakenly
copied the wrong link from my clipboard.
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.

Thursday, December 29, 2016

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

Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 02:31PM -0800

> message name expands to some hex number, e.g. 0x000F for WM_PAINT,
> which would generate a macro invocation like HANDLE_0x000F instead of
> HANDLE_WM_PAINT. [...]
 
(Before I start, thank you for the later explanation of message
flow. I think I was able to figure out what I was looking for.)
 
Well, that is annoying. Normally I would expect those would be
enumeration constants, but I guess they are macros instead.
 
After seeing this message, I looked into this more deeply.
Basically, if you want to handle cracking "automatically" rather
than by hand, I think you're stuck with some sort of macro
solution. (Disclaimer: I know essentially nothing about the
newer variadic template stuff.) However, and here is the good
news, I think a macro solution can be constructed that is a lot
simpler than the earlier ones. Here is my example file,
including some minor warts (partly because the environment is
linux but with a -I to get the MS windows header files, and also
I dummied up a 'winapi' since I didn't discover one otherwise),
which compiles.
 
The definition of SELF_ON() is the key item to look at - does
this approach seem cleaner to you? I would be inclined to
use something like this.
 
=============================================================================
#define __i686__ 1
#include <windows.h>
#include "generated/crackit.h"
 
struct winapi {
struct Message {
UINT message_id;
WPARAM wParam;
LPARAM lParam;
};
typedef LRESULT Lresult;
};
 
struct Base {
virtual winapi::Lresult on( winapi::Message const& m ) = 0;
};
 
#define SELF_ON( type, m ) \
case type: return CRACK_##type( this->on_##type, (m).wParam, (m).lParam )
 
struct Sample : Base {
auto on( winapi::Message const& m ) noexcept
-> winapi::Lresult
override
{
switch( m.message_id ){
SELF_ON( WM_COMMAND, m );
SELF_ON( WM_SIZE, m );
SELF_ON( WM_PAINT, m );
}
return 0; //subclassing_.original_processing( m );
}
 
winapi::Lresult on_WM_COMMAND( ULONG a, HWND b, ULONG c ){ return 0; }
winapi::Lresult on_WM_SIZE( ULONG a, ULONG b, ULONG c ){ return 0; }
winapi::Lresult on_WM_PAINT(){ return 0; }
};
 
=============================================================================
 
The definitions for the CRACK_... macros (ie, in the generated
file "generated/crackit.h") are produced programmatically from
the HANDLE_... macros in <windowsx.h>, using a short awk script:
 
#! /bin/awk -f
 
$0 ~ /#define HANDLE_WM_/ {
gsub( /[(]hwnd,/, "(fn," );
gsub( /,fn[)]/, ")" );
gsub( /[(][(]hwnd[)],/, "(" );
gsub( /[(]fn[)][(]hwnd[)]/, "(fn)()" );
gsub( / HANDLE_/, " CRACK_" );
print
}
 
So, for what it's worth, that is now the best suggestion I have
to offer.
woodbrian77@gmail.com: Dec 29 02:19PM -0800

On Thursday, December 29, 2016 at 2:55:57 PM UTC-6, Ian Collins wrote:
> > like little children, you will never enter the kingdom of heaven.
> > Matthew 18:3
 
> Do little children insult whole countries?
 
I agree with Ben Shapiro when he describes himself
as a "radical individualist". I'm for people,
but against the baseless hatred in some "leaders"
-- Putin, Obama ...
 
Some would like to set a trap for Israel with this
UN (United Nothing) vote. The funny thing is that
these "leaders" will have the trap they intended for
Israel recoil on themselves. I'll be buying products
from Taiwan and South Korea, rather than China or Japan.
 
 
Brian
Ebenezer Enterprises - "They prepared a net for my steps;
My soul is bowed down; They dug a pit before me; they
themselves have fallen into the midst of it. Selah." Psalms 57:6
 
http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Dec 30 11:25AM +1300


> I agree with Ben Shapiro when he describes himself
> as a "radical individualist". I'm for people,
> but against the baseless hatred in some "leaders"
 
So how much do you know about the people and leaders of New Zealand?
Enough to insult us?
 
--
Ian
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 02:00PM -0800


> Simple question, simple answer: in C++ a type is that which an object
> is an instance of; an object doesn't have to be an instance of a class
> type: an 'int' variable is also an object.
 
This answer conflates the two different notions of type, as
explained in my other posting. For example a variable of
type 'int' and a variable of type 'const int' are both
instances of the 'int' representation, but they have
different types (ie, in the sense of what is checked at
compile time).
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 02:06PM -0800

> when are two >>bundles<< equal? Because of this vagueness,
> the sentence possibly cannot be used as a definition.
 
> [...]
 
All these ideas have been explored in the literature 20, 30,
or 40 years ago. A good starting point is the paper by
James Morris, "Types are not Sets":
 
http://dl.acm.org/citation.cfm?id=582168
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 01:56PM -0800

>> asymptotic complexity, worst-case or otherwise.
 
> So how to get the middle element without traversing linked list O(n)
> times for each partition? You are basically contradicting yourself.
 
I gather you now agree that this can be done without changing
the order, so I guess there is no need to explain further.
 
The problem of finding the middle element of a list while
traversing the list once does make an amusing little exercise.
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.

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

Mr Flibble <flibble@i42.co.uk>: Dec 29 06:58PM

I do hope regular listeners enjoyed my mathematical word salads.
 
Sausages.
 
/Flibble
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Dec 29 12:55PM -0800

On Thursday, December 29, 2016 at 1:58:42 PM UTC-5, Mr Flibble wrote:
> [snip]
 
Leigh, the life of your eternal soul hinges upon what you do with
Jesus Christ. Reject Him as you are doing, and you remain under
condemnation for your sin. Repent of your sin and ask Him to forgive
you and you pass from death to life in eternity.
 
It's your choice. Only a fool would choose eternal damnation over
eternal life.
 
Best regards,
Rick C. Hodgin
Ian Collins <ian-news@hotmail.com>: Dec 30 09:59AM +1300

On 12/30/16 07:58 AM, Mr Flibble wrote:
> I do hope regular listeners enjoyed my mathematical word salads.
 
Something amusing to read over breakfast :)
 
> Sausages.
 
Breakfast.
 
--
Ian
Ian Collins <ian-news@hotmail.com>: Dec 29 01:05PM +1300

> On Wednesday, December 28, 2016 at 3:59:23 PM UTC-6, Chris Vine wrote:
 
> Chris, please don't swear here.
 
So you can insult whole countries, but Chris can't swear?
 
Sanctimonious hypocrite.
--
Ian
Jeff-Relf.Me <@.>: Dec 28 04:08PM -0800

Dombo <dombo@disposable.invalid>: Dec 29 02:34PM +0100

> On Wednesday, December 28, 2016 at 3:59:23 PM UTC-6, Chris Vine
> wrote:
 
> Chris, please don't swear here.
 
Why not? "Fuck" is Perhaps one of the most interesting, versatile and
colorful words in the English language today. It is the one magical word
which, just by its sound, can describe pain, pleasure, love, and hate.
 
In language, "fuck" falls into many grammatical categories. It can be
used as a verb, both transitive (John fucked Mary) and intransitive
(Mary was fucked by John). It can be an action verb (John really gives a
fuck), a passive verb (Mary really doesn't give a fuck), an adverb (Mary
is fucking interested in John), or as a noun (Mary is a terrific fuck).
 
It can also be used as an adjective (Mary is fucking beautiful) or an
interjection (Fuck! I'm late for my date with Mary). It can even be used
as a conjunction (Mary is easy, fuck she's also stupid). As you can see,
there are very few words with the overall versatility of the word "fuck"..
 
Aside from its sexual connotations, this incredible word can be used to
describe many situations:
 
1. Greetings: "How the fuck are ya?"
 
2. Fraud: "I got fucked by the car dealer."
 
3. Resignation: "Oh, fuck it!"
 
4. Trouble: "I guess I'm fucked now."
 
5. Aggression: "FUCK YOU!"
 
6. Disgust: "Fuck me."
 
7. Confusion: "What the fuck.......?"
 
8. Difficulty: "I don't understand this fucking business!"
 
9. Despair: "Fucked again..."
 
10. Pleasure: "I fucking couldn't be happier."
 
11. Displeasure: "What the fuck is going on here?"
 
12. Lost: "Where the fuck are we."
 
13. Disbelief: "UNFUCKINGBELIEVABLE!"
 
14. Retaliation: "Up your fucking ass!"
 
15. Denial: "I didn't fucking do it."
 
16. Perplexity: "I know fuck all about it."
 
17. Apathy: "Who really gives a fuck, anyhow?"
 
18. Greetings: "How the fuck are ya?"
 
19. Suspicion: "Who the fuck are you?"
 
20. Panic: "Let's get the fuck out of here."
 
21. Directions: "Fuck off."
 
22. Disbelief: "How the fuck did you do that?"
 
It can be used in an anatomical description- "He's a fucking asshole."
It can be used to tell time- "It's five fucking thirty." It can be used
in business- "How did I wind up with this fucking job?" It can be
maternal- "Motherfucker." It can be political- "Fuck Dan Quayle!"
 
It has also been used by many notable people throughout history:
 
"What the fuck was that?"
- Mayor of Hiroshima
 
"Where did all these fucking Indians come from?"
- General Custer
 
"Where the fuck is all this water coming from?"
- Captain of the Titanic
 
"That's not a real fucking gun."
- John Lennon
 
"Who's gonna fucking find out?"
- Richard Nixon
 
"Heads are going to fucking roll."
- Anne Boleyn
 
"Let the fucking woman drive."
- Commander of Space Shuttle
 
"What fucking map?"
- "Challenger," Mark Thatcher
 
"Any fucking idiot could understand that."
- Albert Einstein
 
"It does so fucking look like her!"
- Picasso
 
"How the fuck did you work that out?"
- Pythagoras
 
"You want what on the fucking ceiling?"
- Michaelangelo
 
"Fuck a duck."
- Walt Disney
 
"Why?- Because its fucking there!"
- Edmund Hilary
 
"I don't suppose its gonna fucking rain?"
- Joan of Arc
 
"Scattered fucking showers my ass."
- Noah
 
"I need this parade like I need a fucking hole in my head."
- John F. Kennedy
woodbrian77@gmail.com: Dec 29 10:27AM -0800

On Thursday, December 29, 2016 at 7:32:00 AM UTC-6, Dombo wrote:
 
And he said: "Truly I tell you, unless you change and become
like little children, you will never enter the kingdom of heaven.
Matthew 18:3
 
Please don't swear here.
 
 
Brian
Ebenezer Enterprises - Here are five demonstrations that the
"Palestinians want peace" notion is an outright lie, and that
Palestinians actually prefer a continued conflict that
maintains the possibility of the full-scale destruction of
the Jewish State.
 
http://www.dailywire.com/news/11993/do-palestinians-want-peace-here-are-5-facts-say-no-ben-shapiro
Dombo <dombo@disposable.invalid>: Dec 29 08:33PM +0100


> And he said: "Truly I tell you, unless you change and become
> like little children, you will never enter the kingdom of heaven.
> Matthew 18:3
 
You really believe that the verses in your "holy" bible are like magic
spells don't you? Guess what, they don't do fuck. Grow up.
 
 
> Please don't swear here.
 
Your religion is your fucking problem mate, don't try make it my problem.
Ian Collins <ian-news@hotmail.com>: Dec 30 09:55AM +1300


> And he said: "Truly I tell you, unless you change and become
> like little children, you will never enter the kingdom of heaven.
> Matthew 18:3
 
Do little children insult whole countries?
 
> Please don't swear here.
 
Hypocrite.
 
--
Ian
Mr Flibble <flibble@i42.co.uk>: Dec 29 05:01PM

"Fuck" is Perhaps one of the most interesting, versatile and colorful
words in the English language today. It is the one magical word which,
just by its sound, can describe pain, pleasure, love, and hate.
 
In language, "fuck" falls into many grammatical categories. It can be
used as a verb, both transitive (John fucked Mary) and intransitive
(Mary was fucked by John). It can be an action verb (John really gives a
fuck), a passive verb (Mary really doesn't give a fuck), an adverb (Mary
is fucking interested in John), or as a noun (Mary is a terrific fuck).
 
It can also be used as an adjective (Mary is fucking beautiful) or an
interjection (Fuck! I'm late for my date with Mary). It can even be used
as a conjunction (Mary is easy, fuck she's also stupid). As you can see,
there are very few words with the overall versatility of the word "fuck"..
 
Aside from its sexual connotations, this incredible word can be used to
describe many situations:
 
1. Greetings: "How the fuck are ya?"
 
2. Fraud: "I got fucked by the car dealer."
 
3. Resignation: "Oh, fuck it!"
 
4. Trouble: "I guess I'm fucked now."
 
5. Aggression: "FUCK YOU!"
 
6. Disgust: "Fuck me."
 
7. Confusion: "What the fuck.......?"
 
8. Difficulty: "I don't understand this fucking business!"
 
9. Despair: "Fucked again..."
 
10. Pleasure: "I fucking couldn't be happier."
 
11. Displeasure: "What the fuck is going on here?"
 
12. Lost: "Where the fuck are we."
 
13. Disbelief: "UNFUCKINGBELIEVABLE!"
 
14. Retaliation: "Up your fucking ass!"
 
15. Denial: "I didn't fucking do it."
 
16. Perplexity: "I know fuck all about it."
 
17. Apathy: "Who really gives a fuck, anyhow?"
 
18. Greetings: "How the fuck are ya?"
 
19. Suspicion: "Who the fuck are you?"
 
20. Panic: "Let's get the fuck out of here."
 
21. Directions: "Fuck off."
 
22. Disbelief: "How the fuck did you do that?"
 
It can be used in an anatomical description- "He's a fucking asshole."
It can be used to tell time- "It's five fucking thirty." It can be used
in business- "How did I wind up with this fucking job?" It can be
maternal- "Motherfucker." It can be political- "Fuck Dan Quayle!"
 
It has also been used by many notable people throughout history:
 
"What the fuck was that?"
- Mayor of Hiroshima
 
"Where did all these fucking Indians come from?"
- General Custer
 
"Where the fuck is all this water coming from?"
- Captain of the Titanic
 
"That's not a real fucking gun."
- John Lennon
 
"Who's gonna fucking find out?"
- Richard Nixon
 
"Heads are going to fucking roll."
- Anne Boleyn
 
"Let the fucking woman drive."
- Commander of Space Shuttle
 
"What fucking map?"
- "Challenger," Mark Thatcher
 
"Any fucking idiot could understand that."
- Albert Einstein
 
"It does so fucking look like her!"
- Picasso
 
"How the fuck did you work that out?"
- Pythagoras
 
"You want what on the fucking ceiling?"
- Michaelangelo
 
"Fuck a duck."
- Walt Disney
 
"Why?- Because its fucking there!"
- Edmund Hilary
 
"I don't suppose its gonna fucking rain?"
- Joan of Arc
 
"Scattered fucking showers my ass."
- Noah
 
"I need this parade like I need a fucking hole in my head."
- John F. Kennedy
Mr Flibble <flibble@i42.co.uk>: Dec 29 05:36PM

Fuck is a command. Someone pisses you off, you tell them to Fuck off.
Simple. Fuck is an expletive, as in Fuck me, Fuck you, Fuck this. Fuck
is verb and emphasis, like Fucking jerk, or Pass the fucking salt. Fuck
gives you a way to tell someone they've overstepped the line, Shut the
fuck up, Go fuck yourself.
 
Fuck is creative and immensely satisfying. Telling someone to Go take a
flying fuck (at a rolling doughnut) will make them step back a pace.
Fuck expresses and emphasises confusion like no other word, What the
fuck, What the fucking fuck?
 
Fuck is a word for a night in the pub, Fucked again. Or for those who
give you grief while you're there, Fucktards and Motherfuckers. It can
be used on the way home, or in the morning, to great and colourful
effect, My God, I'm never fucking drinking again.
 
Fuck is rebellion, teenage or otherwise, Don't fuck with me, Don't do me
any fucking favours, Fuck the system, Who gives a fuck?
 
Fuck expresses depressive anger, Fuck the world, and equally, the
encouragement that's its opposite, Don't get fucked up, fucked over, She
isn't fucking worth it.
 
Fuck expresses confusion, Who the fuck are you, What the fuck is this,
You're fucking kidding me. It expresses exasperation, You dumb fuck.
 
With the right character, Fuck is a word that adds an underline to
almost any emotion, that exaggerates speech and reaction, that can be
put fucking everywhere, to fucking enhance anything, and still make
fucking sense.
 
Fuckers.
 
http://danieware.com/2743/fuck/
Daniel <danielaparker@gmail.com>: Dec 29 10:44AM -0800

On Thursday, December 29, 2016 at 12:01:28 PM UTC-5, Mr Flibble wrote:
 
> Aside from its sexual connotations, this incredible word can be used to
> describe many situations:
 
<22 examples snipped>
 
23. Posts "There is no such thing as the set of finite ordinals." Reads response.
Fuck!
Gareth Owen <gwowen@gmail.com>: Dec 29 06:50PM


> 23. Posts "There is no such thing as the set of finite ordinals."
> Reads response.
> Fuck!
 
"This fuckwit doesn't have the first fucking clue."
Robert Wessel <robertwessel2@yahoo.com>: Dec 29 02:49PM -0600

On Thu, 29 Dec 2016 17:36:35 +0000, Mr Flibble <flibble@i42.co.uk>
wrote:
 
>fucking sense.
 
>Fuckers.
 
>http://danieware.com/2743/fuck/
 
 
Dude!
David Brown <david.brown@hesbynett.no>: Dec 29 09:38AM +0100

On 28/12/16 16:34, Gareth Owen wrote:
>> because there is a way to define ordinals, but it is not a set.
 
> On a related note, I am currently attempting to teach my goldfish to
> speak Norwegian.
 
It will take time, but I am sure if you persist then it will learn in
the end. /I/ did, and we Scots are not known for our language abilities :-)
David Brown <david.brown@hesbynett.no>: Dec 29 09:43AM +0100

On 28/12/16 17:40, Mr Flibble wrote:
 
> Bullshit. There is no such thing as the set of finite ordinals as there
> is an infinite number of ordinals; you have also been drinking the
> koolaid like that idiot Owen.
 
/You/ referred to "the set of ordinals" a couple of posts back. Now you
don't believe in the "set of /finite/ ordinals", which is clearly going
to be a subset of the set /you/ mentioned?
 
Perhaps you are unsure about what a "set" actually is, or what an
"ordinal" is, or what "finite" means?
David Brown <david.brown@hesbynett.no>: Dec 29 11:00AM +0100

On 28/12/16 18:12, Mr Flibble wrote:
 
> Bullshit; you cannot have a set of infinite things as infinity is,
> unlike a set, unbounded. Countable infinities are unbounded just like
> uncountable infinities despite what Wikipedia says.
 
Sets don't have to be finite - why on earth would you think that?
 
And as for "bounded" and "unbounded", you have to be very careful of
what you mean. These terms refer to order, not size. The set
 
{x ∈ ℝ : x > 0 and x < 1}
 
is infinite and unbounded (since the limits, 0 and 1, are not in the
set), while the set
 
{x ∈ ℝ : x ≥ 0 and x ≤ 1}
 
is infinite and bounded.
 
(All finite sets are bounded.)
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 29 11:05AM -0600


> {x ∈ ℝ : x ≥ 0 and x ≤ 1}
 
> is infinite and bounded.
 
> (All finite sets are bounded.)
 
Exactly.
 
/Flibble
Gareth Owen <gwowen@gmail.com>: Dec 29 05:43PM


> {x ∈ ℝ : x > 0 and x < 1}
 
> is infinite and unbounded (since the limits, 0 and 1, are not in the
> set), while the set
 
That's not what we were taught re bounded and unbounded. The definition
I was taught was to do with there being a metric, and that there was a
 
∃r ∈ ℝ such that ||x|| < r ∀x ∈ S
 
> {x ∈ ℝ : x ≥ 0 and x ≤ 1}
 
> is infinite and bounded.
 
This is closer to the definition I know for open/closed (but not the same)
 
> (All finite sets are bounded.)
 
Still true.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 29 12:34AM +0100

> ::std::unique_ptr<cmw_request> request(::new cmw_request(localbuf));
 
> After getting C++ 2014 compilers, I wrote it like this:
> auto request=::std::make_unique<cmw_request>(localbuf);
 
I haven't used the feature, but I think if `localbuf` is not a pointer
but something passed by reference, you need to use `std::ref`.
 
And in general, I'd just make a factory function.
 
 
Cheers!,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 29 12:37AM +0100

On 25.12.2016 04:48, Ian Collins wrote:
>> ::std::unique_ptr<cmw_request> request(::new cmw_request(localbuf));
 
> I can see some (very week) justification for the superfluous colons
> before std, but new?
 
It avoids invoking a class-specific override of the allocation function.
 
It can be bug because if `std::default_delete` isn't specialized for
this class, it will use an ordinary delete expression that invokes a
class specific deallocation function if such exists.
 
But then, if `std::default_delete` isn't specialized and the class
overrides allocation and deallocation, then this qualification is a sort
of dirty workaround: not benefiting from the custom allocator, but at
least not invoking Undefined Behavior.
 
 
Cheers!,
 
- Alf
woodbrian77@gmail.com: Dec 28 06:23PM -0800

On Wednesday, December 28, 2016 at 5:34:28 PM UTC-6, Alf P. Steinbach wrote:
> > auto request=::std::make_unique<cmw_request>(localbuf);
 
> I haven't used the feature, but I think if `localbuf` is not a pointer
> but something passed by reference, you need to use `std::ref`.
 
What feature do you mean? localbuf isn't a pointer. I've
not gotten any compiler warnings or run time errors from that
line. It is currently line 257 in this file:
 
https://github.com/woodbrian/onwards/blob/master/cmwAmbassador.cc
 
 
> And in general, I'd just make a factory function.
 
You may have missed what I was asking about. There's a new way
to write that line without using make_unique. This has more info:
 
http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4471.html
 
It says: Creating "make functions" like make_tuple is confusing,
artificial, extra boilerplate, and inconsistent with how non-template
classes are constructed.
 
Unfortunately, none of the examples they mention are of
std::unique_ptr.
 
 
Brian
Ebenezer Enterprises - Enjoy programming again.
http://webEbenezer.net
Jeff-Relf.Me <@.>: Dec 28 06:23PM -0800

woodbrian77@gmail.com: Dec 28 04:04PM -0800

On Wednesday, December 28, 2016 at 4:10:05 PM UTC-6, Mr Flibble wrote:
> Please stick to topic which is C++ modulo sausages.
 
Hi, Leigh,
 
I enjoyed your "Read the Bible" post here a month or so ago.
 
But yes, C++ 2017 is looking OK. And if you have been playing
with with Java, D, Go, Rust, C#, etc. for a few years, C++ is
likely better than how you remember it.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
woodbrian77@gmail.com: Dec 28 03:46PM -0800

On Wednesday, December 28, 2016 at 5:24:51 PM UTC-6, Marcel Mueller wrote:
> code.
> If on a certain platform it is better to go this way then it should be
> up to the optimizer to generate the required code.
 
I agree and would describe the line of code as clever.
I think in one of Chandler Carruth's talks he said that
he doesn't want clever code.
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
 
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.