- iomanip not working as i expect - 5 Updates
- [OT] Re: std::wstring considered useless - 6 Updates
- "C++11 threads, affinity and hyperthreading " - 1 Update
- problems with friends ... ;-) - 1 Update
- segmented_array et al now on GitHub - 1 Update
- Announce: SObjectizer-5.5.15 with friendship of actors and hierarchical state machines - 1 Update
Barry Schwarz <schwarzb@dqel.com>: Jan 20 12:11PM -0800 On Wed, 20 Jan 2016 18:13:46 GMT, scott@slp53.sl.home (Scott Lurndal) wrote: > You should be using snprintf :-) > char monthyearastext[5]; > snprintf(monthyearastext, sizeof(monthyearastext), "%2.2u%2.2u", month, year); For conversion specifier u, both field width and precision specify minimum values. Thus %2.2u will still convert year to a four-character value. However, since snprintf has been directed to output at most 4 characters, the last two characters of the converted year value will be discarded. Thus, the resulting string from the above code will be "0120" and not the desired "0116". -- Remove del for email |
scott@slp53.sl.home (Scott Lurndal): Jan 20 08:59PM >For conversion specifier u, both field width and precision specify >minimum values. Thus %2.2u will still convert year to a >four-character value. Odd. With %2.2s, it will only include two bytes from the string. I'd expected symmetry for integers. C'est la vie. strftime it is. e.g. #include <stdio.h> unsigned long long main() { char str1[] = "abcd"; char str2[] = "efgh"; printf ("%2.2s%2.2s\n", str1, str2); } $ cc -o /tmp/d /tmp/d.c $ /tmp/d abef $ |
Ben Bacarisse <ben.usenet@bsb.me.uk>: Jan 20 09:22PM > It's been an eon since I had to use these manipulators. I am not > getting the output I expected. I am looking for a 2 digit month next > to a 2 digit year. <snip> > << month > << std::setw(2) << std::setfill('0') << std::right > << year; You could simply use year % 100 here. <snip> -- Ben. |
Barry Schwarz <schwarzb@dqel.com>: Jan 20 03:01PM -0800 On Wed, 20 Jan 2016 20:59:29 GMT, scott@slp53.sl.home (Scott Lurndal) wrote: >>four-character value. >Odd. With %2.2s, it will only include two bytes from the string. I'd >expected symmetry for integers. C'est la vie. For integer conversions, precision specifies the minimum number of digits. For string "conversions," it specifies the maximum number of characters. It also has other meanings for various floating point conversions. -- Remove del for email |
legalize+jeeves@mail.xmission.com (Richard): Jan 20 11:26PM [Please do not mail me a copy of your followup] slp53@pacbell.net spake the secret code >Christopher Pisz <nospam@notanaddress.com> writes: >>Where am I going wrong? > You should be using snprintf :-) Yet your own example gets it wrong, which just serves to demonstrate why using printf-style functions is error-prone. Just the other day I found yet-another-occurrence of a printf-style varargs function being passed an object instead of a primitive type for a log message. The code compiled just fine, but of course results in absolute garbage when executed. I prefer mechanisms that fail at compile time when I write something non-sensical. (Yes, I know some more modern compilers can be configured to warn or error at such things. Do you know why? Because it is so easy to use this construct incorrectly that they attempt to compensate for it. This again just serves to demonstrate why it should be avoided.) -- "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> |
scott@slp53.sl.home (Scott Lurndal): Jan 20 08:54PM >> sourcing your application. >> (Which is why RMS hates the LGPL.) >[citation needed] see libreadline. https://en.wikipedia.org/wiki/GNU_Readline#Choice_of_the_GPL_as_GNU_Readline.27s_license |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jan 20 09:10PM On Tue, 2016-01-19, Vir Campestris wrote: > On 19/01/2016 18:11, Richard wrote: ... > I suspect that myopia is the reason why STL files can (or is it could) > only be opened with a narrow char name. Doesn't map at all well to > Windows, but it's fine for Linux/Unix... What is an STL file -- do you mean e.g. a std::fstream, or a FILE*? I don't think you need to look for a conspiracy. We all used 8-bit character sets back in the 1990s, and all the APIs looked like that, always had. Then when it became fashionable to ask for more (around when Java came, I suppose) pretty much everyone adopted utf-8, which didn't require API changes. Microsoft didn't[0], and they weren't very interested in C++ at the time[1] so I guess the standards people weren't very interested in catering to them. /Jorgen [0] And perhaps they had good reasons, e.g. their work predated utf-8. [1] Remember the many years when VC6 was the best they could offer? -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Ian Collins <ian-news@hotmail.com>: Jan 21 10:59AM +1300 Jorgen Grahn wrote: > [1] Remember the many years when VC6 was the best they could offer? I wish people wouldn't keep reminding me, I'll have nightmares for a week now... -- Ian Collins |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jan 20 10:01PM On Wed, 2016-01-20, Scott Lurndal wrote: >>[citation needed] > see libreadline. > https://en.wikipedia.org/wiki/GNU_Readline#Choice_of_the_GPL_as_GNU_Readline.27s_license Sorry, I meant a citation for "RMS hates the LGPL". /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 20 10:05PM On 20/01/2016 21:59, Ian Collins wrote: >> [1] Remember the many years when VC6 was the best they could offer? > I wish people wouldn't keep reminding me, I'll have nightmares for a > week now... VC6 has nothing to do with C++ sausages. Also, if you mention VC6 again I am going to kill you. /Flibble |
legalize+jeeves@mail.xmission.com (Richard): Jan 20 10:37PM [Please do not mail me a copy of your followup] Jorgen Grahn <grahn+nntp@snipabacken.se> spake the secret code >> see libreadline. >https://en.wikipedia.org/wiki/GNU_Readline#Choice_of_the_GPL_as_GNU_Readline.27s_license >Sorry, I meant a citation for "RMS hates the LGPL". It's my opinion. I cite my own brain. -- "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> |
Lynn McGuire <lmc@winsim.com>: Jan 20 04:04PM -0600 "C++11 threads, affinity and hyperthreading" http://eli.thegreenplace.net/2016/c11-threads-affinity-and-hyperthreading/ Looks tricky. Lynn |
Marcel Mueller <news.5.maazl@spamgourmet.org>: Jan 20 10:54PM +0100 On 20.01.16 08.45, Christof Warlich wrote: > tst.cpp:9:23: error: within this context > class Derived: public B<A::Inner> {}; > ^ First of all Derived need to be your friend rather than B<> that does not know anything about A::Inner. But this is still not sufficient because B<> is a public base class that cannot be accessed from public since the template parameter is non public. But even with private inheritance it does not work. I have no idea why. In contrast an aggregation class Derived { public B<A::Inner> TheB; }; works if you declare Derived as friend. Marcel |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 20 08:00PM On 20/01/2016 04:29, Daniel wrote: > Thanks for posting this. > I note that while array_tree has a stateful allocator, the swap method does not swap the allocator, but does swap pointers to data that were allocated with the allocator. > Is this safe? Fixed. /Flibble |
eao197@gmail.com: Jan 19 10:33PM -0800 SObjectizer is a small framework for simplification of development of concurrent and event-driven applications in C++ by using ideas from actor- and publish-subscribe models. SObjectizer is an OpenSource project which in distributed under 3-clauses BSD license. This release adds a possibility to implement an agent as hierarchical state machine. Version 5.5.15 supports such features for agent's states as composite states, shallow- and deep-history, on_enter/on_exit handlers, time limits, transfer_to_state (a kind of deferring of events) and suppression of events. Just a short example of new features: an agent which implements blinking of LED indicator. This agent receives turn_on_off signal for turning blinking on and off. When blinking is turned on then agent switches LED indicator on for 1.5s then switches it off for 0.75s then switches on again and so on until the agent receives next turn_on_off signal. A code for such agent can look like: class blinking_led final : public so_5::agent_t { state_t off{ this }, blinking{ this }, blink_on{ initial_substate_of{ blinking } }, blink_off{ substate_of{ blinking } }; public : struct turn_on_off : public so_5::signal_t {}; blinking_led( context_t ctx ) : so_5::agent_t{ ctx } { this >>= off; off.just_switch_to< turn_on_off >( blinking ); blinking.just_switch_to< turn_on_off >( off ); blink_on .on_enter( []{ /* some device-specific code */ } ) .on_exit( []{ /* some device-specific code */ } ) .time_limit( std::chrono::milliseconds{1500}, blink_off ); blink_off .time_limit( std::chrono::milliseconds{750}, blink_on ); } }; For more details please look to the corresponding Wiki section: https://sourceforge.net/p/sobjectizer/wiki/so-5.5%20In-depth%20-%20Agent%20States/ There is also updated version of second part of "Deep Dive into SObjectizer-5.5" presentation which gives an overview of agent's states in SObjectizer: http://www.slideshare.net/YauheniAkhotnikau/dive-into-sobjectizer-55-second-part-states The v.5.5.15 can be obtained from the corresponding Files section: http://sourceforge.net/projects/sobjectizer/files/sobjectizer/SObjectizer%20Core%20v.5.5/ or can be checked out from Subversion repository: http://svn.code.sf.net/p/sobjectizer/repo/tags/so_5/5.5.15 or from mirror on GitHub: https://github.com/masterspline/SObjectizer/releases/tag/v5.5.15 |
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