- Determining endianess at compile time - 3 Updates
- Broad Question for C++ coders - 7 Updates
- Sorting strings - 3 Updates
- Name for an operator - 1 Update
- If a regex evaluates to true call a member function (C++14) - 1 Update
| Juha Nieminen <nospam@thanks.invalid>: May 18 09:39AM > return overlay{ 1 }.b.a; } > int main() > { ::std::cout << "endian()" << " = " << endian() << '\n'; } test.cc:2:16: error: constexpr function never produces a constant expression [-Winvalid-constexpr] constexpr bool endian() ^ test.cc:5:23: note: read of member 'b' of union with active member 'i' is not allowed in a constant expression return overlay{ 1 }.b.a; } --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
| scott@slp53.sl.home (Scott Lurndal): May 18 01:45PM >I didn't find an approach I liked so I rely on users to read=20 >the documentation and set -DCMW_BIG_ENDIAN if necessary. From >what I can tell, big-endian systems are fading from the landscape. Not true at all. Consider that network byte-order is big-endian, and you'll see why big-endian is still quite popular in networking applications (routers, switches, security appliances, etc). Note that the new ARM64 processor is capable of operating in either (or both) endiannesses. |
| woodbrian77@gmail.com: May 18 12:15PM -0700 On Monday, May 18, 2015 at 8:45:56 AM UTC-5, Scott Lurndal wrote: > applications (routers, switches, security appliances, etc). Note > that the new ARM64 processor is capable of operating in either > (or both) endiannesses. That might be interesting if it were a big-endian only device. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
| Sam <sam@email-scan.com>: May 17 08:07PM -0500 > removed ? (in a sense of not just not having to use a feature or a paradigm, > but also not having to deal with it or consider it's use by others) > Thanks When is his homework assignment due? What class is this, where you get questions like this, leading up to your final exams? |
| woodbrian77@gmail.com: May 17 06:35PM -0700 > Hope everyone for a nice weekend, > Defining programmers as those who authored any amount of C++ code that made it into production environment - > If you could add one thing - anything at all - to the core language or the new standard, what would it be ? I mentioned this in another thread, but I'd like to see a ctor added to std::string that takes a char const* and an integer value. The integer would be the length to reserve beyond the length of the char const*. I think this ctor would help to reduce the number of allocations strings do. It's surprising to me that this wasn't added years ago. Better late than never. I look forward to modules being added. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
| Paavo Helde <myfirstname@osa.pri.ee>: May 17 11:28PM -0500 udtelco@gmail.com wrote in > like to see removed ? (in a sense of not just not having to use a > feature or a paradigm, but also not having to deal with it or consider > it's use by others) 1. Portable C++ ABI (something along the lines of e.g. https://isocpp.org/files/papers/n4028.pdf) 2. Automatic conversions (numeric-to-bool, enum-to-numeric, numerics themselves (though the last one is tricky, just slapping an explicit static_cast everywhere where a conversion is required would make the things even worse)). |
| udtelco@gmail.com: May 17 09:57PM -0700 On Sunday, May 17, 2015 at 9:07:34 PM UTC-4, Sam wrote: > When is his homework assignment due? What class is this, where you get > questions like this, leading up to your final exams? Who is "he", and what's bothering you so much about this question ? And do you always stick an attachment into your contribution to this global museum of wisdom and tolerance ? |
| Christopher Pisz <nospam@notanaddress.com>: May 18 10:15AM -0500 > If you could add one thing - anything at all - to the core language or the new standard, what would it be ? > And in a same way, but trickier, what if anything would you like to see removed ? (in a sense of not just not having to use a feature or a paradigm, but also not having to deal with it or consider it's use by others) > Thanks Add: datetime more like boost's timezone not like boost's exceptions with call stack built in ability to see "who started the thread" when debugging naming of threads Remove: globals goto variadic argument lists C -- I have chosen to troll filter/ignore all subthreads containing the words: "Rick C. Hodgins", "Flibble", and "Islam" So, I won't be able to see or respond to any such messages --- |
| Victor Bazarov <v.bazarov@comcast.invalid>: May 18 11:23AM -0400 On 5/18/2015 11:15 AM, Christopher Pisz wrote: > Remove: > [..] > C That way we'll end up with the language called "++", which is neither here nor there. ;-) V -- I do not respond to top-posted replies, please don't ask |
| "Jason C. McDonald" <indeliblebluepen@nospam.invalid>: May 18 11:39AM -0700 On 05/18/2015 08:23 AM, Victor Bazarov wrote: > That way we'll end up with the language called "++", which is neither > here nor there. ;-) > V So...we once had the attack of the one-letter languages. Now we'll have the attack of the non-alphanumeric languages? ++ -- (for the minimalists) ?? (for absolutely beginners) !! (for quick-and-dirty programming by people who reject all standards) !%#*&@^ (for irritating the heck out of people) -- Jason C. McDonald (CodeMouse92) [CEO, Lead Dev @ MousePaw Games] |
| udtelco@gmail.com: May 17 09:45PM -0700 I would like to have sort function for strings that would first compare length and have longer string be greater then shorter one, and if they are same length - compare them as usual. So that 1. "1234567" 2. "12345" 3. "111111" 4. "13456" 5. "01102121" would get sorted as 5 > 1 > 3 > 4 > 2 bool less(const string& lhs, const string&rhs) { // if( lhs.length() < rhs.length() ) return true; return (lhs.length() < rhs.length()) ? true : (lhs < rhs); } Is there a more efficient way to do this ? Thank you dear newsgroup. |
| "Öö Tiib" <ootiib@hot.ee>: May 17 11:16PM -0700 > // if( lhs.length() < rhs.length() ) return true; > return (lhs.length() < rhs.length()) ? true : (lhs < rhs); > } So both 'less( "1234567", "13456" )' and 'less( "13456", "1234567" )' return 'true'? > Is there a more efficient way to do this ? Why you care about efficiency when your algorithm seems incorrect? Most important goal is always correctness since no one needs software that gives incorrect answers more quickly. |
| Juha Nieminen <nospam@thanks.invalid>: May 18 09:46AM > // if( lhs.length() < rhs.length() ) return true; > return (lhs.length() < rhs.length()) ? true : (lhs < rhs); > } That doesn't work because if lhs is larger than rhs, then they won't be compared by length. What you want is: return (lhs.length() == rhs.length()) ? (lhs < rhs) : (lhs.length() < rhs.length()); The compiler will most probably optimize those extra length() calls away, so there's usually no need to worry about them. (And even if it doesn't, it's not a big deal anyway.) --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
| legalize+jeeves@mail.xmission.com (Richard): May 18 02:39AM [Please do not mail me a copy of your followup] Paul <pepstein5@gmail.com> spake the secret code >struct A { > operator B(); >}; struct A is defining a conversion operator so that it can be converted into a struct B. This enables the following: A a; B b1 = a; // implicit conversion B b2 = static_cast<B>(a); // explicit conversion If you change to: struct B; struct A { explicit operator B(); }; A a; B b1 = a; // error: implicit conversion not allowed B b2 = static_cast<B>(a); // OK: explicit conversion -- "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> |
| legalize+jeeves@mail.xmission.com (Richard): May 18 02:30AM [Please do not mail me a copy of your followup] Chicken Mcnuggets <chicken@mcnuggets.com> spake the secret code >and this is what I was roughly hoping to emulate. The URL regex and the >views are provided by the user and the framework provides the code to >link the two together. I'm familiar with Django and how it maps URLs to views. There are a number of ways to orchestrate the C++ equivalent. For instance: class IView { public: virtual ~IView() {} // user implements this virtual void render() = 0; }; std::map<std::string, std::unique_ptr<IView>> viewMapping; Really, you want to define an abstraction for your C++ customers to implement so that you are employing Dependency Inversion Principle and eliminating unnecessary coupling. Their callback handler is a detail that depends on an abstraction (IView). Your regex->handler dispatcher is a detail that depends on an abstraction (IView). You publish the IView interface for your clients to implement. -- "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:
Post a Comment