Wednesday, September 26, 2018

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

"Öö Tiib" <ootiib@hot.ee>: Sep 26 05:25AM -0700

On Wednesday, 26 September 2018 15:06:25 UTC+3, James Kuyper wrote:
> I realized I didn't know which directory contains the PolyBoRi code, and
> didn't feel like searching farther. If you know that the code is C++,
> you might provide hints to speed up that search.
 
There are the packages:
https://git.sagemath.org/sage.git/tree/build/pkgs
Hmm the PolyBoRi is renamed as brial.
https://git.sagemath.org/sage.git/tree/build/pkgs/brial/SPKG.txt
So the C++ examples are there:
https://github.com/BRiAl/BRiAl/tree/master/tests
Particularly BoolePolyRingTest.cc is likely of interest.
"Öö Tiib" <ootiib@hot.ee>: Sep 26 05:47AM -0700

On Wednesday, 26 September 2018 14:57:53 UTC+3, Bart wrote:
 
> Do you see the difference?
 
Yes I see, and your example is good in sense that usage of C++ is
indeed at least twice more verbose and complicated than that of Python.
Also, sage has already redirected all hard lifting to libraries
so there is no much performance gain to expect.
However OP did explicitly express his desire to undo that and to
use C++ directly, so he deserves few kicks. ;)
red floyd <dont.bother@its.invalid>: Sep 26 11:47AM -0700

On 9/25/2018 11:26 PM, Abhishek Kesarwani wrote:
 
>>> It is possible to define similar things in C++? Any kind of help is appreciable.
 
>> Yes it's possible.
 
> How? Tell me the code.
 
How much are you going to pay me to do your homework?
ram@zedat.fu-berlin.de (Stefan Ram): Sep 26 06:03PM

>As used in this newsgroup, pedantic is usually used as an
>uninitential complement, by people who aren't careful about
>the meanings of their words, to describe those who are.
 
I only use this word, when I write a gcc call.
 
gcc ... -pedantic -pedantic-errors ...
 
»I have never, ever, ever seen a great software developer
who does not have amazing attention to detail.«
 
www.softwarebyrob.com/articles/Personality_Traits_of_the_Best_Software_Developers.aspx
[historic URI]
ram@zedat.fu-berlin.de (Stefan Ram): Sep 26 06:14PM

>»I have never, ever, ever seen a great software developer
>who does not have amazing attention to detail.«
 
This has to do with amplification and digital encodings.
 
In the case of analog values, a small difference often
does not matter much. The speed of the car was 99 mph,
or was it 99.000001 mph? Does not matter, usually.
 
(There are some exceptions, when small differences are
amplified. This can happen in nature or be created
artificially. But in those cases, often such small
differences can be involved that all pedantry won't
help to predict the behavior of a system.)
 
But with digital encodings and amplification, a single
bit can determine the difference between war and peace.
Insofar, there are no details anymore. Everything can
be important.
 
A digital encoding, as it is usually used with
digital devices, can ascribe an arbitrary meaning to
a bit, and in today's world, digital devices take part
in many chains were decisions are made.
Tim Rentsch <txr@alumni.caltech.edu>: Sep 26 09:20AM -0700


>> (The /'s indicate italics in the original, signifying a
>> definition of the italicized term.)
 
> While your answer is pedantically correct
 
You're charging me with being pedantic? That's humorous.
 
> (and I therefore strongly approve of it),
 
This makes me think you don't know the term means. Look it up.
"Pedantic" is a negative term that implies someone is showing off
book learning or trivia. If you want to characterize yourself
that way, be my guest, but that's not what I'm doing here.
 
> type can be initialized using a string literal. Most of the
> specifically "character" semantics are implemented by standard
> library routines.
 
The defined term is used in more than a dozen other places in the
C++ standard. To say there is no such thing as a "character type"
in C++ is simply wrong, despite character types being covered by the
umbrella terms "integral types" or "integer types" in many other
passages of the C++ standard.
jameskuyper@alumni.caltech.edu: Sep 26 10:52AM -0700

On Wednesday, September 26, 2018 at 12:20:23 PM UTC-4, Tim Rentsch wrote:
 
> This makes me think you don't know the term means. Look it up.
> "Pedantic" is a negative term that implies someone is showing off
> book learning or trivia.
 
As used in this newsgroup, pedantic is usually used as an uninitential complement, by people who aren't careful about the meanings of their words, to describe those who are.
 
If you want to characterize yourself
> > library routines.
 
> The defined term is used in more than a dozen other places in the
> C++ standard.
 
True, but none of what it says in those other places affects the semantics of those data types.
 
> To say there is no such thing as a "character type" ...
 
Which I did not.
Philipp Klaus Krause <pkk@spth.de>: Sep 26 02:48PM +0200

How can I get the type of a member of a template parameter. E.g. in a
template <class T_t> assume that T_t has a member x. I want to declare
another variable of the same type.
 
Philipp
"Öö Tiib" <ootiib@hot.ee>: Sep 26 06:06AM -0700

On Wednesday, 26 September 2018 15:48:37 UTC+3, Philipp Klaus Krause wrote:
> How can I get the type of a member of a template parameter. E.g. in a
> template <class T_t> assume that T_t has a member x. I want to declare
> another variable of the same type.
 
Use decltype specifier.
 
#include <iostream>
 
template <typename T_t>
struct Example {
decltype(T_t::x) another; // <--- here
};
 
// trying out ...
 
struct Parameter { double x; };
 
int main()
{
Example<Parameter> test{4.2};
std::cout << test.another << "\n";
}
Philipp Klaus Krause <pkk@spth.de>: Sep 26 03:24PM +0200

Am 26.09.2018 um 15:06 schrieb Öö Tiib:
> Example<Parameter> test{4.2};
> std::cout << test.another << "\n";
> }
 
Thanks. What if T_t is some boost graph, the vertex type is the struct,
and x is a member of that struct?
 
Philipp
jameskuyper@alumni.caltech.edu: Sep 26 06:41AM -0700

On Wednesday, September 26, 2018 at 9:24:54 AM UTC-4, Philipp Klaus Krause wrote:
> > }
 
> Thanks. What if T_t is some boost graph, the vertex type is the struct,
> and x is a member of that struct?
 
I'm not familiar with boost graphs, but what expression would you
ordinarily use to access that member of a struct contained in such a
graph? Whatever expression you would use for that purpose, put it inside
the decltype() expression, and it should work.
"Öö Tiib" <ootiib@hot.ee>: Sep 26 06:49AM -0700

On Wednesday, 26 September 2018 16:24:54 UTC+3, Philipp Klaus Krause wrote:
> > }
 
> Thanks. What if T_t is some boost graph, the vertex type is the struct,
> and x is a member of that struct?
 
Basically same. I haven't used Boost.Graph for anything in few years.
When dealing with Boost.Graph use typedefs massively, otherwise you
lose your ways in that <<,><>,<::>::> forest. Something like that:
 
using Vertex = graph_traits<T_t>::vertex_descriptor;
using X = decltype(Vertex::x);
X another;
Philipp Klaus Krause <pkk@spth.de>: Sep 26 03:56PM +0200

Am 26.09.2018 um 15:49 schrieb Öö Tiib:
 
> using Vertex = graph_traits<T_t>::vertex_descriptor;
> using X = decltype(Vertex::x);
> X another;
 
The vertex_descriptor is not the vertex. From my limited experience,
vertex_descriptor tends to be some unsigned integer type.
 
Philipp
"Öö Tiib" <ootiib@hot.ee>: Sep 26 07:20AM -0700

On Wednesday, 26 September 2018 16:56:26 UTC+3, Philipp Klaus Krause wrote:
> > X another;
 
> The vertex_descriptor is not the vertex. From my limited experience,
> vertex_descriptor tends to be some unsigned integer type.
 
Then it is vertex_iterator dereferenced or some other such thing.
 
using VertexIt = graph_traits<T_t>::vertex_iterator;
using Vertex = iterator_traits<VertexIt>::value_type;
using X = decltype(Vertex::x);
X another;
 
Do not keep your experience so limited. Read docs of stuff you use,
the diagnostics from heavily templated stuff are really lot worse to
read. ;)
Philipp Klaus Krause <pkk@spth.de>: Sep 26 04:35PM +0200

Am 26.09.2018 um 16:20 schrieb Öö Tiib:
> using Vertex = iterator_traits<VertexIt>::value_type;
> using X = decltype(Vertex::x);
> X another;
 
Dereferencing boost vertex iterators yields vertex descriptors, not
vertices.
 
I don't have much experience with C++ (I prefer C).
 
So far the only idea I have come up is creating an instance of T_t with
at least one vertex, and then using decltype(T[0].x). But that seemed
too ugly even by C++ standards, so I decided to ask on comp.lang.c++
instead.
 
Philipp
jameskuyper@alumni.caltech.edu: Sep 26 08:26AM -0700

On Wednesday, September 26, 2018 at 10:35:48 AM UTC-4, Philipp Klaus Krause wrote:
...
> at least one vertex, and then using decltype(T[0].x). But that seemed
> too ugly even by C++ standards, so I decided to ask on comp.lang.c++
> instead.
 
decltype() requires an expression as it's argument. If T is a type, T[0]
could be a typename for an array containing 0 elements of type T - which
would be a problem because of the 0 length. However, the immediately
following '.' would make it a syntax error. A type name can appear in an
expression, but only as the argument of a sizeof, alignof, new, or
typeid expression, never as the the starting portion of the expression.
 
I think you mean _t[0].x rather than T{0].x. If that's the simplest
expression that you can think of which gives you the value of the x
member, then decltype(_t[0].x) is the best you can do. I'm not sure why
you consider that "too ugly". Any construct that gives you the type of
that member has to be given enough information to identify which member
it is, of which struct type. Could you give an example of less ugly
syntax that could have been used for this purpose (possibly in an
entirely different language from C++), so I can better understand your
judgement of this particular syntax as "too ugly"?
"Öö Tiib" <ootiib@hot.ee>: Sep 26 08:32AM -0700

On Wednesday, 26 September 2018 17:35:48 UTC+3, Philipp Klaus Krause wrote:
> at least one vertex, and then using decltype(T[0].x). But that seemed
> too ugly even by C++ standards, so I decided to ask on comp.lang.c++
> instead.
 
The decltype guarantees that the operand given to it is only
compile time evaluated for type so it must be well-formed approach.
However writing templates around weightiest bits in boost will
take quite lot of stamina and does not really help to learn C++
since that level of work is rather rarely needed.
 
Usually one uses concrete instantiation of boost.adjacency_list
or the like through pimpl to hide every of its thorns from the
whole world. Not letting anything but one cpp file to #include
that monster tends also to speed the compilation.
Philipp Klaus Krause <pkk@spth.de>: Sep 26 05:38PM +0200

> syntax that could have been used for this purpose (possibly in an
> entirely different language from C++), so I can better understand your
> judgement of this particular syntax as "too ugly"?
 
What I meant is
 
T_t T;
boost::add_vertex(T);
decltype(T[0].x) x;
 
I consider it ugly because it instantiates an object (T), just to get a
type.
 
Philipp
"Öö Tiib" <ootiib@hot.ee>: Sep 26 08:54AM -0700

On Wednesday, 26 September 2018 18:38:27 UTC+3, Philipp Klaus Krause wrote:
> boost::add_vertex(T);
 
> I consider it ugly because it instantiates an object (T), just to get a
> type.
 
Then don't instantiate.
 
using Vertex = std::remove_cv<decltype(T_t()[0].x)>::type;
 
The remove_cv just for case if it returns it const qualified.
jameskuyper@alumni.caltech.edu: Sep 26 10:46AM -0700

On Wednesday, September 26, 2018 at 11:38:27 AM UTC-4, Philipp Klaus Krause wrote:
...
> decltype(T[0].x) x;
 
> I consider it ugly because it instantiates an object (T), just to get a
> type.
 
"The operand of the decltype specifier is an unevaluated operand." (7.1.6.2p4)
Tim Rentsch <txr@alumni.caltech.edu>: Sep 26 08:58AM -0700


> ... which is why I bracket everything. I'm "agnostic" in this - I
> don't know the full order of precedences, and I don't believe you do
> either.
 
You may see a trolling followup from Bart making comments about me
and my beliefs. Please ignore these comments. Bart does not
speak for me. Whether intentionally or not, he has misrepresented
both earlier remarks I have made and my beliefs on the subject.
 
My current policy is not to respond to any posting of Bart's,
whatever the circumstances. Sometimes I may read them, and
other times I may not, but in any case no response will be
given.
Bart <bc@freeuk.com>: Sep 26 05:32PM +0100

On 26/09/2018 16:58, Tim Rentsch wrote:
> and my beliefs. Please ignore these comments. Bart does not
> speak for me. Whether intentionally or not, he has misrepresented
> both earlier remarks I have made and my beliefs on the subject.
 
People can do their own searching for Tim's posts on the subject (mostly
in c.l.c) and make up their minds. But I expect they will show my
remarks weren't wildly off the mark.
 
 
> My current policy is not to respond to any posting of Bart's,
> whatever the circumstances.
 
Funny, I tend to do the same with yours, although mostly because the
topics you post on are so dull.
 
This post is for the group's benefit.
 
Sometimes I may read them, and
Paavo Helde <myfirstname@osa.pri.ee>: Sep 26 08:40PM +0300

On 26.09.2018 13:16, Bart wrote:
> by other languages, although a few are starting to drop some of those.
 
> By that measure, *every* language is derived from Fortran! Just because
> it was the first to use arbitrary expressions in source code.
 
As a counter-example, Lisp is still very much alive, also in Emacs and
AutoCAD for example, and does not contain infix expressions or
precedence rules (at least according to my limited knowledge). Google
says APL does not have precedence rules either.
 
So I would say not every language is "derived from Fortran" regarding
expression syntax. But many are indeed.
Tim Rentsch <txr@alumni.caltech.edu>: Sep 26 09:00AM -0700

> demonstration for him, someone who would be facing precisely the same
> danger, does not reflect well on his character, regardless of how little
> validity there might be in his fears.
 
This reasoning is flawed in several respects. However since
the subject is off-topic I will say nothing further.
Tim Rentsch <txr@alumni.caltech.edu>: Sep 26 08:45AM -0700


> I'm looking for a way to make my linker tell me that the
> executable it linked contains the same symbols as in one of
> the executable's shared libraries.
 
Long story short - I suspect you are looking in vain (disclaimer:
I am not a linker expert).
 
On the plus side, if you are running on Linux it should be fairly
easy to put something together that does what you what want by
using other tools, including in particular 'readelf' (I almost
always use 'readelf -a', because I'm too lazy to learn the options
and I already know how to use grep and awk). You may need another
tool to locate the shared libraries you're interested in, but I
expect you can track that down yourself in another newsgroup where
it's more topical.
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: