Thursday, November 20, 2014

Digest for comp.lang.c++@googlegroups.com - 8 updates in 6 topics

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
"A" <a@a.a>: Nov 20 09:32PM +0100

In this particular example:
 
int TForm1::TestOfFinally()
{
int i = 111;
std::vector<int> aa;
 
aa.push_back(123);
 
try
{
return i;
}
__finally
{
Application->MessageBox(IntToStr((int)aa.size()).c_str(), L"Info",
MB_OK | MB_ICONINFORMATION);
}
}
 
aa.size() is 0 as it goes out of scope after return i; in try part of the
block.
 
Isn't __finally supposed to keep variables in scope until it finishes?
 
If return i; is removed (or moved after the __finally block), the message
box shows 1 instead of 0 as above for vector size.
 
The above example is in C++ Builder 2010.
Paavo Helde <myfirstname@osa.pri.ee>: Nov 20 04:39PM -0600

> return i;
> }
> __finally
 
The C++ standard does not contain word "__finally". The identifiers
containing double underscores are reserved for implementations, so this is
most probably some kind of extension provided by your particular C++
implementation (and if I am not mistaken, it is probably meant to be used
together with __try, not try). Maybe it would work better with __try, who
knows.
 
The "finally" thing is used as a poor substitute for RAII in languages
which are lacking it. In C++ we have RAII and proper destructions (and
things like ScopeGuard if one is too lazy to write a helper class with a
destructor), so it baffles me why somebody would ever need functionality of
"finally" in C++, it is just inferior in every sense IMO.
 
Cheers
Paavo
"Charles J. Daniels" <chajadan@gmail.com>: Nov 19 11:33PM -0800

> directive issued inside the Library is equivalent to a series of using
> declarations, one for each name contained inside the Inner namespace (e.g.,
> using Inner::Int32; using Inner::Char8; etc.)?
 
I don't have the exact answer you seek, but the process is called "name lookup" and I really liked this video about it: http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-1-of-n
Bix <spam@nothing.invalid>: Nov 20 09:58PM +0100

> directive issued inside the Library is equivalent to a series of using
> declarations, one for each name contained inside the Inner namespace (e.g.,
> using Inner::Int32; using Inner::Char8; etc.)?
Hi,
I may be wrong but I think that the rule that happy is
 
7.3.4.2 [namespace.udir]
A using-directive specifies that the names in the nominated namespace can be used in the scope in which the
using-directive appears after the using-directive. During unqualified name lookup (3.4.1), the names appear
as if they were declared in the nearest enclosing namespace which
contains both the using-directive and the nominated namespace.
 
 
So the unqualified lookup of Int32 foun Library::Inner::Int32.
 
cheers
bix
red floyd <no.spam@its.invalid>: Nov 17 09:29AM -0800

On 11/15/2014 1:33 AM, Dombo wrote:
> Some publishers, like Manning, add a coupon with a code to their paper
> books that allows you to download the electronic version for free so you
> get the best of both worlds.
 
I just read this morning about the latest Kindle which will let you
(metaphorically) stick your finger between the pages while flipping
back or forward to look at something else.
 
Still doesn't change my opinion on e-books, though.
Alain Ketterlin <alain@dpt-info.u-strasbg.fr>: Nov 14 09:21AM +0100

JiiPee <no@notvalid.com> writes:
 
[...]
> version by using 40000 look-up table converting four integers: like
> 4691 -> '4' '6' '9' '1' . I just implemented it, and it makes it even
> faster! I call it intToStrSuperFast.
 
Make it an array of 4 billion entries of length 10, and you get a
constant time int-to-string conversion! OK, I'm kidding.
 
> _snprintf (VC2008) : 112 s (+3179%)
> _snprintf (VC2010) : 140 s (+3999%)
> _itoa (VC2008) : 36.9 s (+980%)
 
There is something really wrong with your snprintf.
 
Anyway, comparing with snprintf to compare conversion time doesn't mean
much:
 
- your function is a specialized, inline routine, that get optimized at
compile time inside a loop (i.e., it may be unrolled, etc.), and since
you're building an executable and your function is declared inline,
even if it is not actually inlined the compiler is not required to
respect the ABI (this may lead to dramatic improvement on
register-starved archs like x86, especially for functions with 2
parameters).
 
- snprintf is a general, variable-argument, library routine, and the
compiler doesn't even see it. It has probably been compiled
conservatively, to work on any processor sold in the last 10 years or
so.
 
My guess is that you are measuring the overhead of the call, much more
than the conversion time itself. If you want something more useful, make
your function parameters var-arg, use a va_list to pop data, compile
this into a shared-library (with no arch-specific optimization), rewrite
your main to use this, link against the shared-lib.
 
Then, measure and compare. You'll still win (because there is no format
sting to parse, etc), but I would be surprised if the difference were
significant.
 
-- Alain.
Ian Collins <ian-news@hotmail.com>: Nov 17 08:25AM +1300

Mark wrote:
> str << stream.rdbuf() ;
 
> I'd like to determine the size of the istream object before
> extraction with rdbuf(). How can I achieve this.
 
Not all sources have a known size.
 
--
Ian Collins
JiiPee <no@notvalid.com>: Nov 13 11:33AM

On 13/11/2014 11:22, Stephen wrote:
> of the library. Although it is printed on paper slightly thinner that
> toilet paper !
 
> Stephen
 
Ok the thing is that I am looking for as detailed book as possible,
because I know the basics. I want to go a bit deeper.
 
"The C++ Standard Library" by Josuttis.
Yes, am also planning to buy that. And now they have c++11 version of
it. But thats what am after now.... heavy weight. So I also want a heavy
weight C++11 language book.
 
Would be nice to have a book having details what happens in memory when
using different features etc. But not sure if that book exists. But I
like Bjarnes detailed writing.
 
I ll check that "C++ Primer"... would be good if could first read it in
a library before buying.
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: