Friday, June 17, 2016

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

woodbrian77@gmail.com: Jun 17 04:10PM -0700

"Middleware-as-a-service" will continue to disrupt the market for traditional middleware in 2016
 
http://www.reseller.co.nz/article/590705/middleware-as-a-service-turns-enterprise-integration-its-head/
 
 
Brian
Ebenezer Enterprises - "The Stone the builders rejected has
become The Cornerstone." Psalms 118:22
 
http://webEbenezer.net
Stanimir Stamenkov <s7an10@netscape.net>: Jun 18 01:52AM +0300

Mon, 6 Jun 2016 08:42:02 -0400, /Jerry Stuckle/:
 
> Yes, by not following the RFC's and then complaining about others, you
> are behaving as an asshole.
 
> See https://www.ietf.org/rfc/rfc3676.txt section 4.3.
 
This doesn't mandate everyone should use this signature separator.
It has its uses mainly for signatures which include more than simple
name, and spread two or more lines. One may sign using any of:
 
- Name
/Name
-- Name
 
or another style. I think you're just being rude, lazy, or just
ignorant by not stripping it yourself (if the reader doesn't or
can't do it automatically for you), just like you should trim quotes
to a sane minimum, and that can't be automatic.
 
--
Stanimir
MikeCopeland <mrc2323@cox.net>: Jun 17 11:02AM -0700

I'm confused about string::reverse_iterator usage.
What I'm trying to do is scan the end of a string variable for all
numeric digits..and then convert those digits to an integer. For
example, I have;
std::string myData = "cldat89";
and I want to extract and convert the "89" to an integer variable.
Various explanations I've found via Google aren't making sense to me,
as they mostly assume I want to reverse the whole string data or such.
I just want to scan backwards (from last-to-first) until a character
_isn't_ a digit...and then be able to work with the substring of the
digit characters.
Although done this task "brute-force", the concept of
reverse_iterator seemed interesting, so I wanted to try it: so far, I
don't "get it". Please advise. TIA
 
 
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
legalize+jeeves@mail.xmission.com (Richard): Jun 17 06:23PM

[Please do not mail me a copy of your followup]
 
MikeCopeland <mrc2323@cox.net> spake the secret code
 
> std::string myData = "cldat89";
>and I want to extract and convert the "89" to an integer variable.
 
A reverse iterator is not needed:
 
1 #include <iostream>
2 #include <string>
3
4 int main()
5 {
6 std::string s{"cldata89"};
7 auto pos = s.find_last_not_of("0123456789");
8 int val = std::stoi(s.substr(pos + 1));
9 std::cout << val << '\n';
10 return 0;
11 }
 
> g++ --std=c++11 /tmp/a.cpp
> ./a.out
89
 
However, for the purposes of education, a reverse iterator simply
traverses a container in the opposite order of a forward iterator.
I think cppreference.com does a good job of explaining it:
<http://en.cppreference.com/w/cpp/iterator/reverse_iterator>
--
"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>
Victor Bazarov <v.bazarov@comcast.invalid>: Jun 17 02:29PM -0400

On 6/17/2016 2:02 PM, MikeCopeland wrote:
> Although done this task "brute-force", the concept of
> reverse_iterator seemed interesting, so I wanted to try it: so far, I
> don't "get it". Please advise. TIA
 
When you "scan backwards", remember that the characters come in the
reverse order. So, something like this is supposed to work:
 
int accumulator(0);
int multiplier(1), maxnumber(100000);
std::locale defloc;
for (auto it = myData.rbegin();
it != myData.rend() && multiplier < maxnumber;
++it, multiplier *= 10)
{
char c = *it;
if (std::isdigit(c, defloc))
accumulator += (c - '0') * multiplier;
else
break;
}
 
(I didn't actually test this, but it should give you an idea).
 
V
--
I do not respond to top-posted replies, please don't ask
maykov@gmail.com: Jun 16 07:26PM -0700

On Friday, December 12, 1997 at 12:00:00 AM UTC-8, Alexey Maykov wrote:
> because square brackets is the kind of the komment symbol in the ansi c
> standard, but VC++5.0 gives a compile error.
> So, the question is, does the man wrong, or i did something wrong ?
 
Here is what that man said:
 
a[5] is the same as 5[a]
Robert Wessel <robertwessel2@yahoo.com>: Jun 16 11:29PM -0500

>> So, the question is, does the man wrong, or i did something wrong ?
 
>Here is what that man said:
 
>a[5] is the same as 5[a]
 
 
It's not true for declarations, so "int 10[a]" doesn't work. OTOH,
when you access an array, you can write:
 
a[10] = 3;
 
-or-
 
10[a] = 3;
 
and accomplish the same thing. That's because the array accessor
essentially decays into a pointer expression. IOW, the two above
lines are equivalent to:
 
*(a+10) = 3;
 
-and-
 
*(10+a) = 3;
 
The later form ("10[a]") is primarily used to confuse newbies.
 
But it's in no way a comment.
David Brown <david.brown@hesbynett.no>: Jun 17 09:51AM +0200

>> So, the question is, does the man wrong, or i did something wrong ?
 
> Here is what that man said:
 
> a[5] is the same as 5[a]
 
True (within the right context). But that was considered an unfortunate
quirk of the language and very bad style 20 years ago when this thread
was started - it is even more so now.
 
It is good to be helpful and try to answer questions on Usenet, but I
doubt that the OP here has been holding his breath for the last two
decades, waiting for an answer!
Ian Collins <ian-news@hotmail.com>: Jun 17 10:47PM +1200

> On Friday, December 12, 1997 at 12:00:00 AM UTC-8, Alexey Maykov wrote:
 
Time travel again...
 
--
Ian
Real Troll <real.troll@trolls.com>: Jun 17 06:21PM +0100

On 17/06/2016 08:51, David Brown wrote:
> It is good to be helpful and try to answer questions on Usenet, but I
> doubt that the OP here has been holding his breath for the last two
> decades, waiting for an answer!
 
He must have died by now!!!!!!!!!!
legalize+jeeves@mail.xmission.com (Richard): Jun 17 05:35PM

[Please do not mail me a copy of your followup]
 
As others have already mentioned swapping the name of an array and
it's index may be valid syntax, but it is not recommended. Just because
something is allowed doesn't mean it's a good idea.
 
maykov@gmail.com spake the secret code
 
>Here is what that man said:
 
>a[5] is the same as 5[a]
 
For expressions in the C language, yes.
 
1 #include <stdio.h>
2
3 int main()
4 {
5 int a[1] = { 0 };
6 0[a] = 10;
7 printf("%d\n", a[0]);
8 return 0;
9 }
 
> gcc /tmp/a.c
> ./a.out
10
 
For expressions in the C++ language, no.
 
1 #include <iostream>
2 #include <vector>
3
4 int main()
5 {
6 std::vector<int> a(1);
7 0[a] = 10;
8 std::cout << a[0] << '\n';
9 return 0;
10 }
 
> g++ /tmp/a.cpp -o a2.out
/tmp/a.cpp: In function 'int main()':
/tmp/a.cpp:7:4: error: no match for 'operator[]' (operand types are 'int' and 'std::vector<int>')
0[a] = 10;
^
--
"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>
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: