- Why "::std"? - 5 Updates
- What is std::nan can be used for? - 2 Updates
- What is std::nan can be used for? - 1 Update
- How to write this function about implicit declarations? - 1 Update
Christian Gollwitzer <auriocus@gmx.de>: Nov 29 07:40AM +0100 Am 28.11.17 um 08:25 schrieb Juha Nieminen: > code harder to read. I have yet to see any of them giving a good > argument why. They just don't like it... because they don't like > it, period. No good reason. It's partly a matter of taste, but for math functions I'd say that std:: is confusing. Compare: (std::sin(q*r) + q*r*std::cos(q*r)) / std::exp(-q*std::pow(r,2)) (sin(q*r) + q*r*cos(qr)) / exp(-q*pow(r,2)) The second one is not only shorter, but closer to the formula as you read it in textbooks and papers. And if you want to substitute the type, e.g. for automatic differentiation, you need to drop th std:: because the functions are overloaded outside of std::. What is the correct way to do that? Include "math.h" instead of cmath? using std::sin; using std::cos; ... ? Actually, I'd love to have using std::mathfunctions; which import the basic trigonometric functions. Christian |
David Brown <david.brown@hesbynett.no>: Nov 29 09:19AM +0100 On 28/11/17 19:34, Öö Tiib wrote: > fully qualified name of any name x of standard library is ::std::x unless explicitly described otherwise. > Usage of the name std for anything can in practice still get ones work > contract ended as deliberately confusing others and hampering team-work. As far as I can see, the standards put restrictions on the global namespace "std" (or "::std") and namespaces nested within it, but not on namespaces called "std" that are nested within other namespaces. The (global) namespace "posix" is also reserved from use by user code. |
Gareth Owen <gwowen@gmail.com>: Nov 29 07:30PM > As Alf says, no one names a namespace `std`. Well, I've been commissioned to write an app for a clap clinic |
"Öö Tiib" <ootiib@hot.ee>: Nov 29 12:16PM -0800 On Wednesday, 29 November 2017 21:30:46 UTC+2, gwowen wrote: > Ian Collins <ian-news@hotmail.com> writes: > > As Alf says, no one names a namespace `std`. > Well, I've been commissioned to write an app for a clap clinic If you are one of those who religiously calls "sexually transmitted infections" as STD and wants separate namespace for those ... then perhaps write your app in Java. :p |
legalize+jeeves@mail.xmission.com (Richard): Nov 29 10:48PM [Please do not mail me a copy of your followup] (Richard) legalize+jeeves@mail.xmission.com spake the secret code >>always being ungood. [...] >There's one case where I thought it was mandatory: allowing ADL to >select between your custom implementation of swap and std::swap. Maybe I misspoked there and you're supposed to do 'using std::swap;' and not 'using namespace std;'. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
"James R. Kuyper" <jameskuyper@verizon.net>: Nov 29 08:57AM -0500 On 11/29/2017 03:58 AM, Stefan Ram wrote: > |values of the IEEE Standard ... > BTW, did you guys know that ECMA-262 is a normative > reference of ISO 14882? What ECMA-262 has to say about it's Number type is relevant to C++ only in the context of <regex>, the only place where ECMA-262 is mentioned (and ECMA-262's Number type isn't mentioned directly anywhere). IEC 559 (== ANSI/IEEE 754) is the relevant standard, and even then, only if std::numeric_limits<T>::is_iec559 is true. |
Christian Gollwitzer <auriocus@gmx.de>: Nov 29 10:03PM +0100 Am 28.11.17 um 17:42 schrieb Alf P. Steinbach: > not and can still not rely on NaN != NaN, because when you ask the > compiler (e.g. g++, Visual C++) to optimize floating point operations > it's likely to optimize away that special behavior of NaN. How "old" a compiler are you talking about? I've used a!=a for ages to watch for NaN, and ordering the comparisons in a way that it does the right thing with a NaN (i.e. a > 5 vs. ! (a <= 5) ). Maybe if you use -ffast-math these things get optimized away, but I'm not convinced that this buys you so much that it is worth. Without -ffast-math you still have optimizations. I've also seen that mostly NaN became a slow path of execution. When all of the data became NaN, the whole computation slowed down by a factor of 2-3. Christian |
ram@zedat.fu-berlin.de (Stefan Ram): Nov 29 08:58AM >and sets Nan with a mantissa corresponding to processing this >string argument with a function strtod... >I only have one question ... Why would this be necessary ??? ECMA-262 says it in all its glory: |The Number type has exactly 18437736874454810627 (that is, |2^64-2^53+3) values, representing the double-precision 64-bit |format IEEE 754-2008 values as specified in the IEEE Standard |for Binary Floating-Point Arithmetic, except that the |9007199254740990 (that is, 2^53-2) distinct "Not-a-Number" |values of the IEEE Standard ... BTW, did you guys know that ECMA-262 is a normative reference of ISO 14882? |
David Brown <david.brown@hesbynett.no>: Nov 29 08:45AM +0100 On 28/11/17 17:57, James R. Kuyper wrote: >> long list of type attributes manually, when it is easy for them to make >> mistakes. The next is to have complex logic like Ben showed you needed, > Did you mean "James" rather than "Ben"? Yes I did - sorry about that. I don't know why I mixed your names up here (you both give good advice and good examples, so maybe I had just read another post by Ben). > actually compile and execute this code. > In principle, a conceptually similar function could play a useful role > in a compiler. I could understand that - but I am fairly confident that Stefan is not working on a compiler. Simply making a function as an alternative way to express the rules seems reasonable - perhaps to help with Stefan's teaching. However, if it is so hard to write the rules, I wonder if it actually helps. I think Stefan is the only one who could tell us. > members of the described class. If any one of the problematic cases > listed in the standard comes up during that iteration, the function is > implicitly declared as deleted. Designing this sort of thing in a compiler is not going to be an easy task! If /I/ were doing it, on a new compiler, I would try starting by implementing the basics of the new "metaclass" proposal, using an extra keyword "__class" instead of "class". "class" and "struct" can then be implemented as metaclasses - and the rules for which methods are created by the compiler, as well as a variety of warnings, can all be written in C++ with metaclasses, rather than in the compiler itself. |
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