Tuesday, January 2, 2018

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

malcolm.arthur.mclean@gmail.com: Jan 02 07:59AM -0800

Can anyone suggest a good course / resource for someone who used C++ a lot about ten years ago, and now wants to pick it back up, the "look and feel" of the language having changed substantially in the intervening period due to greater use of templates for generic programming, move semantics, lambdas, and the like?
guinness.tony@gmail.com: Jan 02 10:27AM -0800

> Can anyone suggest a good course / resource for someone who used C++ a lot about ten years ago, and now wants to pick it back up, the "look and feel" of the language having changed substantially in the intervening period due to greater use of templates for generic programming, move semantics, lambdas, and the like?
 
This helped me:
 
http://shop.oreilly.com/product/0636920033707.do
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jan 02 08:06PM

On 2 Jan 2018 16:30:44 GMT
> >templates for generic programming
 
> Today, we sometimes can /replace/ the use of templates by
> more readable constexpr functions.
 
And for type computation (as opposed to constexpr value computation),
you can sometimes replace C++98-style templated structs containing
typedefs by decltype with the C++14 auto return type used with
(non-constexpr) template functions. When you call decltype on a
function application the function is not executed: only its return type
is deduced.
 
You can use decltype with function templates in C++14 to iterate over
and manipulate type lists at compile time, for example.
 
Excluding signature overloading, there are I suppose four kinds of
compile-time computation available to the user now in C++14: sizeof,
decltype, constexpr and templates. Of these, C++98 had only sizeof and
templates. Possibly there are more: I would need to think about that.
Intelli2 <intelli2@mama.com>: Jan 02 02:07PM -0500

Hello,
 
 
Read this about the LMAX Disruptor, it is not a general purpose
mechanism, it is not suited for all applications.
 
"You can see this in the way that producers add values to the ring: they
first reserve a slot, then later publish it. If there are two
publishers, and one pauses in the middle (e.g. because the operating
system or virtual machine does a context switch), it stalls all
consumers. A second example is that if you want to distribute work
across a pool of threads, the Disruptor can't help. The FAQ suggests
distributing work modulo the number of workers, but what happens when
one work unit is much more expensive than others for some reason? It
ends up stalling all the future work assigned to that task.
ArrayBlockingQueue, which they clobber in their benchmarks, is much more
forgiving.
 
My point is that even though their ring buffer is very well designed and
tuned for high performance, it isn't an appropriate choice for all
applications. However, if you have producer/consumer queues in your
code, you probably should look to see if Disruptors will match your
needs, and anyone interested in high performance code should read their
paper and/or blog posts."
 
Read more here:
 
http://www.evanjones.ca/lmax-disruptor.html
 
 
This is why i have come with my scalable C++ FIFO queues here:
 
https://sites.google.com/site/aminer68/scalable-fifo-queues-for-c
 
 
And I am actually finishing implemeting my new inventions that are a
scalable Waifree FIFO queue and a scalable Lockfree FIFO queue.
 
 
Please stay tuned !
 
Thank you,
Amine Moulay Ramdane.
Intelli2 <intelli2@mama.com>: Jan 02 02:00PM -0500

Hello,
 
 
Read this about the LMAX Distruptor, it is not a general purpose
mechanism, it is not suited for all applications.
 
"You can see this in the way that producers add values to the ring: they
first reserve a slot, then later publish it. If there are two
publishers, and one pauses in the middle (e.g. because the operating
system or virtual machine does a context switch), it stalls all
consumers. A second example is that if you want to distribute work
across a pool of threads, the Disruptor can't help. The FAQ suggests
distributing work modulo the number of workers, but what happens when
one work unit is much more expensive than others for some reason? It
ends up stalling all the future work assigned to that task.
ArrayBlockingQueue, which they clobber in their benchmarks, is much more
forgiving.
 
My point is that even though their ring buffer is very well designed and
tuned for high performance, it isn't an appropriate choice for all
applications. However, if you have producer/consumer queues in your
code, you probably should look to see if Disruptors will match your
needs, and anyone interested in high performance code should read their
paper and/or blog posts."
 
Read more here:
 
http://www.evanjones.ca/lmax-disruptor.html
 
 
This is why i have come with my scalable C++ FIFO queues here:
 
https://sites.google.com/site/aminer68/scalable-fifo-queues-for-c
 
 
And I am actually finishing implemeting my new inventions that are a
scalable Waifree FIFO queue and a scalable Lockfree FIFO queue.
 
 
Please stay tuned !
 
Thank you,
Amine Moulay Ramdane.
wij@totalbb.net.tw: Jan 02 03:19AM -0800

I am implementing a Complex template using C's _Complex, like below:
 
#include <complex.h>
 
template<typename T>
class Complex {
T _Complex m_z;
public:
...
}
 
But g++ says:
error: complex invalid for 'm_z'
T _Complex m_z;
^~~
 
How to go around this issue? Thanks.
David Brown <david.brown@hesbynett.no>: Jan 02 12:50PM +0100

> I am implementing a Complex template using C's _Complex, like below:
 
C++ does not support C's _Complex types. Use C++'s complex number support.
 
In most cases, C is a subset of C++. But complex number support is
different.
 
C complex numbers:
<http://en.cppreference.com/w/c/numeric/complex>
 
C++ complex numbers:
<http://en.cppreference.com/w/cpp/numeric/complex>
 
 
 
Marcel Mueller <news.5.maazl@spamgourmet.org>: Jan 02 07:30PM +0100

> I am implementing a Complex template using C's _Complex, like below:
[...]
> T _Complex m_z;
> ^~~
 
> How to go around this issue? Thanks.
 
std::complex<T> m_z;
 
C++ does not support C's complex type, as David mentioned.
But the standard guarantees that the implementation of std::complex<T>
is binary compatible to T[2] and this is compatible to C's _Complex. So
it works even if you need to work with a C API.
 
Btw: what do you want to define your own complex class. Doesn't
complex<> fit your needs?
 
 
Marcel
woodbrian77@gmail.com: Jan 01 08:20PM -0800

On Monday, January 1, 2018 at 12:42:13 PM UTC-6, Bonita Montero wrote:
> > ..., and readability not even on the list.
 
> That's serious issue. I'm trying to avoid to trace into
> the standard-library of VC++. It looks like ASCII-garbage.
 
I have the same priorities in terms of run time and compile
time. It's the compile time priority that causes me to
minimize blank spaces. One man's trash is another man's
treasure.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Jan 02 07:48PM +1300

> time. It's the compile time priority that causes me to
> minimize blank spaces. One man's trash is another man's
> treasure.
 
You do post some utter nonsense, but that is impressive even for you...
 
--
Ian.
Real Troll <real.troll@trolls.com>: Jan 02 05:34PM

On 27/12/2017 21:14, Ian Collins wrote:
 
> Why oh why do tutorial still use that obsolete term (STL)?
 
Because you didn't bother to tell them directly what they should be
using or for that matter, you should write to them to update their website.
 
Most websites don't update anything these days because the rate of
change is so rapid that one person's hobby can't keep up with them.
 
Microsoft has got an army of web editors who are spending all their time
updating their pages but this can't be forever. A time will come when
Microsoft will concentrate sorely on C#
Real Troll <real.troll@trolls.com>: Jan 02 06:24PM

On 27/12/2017 15:50, 唐彬 wrote:
> where can i find the code or tutorial to learn from, which can better my coding style and let me learn more about how they work?
> thx a lot
 
You need to provide specific problems for anybody to help you here. You
started with STL but the body is about general coding styles and how to
"learn more".
 
To give an example, the area of a triangle can be computed as follows:
 
<!================== Function 01 ==================!>
int AreaofTriangle (int base, int height)
{
return base * height * 1/2;
}
 
This will work if the dimensions are all integers. What about when
dimensions are in decimals? So you might be tempted to write another
function like so:
 
<!================== Function 02 ==================!>
double AreaofTriangle2 (double base, double height)
{
return base * height * 1/2;
}
 
So this will work with numbers like 3.5, 4.5
 
However, some nit-pickers will come out with some other measurements.
 
So you could apply a template that can work with most sizes as long as
the logic remains the same as to how to calculate the Area of a
Triangle. So you could use this template:
 
<!================== Function 03 ==================!>
template <typename T>
T AreaofTriangle3 (T base, T height)
{
return base * height * 1/2;
}
ram@zedat.fu-berlin.de (Stefan Ram): Jan 02 04:30PM

>back up, the "look and feel" of the language having changed
>substantially in the intervening period due to greater use of
>templates for generic programming
 
Today, we sometimes can /replace/ the use of templates by
more readable constexpr functions.
 
You can read the fourth edition of "The C++ Programming
Language" by Bjarne Stroustrup from 2013 and then "Effective
Modern C++" by Scott Meyers from 2014.
 
On the web, read the new articles Herb Sutter wrote since
2013 ("gotw") and also check out articles on en.cppreference.com
and isocpp.org and movies of C++ talks since 2013 on youtube.com.
jacobnavia <jacob@jacob.remcomp.fr>: Jan 02 01:57AM +0100

Hi
Has anyone here used this static analyzer?
 
For C projects it seems to work, but for C++ code it hangs (I stopped
after waiting for 6 hours for any output).
 
I am using it in an ARM64, about 5 times slower than a high end PC.
 
Is this normal?
 
Thanks for any info
 
jacob
Ian Collins <ian-news@hotmail.com>: Jan 02 02:43PM +1300

On 01/02/2018 01:57 PM, jacobnavia wrote:
> Hi
> Has anyone here used this static analyzer?
 
Yes, my current project uses it (version 1.79 works best for me) on all
of our C and C++ code.
 
> For C projects it seems to work, but for C++ code it hangs (I stopped
> after waiting for 6 hours for any output).
 
Which version and options? It will work significantly faster on Linux
than it does on Windows.
 
> I am using it in an ARM64, about 5 times slower than a high end PC.
 
> Is this normal?
 
Probably, why not just use it on the PC? Using -j 2*core count should
speed things along nicely.
 
--
Ian.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Jan 01 07:46PM -0800

On Monday, January 1, 2018 at 7:57:42 PM UTC-5, jacobnavia wrote:
 
> Is this normal?
 
> Thanks for any info
 
> jacob
 
I have used Visual Studio's built in Code Analyzer. It found half
a dozen rare / extreme-case bugs. I haven't tried Visual Studio 2017's
Code Analyzer yet. Just VS 2015. It's integrated into the GUI, and
enabled by a simple compile option. Compilation takes 2x to 5x longer
than normal. Explains step-by-step conditions which yield the code in
error scenario.
 
--
Rick C. Hodgin
Andrea Venturoli <ml.diespammer@netfence.it>: Jan 02 04:11PM +0100

On 01/02/18 01:57, jacobnavia wrote:
> Hi
> Has anyone here used this static analyzer?
 
Yes.
 
 
 
> For C projects it seems to work, but for C++ code it hangs (I stopped
> after waiting for 6 hours for any output).
 
I'm using it on C++, and it's doing partly its job: I get a lot of false
positives (always of the same 2 or 3 types however), but it did find
some faults in the code.
 
 
 
> I am using it in an ARM64, about 5 times slower than a high end PC.
 
> Is this normal?
 
No.
While it's slow, I never had to wait 6 hours.
 
 
 
bye
av.
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: