Monday, July 30, 2018

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

ram@zedat.fu-berlin.de (Stefan Ram): Jul 30 10:46PM

>void PrintFirstOf(const Container& c)
>{
> typename Container::value_type v = std::get<0>(c);
 
Good idea, I will use this one, albeit a little later, in a
lesson dedicated to parameters of user-defined types. Thank
you!
 
>As a side effect it would be probably good to add here some
>assurance that the size oft he array is > 0
 
Yes. But the expression with »::std::get< 0 >« (from my
original program) already is quite close to this:
 
main.cpp
 
#include <array>
int main() { ::std::array< int, 0 >a; ::std::get< 0 >( a ); }
 
transcript
 
compiler error: static assertion failed: array index is within bounds
 
.
Sam <sam@email-scan.com>: Jul 30 05:58PM -0400

Stefan Ram writes:
 
> better way? (Since this is intended to show off »value_type«,
> »value_type« should appear in the answer. So, »auto v = ...«
> would not be helpful.)
 
I know of no other way to reference the type of the values in a container,
other than it's value_type.
 
As an aside when one's "drafting a lesson": it's true that it's useful to
point out why someone might want to explicitly specify "::std" in this
manner; as well as go over what "::std::this" or "::std::that" means, and
point out what this does, and why. But overusing the double-colons like that
makes C++ look like bad Perl.
 
I happen to like Perl. And I use Perl. And there's nothing wrong with Perl,
but there's everything wrong with bad Perl. And "::std::this" and
"::std::that" makes the whole thing, above, look like bad Perl or the C++
version of the obfuscated C context, and the most it would accomplish is
make everyone's eyes bleed.
 
So let's just stick to simply "std::this" or "std::that", to make the end
result look like elegant C++ (and using sensible identation would also be a
plus). This will still be free of the "using namespace std;" annoyance, but
without going to the other extreme of spraying "::" everywhere, merely to
show off one's pedantic understanding of C++, but also making the resulting
code more convoluted than it needs to be.
Manfred <invalid@add.invalid>: Jul 31 12:26AM +0200

On 07/30/2018 11:18 PM, Stefan Ram wrote:
> better way? (Since this is intended to show off »value_type«,
> »value_type« should appear in the answer. So, »auto v = ...«
> would not be helpful.)
 
things like value_type are most useful with template (meta)programming,
so it could be useful to show its use with template type arguments,
instead of decltype:
 
 
#include <array>
#include <initializer_list>
#include <iostream>
#include <ostream>
#include <string>
 
using namespace ::std::literals;
 
template<typename Container>
void PrintFirstOf(const Container& c)
{
typename Container::value_type v = std::get<0>(c);
 
std::cout << v << std::endl;
}
 
int main()
{
{
::std::array const a{ 4, 2, 7 };
PrintFirstOf(a);
// decltype( a )::value_type v = ::std::get< 0 >( a );
// ::std::cout << v << '\n';
}
 
{
::std::array const a{ "alpha"s, "gamma"s, "delta"s };
PrintFirstOf(a);
// decltype( a )::value_type v = ::std::get< 0 >( a );
// ::std::cout << v << '\n';
}
}
 
As a side effect it would be probably good to add here some assurance
that the size oft he array is > 0
jacobnavia <jacob@jacob.remcomp.fr>: Jul 31 12:05AM +0200

> Here's a link to a cloud-based IDE
> https://codetasty.com/
 
I followed that link, and I thought that I arrived to some tutorial or
similar. So I clicked into "Get started"
 
A window appears that asks for my email. In general I do not like to put
my email anywhere and give people more opportunities to send me spam, so
I tried to close that, but it is impossible. The programmer didn't put a
close button or something to get out of that window.
 
Of course I can close it with closing the tab in the navigator, what I
did. Then reloaded the page and started looking at something that could
tell me what this software does...
 
I scrolled down and read:
 
<quote>
Real-time language tools
that make you smarter
<end quote>
 
Yeah smarter, of course I need that tool, dumb as I am...
 
Then:
 
<quote>
Our IDE helps you write readable and clean code the smarter way - in
real time.
<end quote>
 
Sure, vi does that too. I write code in vi in real time, and after I
type something, I see immediately what I type. In real time. Gone are
the old days when I waited in some editor, for the characters that I
type to appear in the screen. All editors are real time now.
 
This one has PHP code completion, a feature the author is very proud of.
Animations in the screen show you typing and code completion at work.
 
This "IDE" is then actually a PHP editor with code completion.
 
There is no word of a debugger, advanced syntactic search possibilities
whatever. No trace of an IDE.
 
It can handle, as it says, files of hundred thousand lines or even more.
Great.
 
Vim does that too.
 
Or emacs, or visual studio or whatever.
 
<quote>
What makes us top-notch
<end quote>
 
Yeah, I wonder... WHAT?
 
<quote>
No Setup
<end quote>
 
No setup?
 
How can I tell it to display tabs at 6 positions? I would like to know.
And please, not 4, not 8, but 6. OK?
 
I took the link because you cited King. That was disconcerting enough to
be worth a click.
 
But using M. L. King to sell a PHP editor?
 
Wait a minute man. Have more respect for black people ok?
 
Do not USE them in your marketing stuff.
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: