Click here to Skip to main content

Articles by Aescleal (Tip/Tricks: 7)

Tip/Tricks: 7

RSS Feed
No articles have been posted.
No blogs have been submitted.

Average tips rating: 4.68

MFC
General
Posted: 21 Oct 2010   Updated: 21 Oct 2010   Views: 3,310   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: The Code Project Open License (CPOL)      Bookmarked: 0   Downloaded: 0
printf is so 1980s. If you don't want to dig out your shoulder pads and big hair why not go for a more modern C++ approach?Instead of a function try a stream buffer:class message_box_stream_buf : public std::basic_streambuf{ public: message_box_stream_buf( const...
Win32/64 SDK & OS
General
Posted: 27 Sep 2010   Updated: 27 Sep 2010   Views: 2,540   Rating: 4.40/5    Votes: 5   Popularity: 3.49
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
I tend to use boost::interprocess::named_mutex for the same thing. The equivalent code is something like:using boost::interprocess;const char *application_name = "Application Name";int main()try{ struct named_mutex_killer { ~named_mutex_killer() {...
Programming Tips
General
Posted: 8 Jun 2010   Updated: 10 Jun 2010   Views: 2,510   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
Alain's (original, now much hacked) narrow character version, could leak if std::basic_string::asign threw. To make the function exception safe either use a local buffer (if the size is fixed) or a vector (if the size isn't known).In both cases it's usually more efficient (and readable) to...
Posted: 14 Jun 2010   Updated: 15 Jun 2010   Views: 931   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
Instead of doing what the original author does (which is read a string and convert it manually into a number) why not use streams properly?When a program wants a number, read a number and then check the stream state is still good. If it's not you know the user has entered something that's...
Posted: 1 Aug 2010   Updated: 1 Aug 2010   Views: 1,755   Rating: 4.83/5    Votes: 6   Popularity: 3.76
Licence: The Code Project Open License (CPOL)      Bookmarked: 1   Downloaded: 0
Combining a smart pointer with a collection we can get all the functionality that the original author wrote a custom class for, and a bit more:typedef std::vector> garbage_collector;Er, that's it. So how would you use this? Say you wanted to use character arrays as...
Posted: 8 Sep 2010   Updated: 19 Sep 2010   Views: 4,145   Rating: 3.50/5    Votes: 13   Popularity: 3.90
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
In C++ you can use the size of a pointer to work out what sort of process you're running in:bool is_64_bit(){ return sizeof(void *) == 8;}This has got the advantage of being portable and you don't have to call any OS functions.You can do something similar in C - just return...
Posted: 19 Sep 2010   Updated: 20 Sep 2010   Views: 3,206   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: The Code Project Open License (CPOL)      Bookmarked: 2   Downloaded: 0
If you can, the quickest way to calculate the Fibonacci numbers is to do it at compile time. This is a case of "My recursive method is quicker than yours...":templateclass fibonacci_number{ public: static const T value = fibonacci_number<T, n -...
No reference articles have been posted.

Aescleal
Software Developer (Senior)
United Kingdom United Kingdom
I've been programming since 1985 - starting with Fortran 77, then moving onto assembler, C and C++ in about 1991. I also know enough Java and Python to read code but you probably wouldn't want me writing it.
 
I've worked in a wide variety of application areas - defense, banking, games and security with the longest stints being in security. I also seem to end up programming devices far too often.
Follow on   Google+


Advertise | Privacy | Mobile
Web03 | 2.8.141022.1 | Last Updated 23 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid