- What is '!cin'? - 4 Updates
- apply function and operator - 2 Updates
- C++ needs some help - 1 Update
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 01 08:35AM +0100 On 10/31/2015 3:54 PM, Richard Damon wrote: [snip] > istreams define a member operator!() which is the equivalent to calling > fail() to see if something has gone wrong with the stream (like it > couldn't extract a string s1) Roughly, but the details are a bit different. C++ streams define conversion to boolean, and applying the built-in "!" operator invokes that conversion. In C++98 this was an implicitly invokable conversion to "void*". In C++11 and later it's an "explicit" conversion to "bool", with special rules that allow such a conversion to be implicitly invoked in a context requiring a "bool". C++14 §4/4 «Certain language constructs require that an expression be converted to a Boolean value. An expression e appearing in such a context is said to be /contextually converted/ to bool and is well-formed if and only if the declaration bool t(e); is well-formed, for some invented temporary variable t (8.5).» Essentially, writing "!stream" is equivalent to writing "stream.fail()". Worth noting, that "stream.good()" is not the opposite of "stream.fail()", and that the conversion to boolean is based on "fail()". Cheers, - Alf |
fl <rxjwg98@gmail.com>: Nov 01 10:59AM -0800 On Sunday, November 1, 2015 at 2:35:28 AM UTC-5, Alf P. Steinbach wrote: > "stream.fail()", and that the conversion to boolean is based on "fail()". > Cheers, > - Alf Great thanks. I use MSVC 2010. What version is it, C++11, or C++14? How can I know that? |
fl <rxjwg98@gmail.com>: Nov 01 11:02AM -0800 On Sunday, November 1, 2015 at 2:35:28 AM UTC-5, Alf P. Steinbach wrote: > "stream.fail()", and that the conversion to boolean is based on "fail()". > Cheers, > - Alf I am a little confused about the description. "!stream" is an explicit type or an implicit type? Thanks, In C++11 and later it's an "explicit" conversion to "bool", with special rules that allow such a conversion to be implicitly invoked in a context requiring a "bool". |
Paavo Helde <myfirstname@osa.pri.ee>: Nov 01 02:46PM -0600 fl <rxjwg98@gmail.com> wrote in > Great thanks. I use MSVC 2010. What version is it, C++11, or C++14? > How can I know that? http://en.cppreference.com/w/cpp/compiler_support In this table, MSVC2010 appears as MSVC 10.x (see https://en.wikipedia.org/wiki/Visual_C%2B%2B). It does indeed contain some C++11 features, but not the "Explicit conversion operators" feature discussed in this thread. hth Paavo |
asetofsymbols@gmail.com: Nov 01 01:13AM -0800 Wouter wrote: google "c++ lambda" Wouter ------- I find in internet some example of anonymous function in C++ In our example will be something as x.apply( u32 (u32 z)[](2*z) ) or something as above: But I think the matlab way is better x.apply( @(z) 2*z ) Because is more short: Will be the compiler find the right function: if there are 2 or more functions that are ok than not compile and add type in function For me the best would be x.apply(2*α) Where α is a variable... if one has 2 variables just write 2*α+β as (x,y)->(2*x+y) |
asetofsymbols@gmail.com: Nov 01 01:16AM -0800 First 10 Greek letters lowercase as argument for anonymous function |
woodbrian77@gmail.com: Oct 31 09:28PM -0700 On Saturday, October 31, 2015 at 12:22:52 PM UTC-5, Jorgen Grahn wrote: > > Alphabetical would be more logical. > However, what matters is what rules Wikipedia has around > such things. Either alphabetical or chronological would be an improvement. If Java supporters insist on a long, boring description, they should be willing to let shorter and sweeter descriptions be placed before them. |
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:
Post a Comment