Wednesday, October 14, 2020

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

Nikki Locke <nikki@trumphurst.com>: Oct 14 10:23PM

Available C++ Libraries FAQ
 
URL: http://www.trumphurst.com/cpplibs/
 
This is a searchable list of libraries and utilities (both free
and commercial) available to C++ programmers.
 
If you know of a library which is not in the list, why not fill
in the form at http://www.trumphurst.com/cpplibs/cppsub.php
 
Maintainer: Nikki Locke - if you wish to contact me, please use the form on the website.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 14 08:05PM

On Sun, 2020-10-11, Öö Tiib wrote:
> own issues.
> Program is put together of patterns and it is business of compiler
> to reduce it to minimal binary code.
 
It's not how I see it, but I couldn't come up with a good explanation
of how I /do/ see it.
 
>> types.
 
> May be it is indeed better to use unordered_map<std::string, Photo>.
> I think of such idiom as "dictionary idiom" as it is rather common.
 
For me, anything that discourages use of domain-specific types is a
bad thing. I use them a lot to (the way I see it) make my designs
clearer; it's one of the main benefits of C++ IMO.
 
> That does compile when <string> is included. What you search
> for photo in your set of photos with? Without file name in
> external interface? Dummy photo?
 
In this application, a (name of a) photo isn't just a string: it's
either a file name matching a certain pattern, or it's invalid. I
establish that at the external interface, before this set or map gets
involved. Then it makes sense to represent it as a type, to show that
this invariant holds.
 
[snip]
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Thiago Adams <thiago.adams@gmail.com>: Oct 14 11:01AM -0700

This sample prints:
 
https://godbolt.org/z/3f13vW
 
#include <stdio.h>
 
struct Point {
const char* name = "";
int x = 1, y = 2;
};
 
struct Line {
struct Point pt1 = { .name = "pt1" };
};
 
int main()
{
struct Line line = {};
printf(".pt1 = {.name='%s' .x=%d .y=%d}\n", line.pt1.name, line.pt1.x , line.pt1.y);


struct Line line2 = { .pt1 = {.x = 3} };
printf(".pt1 = {.name='%s' .x=%d .y=%d}\n", line2.pt1.name, line2.pt1.x , line2.pt1.y);
}
 
 
.pt1 = {.name='pt1' .x=1 .y=2}
.pt1 = {.name='' .x=3 .y=2}
 
 
I was expecting this for the last print:
 
.pt1 = {.name='pt1' .x=3 .y=2}
 
 
basically the designated initializers does not care
about the defaults of line.
 
I was expecting the designed initializer something that
could override the defaults but not ignore then.
 
What do you think? What is the rationale for this?
Thiago Adams <thiago.adams@gmail.com>: Oct 14 11:04AM -0700

On Wednesday, October 14, 2020 at 3:02:07 PM UTC-3, Thiago Adams wrote:
 
> What is the rationale for this?
 
Some references:
 
 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0329r0.pdf
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0329r3.pdf
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0329r4.pdf
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: