Tuesday, April 28, 2015

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

legalize+jeeves@mail.xmission.com (Richard): Apr 28 07:55PM

[Please do not mail me a copy of your followup]
 
Robbie Hatley <see.my.sig@for.my.address> spake the secret code
>> I am looking for a »precompiled binary« or windows
>> installer, not a source tree.
 
>Get Cygwin. [...]
 
Please god, no.
 
Just get Visual Studio Community Edition 2013. It's free and it just works.
<https://www.visualstudio.com/>
 
IMO, cygwin/mingw is a giant PITA on Windows and there isn't any need
for it. VS2013 represents C++11 quite well.
<https://msdn.microsoft.com/en-us/library/hh567368.aspx>
<http://en.cppreference.com/w/cpp/compiler_support>
 
Don't try to make Windows into Unix and don't try to make Unix into Windows.
 
Embrace them both for their strengths and learn their weaknesses.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
scott@slp53.sl.home (Scott Lurndal): Apr 28 08:43PM

><http://en.cppreference.com/w/cpp/compiler_support>
 
>Don't try to make Windows into Unix and don't try to make Unix into Windows.
 
>Embrace them both for their strengths and learn their weaknesses
 
In other words, write two makefiles (or worse, whatever VS uses),
have two completely distinct source bases or piles and piles of #ifdefs.
 
no thanks.
"Öö Tiib" <ootiib@hot.ee>: Apr 28 02:06PM -0700

On Tuesday, 28 April 2015 22:55:10 UTC+3, Richard wrote:
> >> installer, not a source tree.
 
> >Get Cygwin. [...]
 
> Please god, no.
 
Right.
 
> <https://www.visualstudio.com/>
 
> IMO, cygwin/mingw is a giant PITA on Windows and there isn't any need
> for it.
 
These are two different things. Cygwin is sort of obscure thing.
MinGW works fine if you want to compile C or C++ on Windows.
 
> VS2013 represents C++11 quite well.
> <https://msdn.microsoft.com/en-us/library/hh567368.aspx>
> <http://en.cppreference.com/w/cpp/compiler_support>
 
rvalue references "weaseling", constexpr "No", inheriting constructors "No",
unicode support "No" "No" and "No", defaulted and deleted functions
"Yes" but further weaseling shows that it does not work about move
constructors and assignments so "rule of zero" does not work.
It is on the midway between C++03 and C++11 while gcc on MinGW supports
most of the C++14.
 
> Don't try to make Windows into Unix and don't try to make Unix into Windows.
 
> Embrace them both for their strengths and learn their weaknesses.
 
Nah. Minor differences everywhere. Most people on planet rarely leave
web browser anyway. If you want native C++ then download Qt and it
looks passably native everywhere. Only few minor things (like
Bluetooth support on Android or OpenGL with some Intel budget
chips/drivers or annoyances with Apple's App-store) may take
some skill. Overall you will enjoy portable programming language
C++ ... at least way more portable than Java ever will be.
legalize+jeeves@mail.xmission.com (Richard): Apr 28 09:32PM

[Please do not mail me a copy of your followup]
 
ram@zedat.fu-berlin.de (Stefan Ram) spake the secret code
> execute this program (possibly after typos were corrected)?
> I am looking for a »precompiled binary« or windows
> installer, not a source tree.
 
The only thing VS2013 couldn't handle in this code was the string
literal suffix (e.g. "example"s). I didn't try in VS2015 community
technology preview which I believe has this implemented according to
<http://en.cppreference.com/w/cpp/compiler_support>.
 
If you want even more C++11/14 compatibility, then you can continue
using the VS IDE and switch out the compiler for clang:
<http://www.ishani.org/projects/ClangVSX/> I haven't tried this
personally, but I trust in the quality of stuff produced by the clang
team. The project above simply packages what the clang team has been
doing into a nice add-on for Visual Studio.
 
"However, if nothing else, you can use ClangVSX as a quick way to
try out C++11/14 features that recent Clang releases have that
Visual Studio still does not..."
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
legalize+jeeves@mail.xmission.com (Richard): Apr 28 07:46PM

[Please do not mail me a copy of your followup]
 
Victor Bazarov <v.bazarov@comcast.invalid> spake the secret code
>argument list). It's easier to read and understand. If nothing is
>supposed to be there, nothing needs to be declared there. Having 'void'
>to designate an empty argument list is a C-ism.
 
FYI, I've got a change in review to add a check to clang-tidy that
will replace (void) argument lists with (), so you can kill off this
C-ism from your code base in an automated and reliable way :-)
 
<http://reviews.llvm.org/D7639>
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
scott@slp53.sl.home (Scott Lurndal): Apr 28 08:41PM


>FYI, I've got a change in review to add a check to clang-tidy that
>will replace (void) argument lists with (), so you can kill off this
>C-ism from your code base in an automated and reliable way :-)
 
So you don't like it. That doesn't make it wrong. In fact, IMO
it is better to have int function(void) { do_something; }.
 
 
><http://reviews.llvm.org/D7639>
 
Hope it's optional.
 
IIRC, using void that way was introduced with C++, not with C.
Victor Bazarov <v.bazarov@comcast.invalid>: Apr 28 04:53PM -0400

On 4/28/2015 4:41 PM, Scott Lurndal wrote:
>> will replace (void) argument lists with (), so you can kill off this
>> C-ism from your code base in an automated and reliable way :-)
 
> So you don't like it. That doesn't make it wrong. In fact, IMO
 
"In fact"? So, it's a fact that such is your opinion? Good one!
 
 
>> <http://reviews.llvm.org/D7639>
 
> Hope it's optional.
 
> IIRC, using void that way was introduced with C++, not with C.
 
YRI
 
V
--
I do not respond to top-posted replies, please don't ask
woodbrian77@gmail.com: Apr 28 11:45AM -0700

> return *this;
> }
> };
 
Often I use that class like this:
 
throw failure("poll failed: ") << errno;
 
So a std::string is constructed and then the errno in
string form is appended to the original string.
 
In a lot of cases, I have a good idea of how much more text
I'm going to append (potentially via multiple calls to
append) to the original string. So I was thinking it
would be helpful to have a std::string ctor that takes
both a char* and a value that indicates how many more
bytes to reserve beyond the length of the char*.
 
http://en.cppreference.com/w/cpp/string/basic_string/basic_string
 
It seems like that would help avoid some allocations and
moving of strings.
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
"Öö Tiib" <ootiib@hot.ee>: Apr 28 12:58PM -0700


> throw failure("poll failed: ") << errno;
 
> So a std::string is constructed and then the errno in
> string form is appended to the original string.
 
Yes, but what good can the catch site do with that text?
Lot simpler to throw and easier to catch:
 
throw PollFailed( errno );
 
Catch site can differentiate between 'PollFailed' and
'ElectionFailed' by two catches and the errno is possible
to extract from 'PollFailed' (if interesting) without parsing
some sort of text. However if all of it it is anticipated
as uninteresting for catch site then why not just:
 
throw failure("");
 
???
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 28 09:36PM +0100


> http://en.cppreference.com/w/cpp/string/basic_string/basic_string
 
> It seems like that would help avoid some allocations and
> moving of strings.
 
What the fuck are you doing mate? Exceptions should be thrown rarely not
routinely (mainly for exceptional conditions) so who cares about bloody
string allocations? I am sure you just think up random C++ shit to post
so you can advertise your bloody "middleware" project and your fucking god.
 
/Flibble
Marcel Mueller <news.5.maazl@spamgourmet.org>: Apr 28 10:16PM +0200

I have a data structure (for signal processing) where a std::map
contains iterators to it's own elements. I.e.
 
typedef multimap<key_type, element_type> map_type;
typedef map_type::iterator element_type;
 
Of course, I can't write this, because the definition is recursive.
However the resulting data structure is not recursive, since the
iterator has finite size. Is it possible to define a type of this kind?
 
The iterators are required to maintain a second independent sort order,
that only needs a linked list because it only requires the operations
pop_front and push_back.
 
 
Marcel
Victor Bazarov <v.bazarov@comcast.invalid>: Apr 28 04:33PM -0400

On 4/28/2015 4:16 PM, Marcel Mueller wrote:
 
> The iterators are required to maintain a second independent sort order,
> that only needs a linked list because it only requires the operations
> pop_front and push_back.
 
What would your container contain if it only had one element? IOW, what
happens when it goes from empty to ??? upon the first insertion?
 
V
--
I do not respond to top-posted replies, please don't ask
woodbrian77@gmail.com: Apr 27 07:35PM -0700

On Monday, April 27, 2015 at 6:11:42 PM UTC-5, Christopher Pisz wrote:
 
> Do we mean he know he doesn't need to put :: before std, but does it
> anyway because of some sort of OCD-ed-ness? Just because he knows the
> std namespace is global?
 
He may wish to avoid a situation like this:
 
namespace ha {
namespace std {
 
template <class T>
class vector
{
int a;
};
 
}
}
 
using namespace ha;
 
void marshal ()
{
std::vector<int> n;
}
 
The author of code like that may be incompetent or malicious.
There are a lot of fakes these days.
 
Brian
Ebenezer Enterprises - Was Eisenhower the last decent President?
http://webEbenezer.net
"Öö Tiib" <ootiib@hot.ee>: Apr 28 12:12AM -0700

> }
 
> The author of code like that may be incompetent or malicious.
> There are a lot of fakes these days.
 
 
Someone who hides global name 'std' locally deserves every
nuisance that was achieved that way. It is pointless to protect
against. Loss of such customer is actually a victory.
Luca Risolia <luca.risolia@linux-projects.org>: Apr 28 09:38AM +0200

> std::vector<int> n;
> }
 
> The author of code like that may be incompetent or malicious.
 
The author of code like that would not go far enough. At least my g++
compiler gives an error:
 
main.cpp: In function 'void marshal()':
main.cpp:17:3: error: reference to 'std' is ambiguous
std::vector<int> n;
Ian Collins <ian-news@hotmail.com>: Apr 29 07:09AM +1200

> {
> std::vector<int> n;
> }
 
Which happens how often in code snippets posted to Usenet? Or how often
in any sane C++ project?
 
The colons aren't pedantic, they are total superfluous clutter.
 
> The author of code like that may be incompetent or malicious.
> There are a lot of fakes these days.
 
Fake standard headers on a developer's machine?
 
--
Ian Collins
drew@furrfu.invalid (Drew Lawson): Apr 28 07:56PM

In article <cqa47bFk643U2@mid.individual.net>
 
>> The author of code like that may be incompetent or malicious.
>> There are a lot of fakes these days.
 
>Fake standard headers on a developer's machine?
 
This is a common paranoid mindset these days.
 
In the last couple days a resident loon in another group claimed
(while losing an argument) that you can't trust Google search
results. You see, they are *really* an evil conspirator backing
$OtherSide of $PoliticalTopic.
 
This even though the topic wasn't very political. But still, you
know, They are out to perpetrate fraud everywhere possible -- even
in Brian's header files.
 
--
Drew Lawson | Though it's just a memory,
| some memories last forever
Juha Nieminen <nospam@thanks.invalid>: Apr 28 01:23PM

> int main() { int && i = ::std::move( 3 ); ::std::cout << i << '\n'; }
 
There is no difference between "something = std::move(something_else)"
and "something = something_else" when that type has no move constructor.
 
As for having a reference to a temporary, the temporary will exist for
as long as the reference (ie. the current scope).
 
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
"Öö Tiib" <ootiib@hot.ee>: Apr 28 12:37PM -0700

On Tuesday, 28 April 2015 16:23:14 UTC+3, Juha Nieminen wrote:
> > int main() { int && i = ::std::move( 3 ); ::std::cout << i << '\n'; }
 
> There is no difference between "something = std::move(something_else)"
> and "something = something_else" when that type has no move constructor.
 
'std::move' just returns a rvalue reference to its argument
and the "something" is rvalue reference so no constructors were
called in the process?
 
> As for having a reference to a temporary, the temporary will exist for
> as long as the reference (ie. the current scope).
 
Yes, that is true, so sane compiler just optimized the bloat away and
made "std::cout << 3 << '\n';" out of it.
ram@zedat.fu-berlin.de (Stefan Ram): Apr 28 12:47AM

I have found an implementation that prints »3« when given
the following programs. Is this defined behavior? If so,
would someone like to comment on what is happening?
 
#include <iostream>
int main() { int && i = ::std::move( 3 ); ::std::cout << i << '\n'; }
 
#include <iostream>
int main() { int && i = 3; ::std::cout << i << '\n'; }
 
Is storage for an int object allocated sometime during the
execution of this code?
 
Another program:
 
#include <iostream>
 
int main()
{ int j = 4;
int && i = ::std::move( j );
::std::cout << i << '\n'; }
ram@zedat.fu-berlin.de (Stefan Ram): Apr 28 03:54PM

>>. (Maybe you are still using the old C++14? C++14 did
>>not have concepts. But we are living in 2015 now!)
>What is the post-C++14 released standard?
 
It is not released as a standard yet, but the web page
about the concept »Compare« that I gave might help the
OP to learn what kind of type is expected in his code,
and something similar might become part of C++17 or C++2x.
Ian Collins <ian-news@hotmail.com>: Apr 28 08:29PM +1200

> And when I search the sendfile man page for compression, I
> get "Pattern not found." Compression is important for what
> I'm working on.
 
So use compression on your connection. sendfile(2) is exactly what the
original scungy C code was trying to emulate.
 
--
Ian Collins
woodbrian77@gmail.com: Apr 28 08:21AM -0700

On Tuesday, April 28, 2015 at 3:29:16 AM UTC-5, Ian Collins wrote:
> > get "Pattern not found." Compression is important for what
> > I'm working on.
 
> So use compression on your connection.
 
You may want compression for some messages but not
for others. It looks like ICE has support for that:
 
https://doc.zeroc.com/display/Ice/Protocol+Compression
 
The C++ Middleware Writer (CMW) doesn't have support for that
yet, but it's something that I'd like to add. My middle
tier sends 3 types of messages to the CMW: a login message,
a keepalive message and a generate message. Ideally the login
and keepalive messages wouldn't be compressed.
 
As the ICE page mentions, small messages are poor candidates
for compression. Using compression on such messages has
the opposite of the desired effect: rather than saving on
bandwidth, you wind up using more. Why pay for compression
and bandwidth that you don't need?

 
Brian
Ebenezer Enterprises - So far G-d has helped us.
http://webEbenezer.net
drew@furrfu.invalid (Drew Lawson): Apr 28 02:21PM

In article <Compare-20150427220223@ram.dialup.fu-berlin.de>
 
> . (Maybe you are still using the old C++14? C++14 did
> not have concepts. But we are living in 2015 now!)
 
What is the post-C++14 released standard?
 
 
--
Drew Lawson While they all shake hands
and draw their lines in the sand
and forget about the mess they've made
Paavo Helde <myfirstname@osa.pri.ee>: Apr 27 11:20PM -0500

Doug Mika <dougmmika@gmail.com> wrote in
 
> template<class Compare>
 
> in front of it? What does this represent? What does it indicate in
> the instance of std::list.sort(comp)?
 
Why, you already said yourself it is a member function template:
 
> I have never heard
> of class member functions themselves being template member functions.
 
Yes, the class which it is a member of is a class template itself, so
what? And as with all template parameters of the 'class' or 'typename'
type, it means it needs to be instantiated with some suitable type.
 
std::list<A> myList; // Class instantiated with type A.
B b;
myList.sort<B>(b); // Member fn instantiated with type B.
 
(Here, <B> is usually omitted in real code as the compiler is typically
able to deduce it easily from the type of passed argument b, but one can
specify it explicitly as well).
 
hth
Paavo
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: