Click here to Skip to main content
15,886,110 members

Articles by Aescleal (Tip/Tricks: 7)

Tip/Tricks: 7

RSS Feed

Average article rating:

No articles have been posted.

Average blogs rating:

No blogs have been submitted.

Average tips rating: 4.69

Desktop Programming
MFC
21 Oct 2010   Updated: 21 Oct 2010   Rating: 5.00/5    Votes: 4   Popularity: 3.01
Licence: CPOL    Views: 22,814     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
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
27 Sep 2010   Updated: 27 Sep 2010   Rating: 4.40/5    Votes: 5   Popularity: 3.08
Licence: CPOL    Views: 11,140     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
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() {...
General Programming
String
8 Jun 2010   Updated: 10 Jun 2010   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 13,364     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
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...
Programming Languages
C#
8 Sep 2010   Updated: 19 Sep 2010   Rating: 3.62/5    Votes: 13   Popularity: 4.03
Licence: CPOL    Views: 17,640     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
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...
C++
14 Jun 2010   Updated: 15 Jun 2010   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 4,280     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
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...
1 Aug 2010   Updated: 1 Aug 2010   Rating: 4.83/5    Votes: 6   Popularity: 3.76
Licence: CPOL    Views: 7,451     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
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...
19 Sep 2010   Updated: 20 Sep 2010   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 10,690     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
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 -...

Average reference rating:

No reference articles have been posted.

Average project rating:

No projects have been posted.
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. This time I'm programming terahertz band body scanners.