Monday, December 5, 2016

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

Ramine <ramine@1.1>: Dec 05 12:16PM -0500

Hello......
 
 
Finally, look at this new big revolution !
 
Scientists at the University of Sussex have invented a ground-breaking
new method that puts the construction of large-scale quantum computers
within reach of current technology.
 
Professor Hensinger said: "This development is a game changer for
quantum computing making it accessible for industrial and government
use. We will construct a large-scale quantum computer at Sussex making
full use of this exciting new technology."
 
Read more here:
 
https://www.sciencedaily.com/releases/2016/12/161202103416.htm
 
 
 
Thank you,
Amine Moulay Ramdane.
bleachbot <bleachbot@httrack.com>: Dec 05 12:51AM +0100

bleachbot <bleachbot@httrack.com>: Dec 05 01:37AM +0100

bleachbot <bleachbot@httrack.com>: Dec 05 02:39AM +0100

bleachbot <bleachbot@httrack.com>: Dec 05 03:37AM +0100

bleachbot <bleachbot@httrack.com>: Dec 05 04:25AM +0100

ram@zedat.fu-berlin.de (Stefan Ram): Dec 05 12:23PM

How does one pronounce »GotW« (in the sense of »Guru of the Week«)?
ram@zedat.fu-berlin.de (Stefan Ram): Dec 05 12:54PM

Here is a quote from Bjarne Stroustrup regarding teaching:
 
»The standard library containers and algorithms and the
use of exceptions in resource management are examples of
key topics that are often neglected, or wrongly
considered advanced.«
 
I think the wording »the use of exceptions in resource
management« is slightly odd. Historically, we managed
resources by calling clean-up functions, and exceptions
blew that up. In the 80s this problem was often ignored,
eventually we learned how to adjust everything with RAII,
which is a very ingenious and beautiful solution which
was AFAIK invented by Bjarne Stroustrup.
 
But I'd say that what one should learn is »resource
management (even in the case of exceptions)«, because our
primary goal is resource management and exceptions do not
directly help to accomplish that goal, instead at first
they are a hindrance, but we learned how to do resource
management even in the case of exceptions. Or instead of
»the use of«, one might say, »coping with«, i.e.,
»coping with exceptions in resource management«.
bleachbot <bleachbot@httrack.com>: Dec 05 06:15PM +0100

Daniel <danielaparker@gmail.com>: Dec 04 08:07PM -0800

Consider a class
 
 
template <class Allocator>
struct A_base
{
A_base(const Allocator& allocator)
: allocator_(allocator)
{
}
 
Allocator allocator_;
};
 
 
template <class Allocator>
struct C : public A_base<Allocator>
{
C()
: A_base(Allocator())
{
}
C(const Allocator& allocator)
: A_base{ allocator }
{
 
}
 
void f()
{
}
}
 
Is there a reliable way within function f to determine whether allocator_ is stateful or stateless?
 
I thought about using std::is_default_constructible<Allocator>, as presumably a stateful allocator would not have a default constructor.
 
Or testing whether sizeof(C) == sizeof the same data structure except not inheriting from A_base.
 
Any thoughts?
 
Thanks,
Daniel
"Christopher J. Pisz" <cpisz@austin.rr.com>: Dec 05 12:13AM -0600

On 12/4/2016 10:07 PM, Daniel wrote:
 
> Any thoughts?
 
> Thanks,
> Daniel
 
I'd agree with you that sizeof(C) == sizeof the same data structure
except not inheriting from A_base is pretty much fullproof, but I am no
expert on allocators.
"Öö Tiib" <ootiib@hot.ee>: Dec 05 12:22AM -0800

On Monday, 5 December 2016 06:08:07 UTC+2, Daniel wrote:
> Is there a reliable way within function f to determine whether allocator_ is stateful or stateless?
 
Take from Boost.TypeTraits 'is_stateless'. Docs of TypeTraits:
http://www.boost.org/doc/libs/1_62_0/libs/type_traits/doc/html/index.html
 
 
> I thought about using std::is_default_constructible<Allocator>, as presumably a stateful allocator would not have a default constructor.
 
> Or testing whether sizeof(C) == sizeof the same data structure except not inheriting from A_base.
 
> Any thoughts?
 
Boost docs say that "is_stateless" is implemented like that:
 
::boost::has_trivial_constructor<T>::value
&& ::boost::has_trivial_copy<T>::value
&& ::boost::has_trivial_destructor<T>::value
&& ::boost::is_class<T>::value
&& ::boost::is_empty<T>::value
Daniel <danielaparker@gmail.com>: Dec 05 08:50AM -0800

On Monday, December 5, 2016 at 3:22:23 AM UTC-5, Öö Tiib wrote:
> && ::boost::has_trivial_destructor<T>::value
> && ::boost::is_class<T>::value
> && ::boost::is_empty<T>::value
 
Thanks! And it looks like all the pieces are in <type_traits>.
 
Daniel
David Brown <david.brown@hesbynett.no>: Dec 05 02:17PM +0100

On 05/12/16 13:23, Stefan Ram wrote:
> How does one pronounce »GotW« (in the sense of »Guru of the Week«)?
 
Presumably one pronounces it "Guru of the Week" ? Anything else would
be difficult to say, and impossible to understand.
"Øyvind Røtvold" <orotvold@gmail.com>: Dec 05 03:11PM +0100


> How does one pronounce »GotW« (in the sense of »Guru of the Week«)?
 
Fish?
 
or perhaps got-woo?, althoug that would fit better to a literal Guru,
an I assume that's not what we're taking abuot here.
 
 
--
.. Øyvind - soon to appear in a kill file near you.
.. Ignorance can be cured; stupidity is forever.
Daniel <danielaparker@gmail.com>: Dec 04 08:45PM -0800

In vs 2015, the following compiles:
 
#include <vector>
 
template <class T>
struct A
{
std::vector<T> d_;
};
 
struct B
{
A<B> x_;
};
 
int main()
{
B b;
}
 
However, replacing vector with deque,
 
#include <deque>
 
template <class T>
struct A
{
std::deque<T> d_;
};
 
struct B
{
A<B> x_;
};
 
int main()
{
B b;
}
 
fails with error message "use of undefined type 'B'"
 
Is that expected?
 
Thanks,
Daniel
Ian Collins <ian-news@hotmail.com>: Dec 05 06:05PM +1300

On 12/ 5/16 05:45 PM, Daniel wrote:
> B b;
> }
 
> fails with error message "use of undefined type 'B'"
 
Where?
 
> Is that expected?
 
No, are you sure you posted what you compiled?
 
--
Ian
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 05 01:03PM +0100

On 05.12.2016 05:45, Daniel wrote:
> }
 
> fails with error message "use of undefined type 'B'"
 
> Is that expected?
 
In the C++03 days it would be expected, also for the vector.
 
A standard library container item type could not be of incomplete type,
so you'd get the same problem with
 
struct S { vector<S> v; };
 
But I have a vague recollection that this was changed in C++11 or C++14.
Not sure though. Technically it can be supported because the various
/operations/ of that vector are not instantiated until they're used, at
which point S is complete, e.g. its size is known.
 
 
Cheers & hth.,
 
- Alf
Ike Naar <ike@iceland.freeshell.org>: Dec 05 07:51AM


> //Create vector of size n and initialize to 1 to n
> vector<unsigned long long> v(n);
> for (unsigned long long i = 1; i < v.size(); ++i)
 
This loop does not initialize v[0], but v[0] is used in the next loop.
 
Ike Naar <ike@iceland.freeshell.org>: Dec 05 08:05AM

> v[j] = v[val];
> v[val] = temp;
> }
 
There is a standard library function for that:
 
#include <algorithm>
std::random_shuffle(v.begin(), v.end());
"Öö Tiib" <ootiib@hot.ee>: Dec 05 01:35AM -0800

On Monday, 5 December 2016 09:53:01 UTC+2, Ike Naar wrote:
> > vector<unsigned long long> v(n);
> > for (unsigned long long i = 1; i < v.size(); ++i)
 
> This loop does not initialize v[0], but v[0] is used in the next loop.
 
It feels worth to mention here that the vector elements are not
uninitialized before the loop. The loop modifies values of those.
So v[0] remains with value 0ULL as it was set by declaration of
v and usage of it in next loop is well-defined.
 
Ramine <ramine@1.1>: Dec 04 10:26PM -0500

Hello..........
 
The essence of concurrency
 
I think Java and ADA and C++ and those kind of languages that uses
object oriented programming have failed miserably..
 
Because parallel programming has made them to fail, because
they are too risky for parallel programming and thus for
safe-criticalsystems..
 
Now read carefully this:
 
The Downfall of Imperative Programming
 
https://www.fpcomplete.com/blog/2012/04/the-downfall-of-imperative-programming
 
As you will notice this person is not telling you that functional
programming with Haskel and MVars is prone to Deadlocks and to Stavation
, other than that functional programming introduces a problem with
readability even if you use defun to simplify lisp programs etc.
because functional programming doesn't force you to make functional
programming more readable, so this problems of readability and Deadlocks
and Starvation have made functional programming to fail also.
 
So i think that we have a big problem now.
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 04 09:38PM -0500

Hello..................
 
The essence of the essence..
 
It's a good subject of philosophy..
 
But how to attack this subject ?
 
The what first:
 
The essence of the essence is a view that enhance our understanding..
 
The how in second:
 
The tools of the essence of the essence is the tool also
of philosophy: intelligence and logic and measure and money.
 
Because a consequence of the essence of the essence is a higher degree
of quality,but the essence of quality is a consequence of more money
and more intelligence both cultural and genetical.
 
And the essence of the essence is also a consequence of the essence of
science that in turn is consequence of the essence of quality.
 
So as you have seen me doing is using the essence of science to
understand more the essence of reality, and that's why i have
attacked philosophical subjects such as the essence of quality
and the essence of science and the essence of programming and
the essence of parallel programming.
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 04 08:41PM -0500

Hello..........
 
The essence of parallel programming
 
Now i want to attack a problem about the essence of parallel programming
 
I have understood more programming in Functional programming like
programming in Scheme, Lisp and Haskel.. and i have programmed
with C++ and Java and Object Pascal and Javascript and Perl.
 
Now what is the essence of parallel programming ?
 
You can not speak about the essence without speaking about
the empirical facts that constrain parallel programming..
 
Now if you look at the functional programming Haskel, it
tries to eliminate race conditions by using pure functions
and Mvars, but it still is prone to Deadlocks and to Starvation
and to the following form of logical problem:
 
Look at this Relacy Race Detector:
 
http://www.1024cores.net/home/relacy-race-detector
 
Other that look at this:
 
a:=a+1
 
If every thread has to increment "a" one time, this form of logic
is nasty, because if we do the following in Relacy Race Detector:
 
tmp:=a
 
lock.enter;
 
a:=tmp+1;
 
lock.leave;
 
 
How can Relacy Race Detector detect that the logic that every thread has
to increment "a" one time is good ? Relacy Race Detector can
not do it, and this form of logic can become more nasty, so
this is why parallel programming for safe-critical systems
is still too risky.
 
Other than that modeling with contracts and with Relacy Race Detector
is prone to error, so i think that since the essence of parallel
programming is contrained by all those limitations, i think
parallel programming is still too risky for safe-critical systems.
 
So i will ask you also a question:
 
Do you think that modeling with contracts with ADA or Eiffel is
sufficient? i don't think so, because it lesser the probability
of failing , but it still can fail, so contracts or Functional
programming is not the silver bullet.
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 04 07:39PM -0500

Hello......
 
Look at this Relacy Race Detector:
 
http://www.1024cores.net/home/relacy-race-detector
 
It is designed to detect race conditions, but you have to understand me
Sir and Madam, you have to model your problem with this tool,
and this modeling is prone to error, so that's not good for
safe-critical systems, other that look at this:
 
a:=a+1
 
If every thread has to increment "a" one time, this form of logic
is nasty, because if we do the follwing in Relacy Race Detector:
 
tmp:=a
 
lock.enter;
 
a:=tmp+1;
 
lock.leave;
 
 
How can Relacy Race Detector detect that the logic that every thread has
to increment "a" one time is good ? Relacy Race Detector can
not do it, and this form of logic can become more nasty, so
this is why parallel programming for safe-critical systems
is still too risky.
 
 
 
Thank you,
Amine Moulay Ramdane.
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: