background preloader

C++

Facebook Twitter

C++ - Unique class type Id that is safe and holds across library boundaries. Storing C++ template function definitions in a .CPP file. Why C++ Is Not “Back” I love C++.

Why C++ Is Not “Back”

C++ taught me how to really write code. Back in the day I would study the intricacies of the language, Standard Template Library, and all the nuances of memory management and pointer arithmetic. Those were some seriously good times. I remember reading Scott Meyers Effective C++ book series over and over again.

Each time I would learn something new or grasp more of how to use C++. I’m saying all this just to let you know that I don’t hate C++. There are plenty of excellent developers I know today that still use C++ and teach others how to use it and there is nothing at all wrong with that. So what is the problem then? The new message is wrong C++11 just came out recently and it seems like there is this big resurgence in interest in C++ development. Now don’t get me wrong.

There is one thing it didn’t become though—and this is the most important—more simple. Everyone keeps asking me if they need to learn C++, but just like my answer was a few years ago, it is the same today—NO! Wait! CUDA - Tutorial 4 - Atomic Operations. This tutorial will discuss how to perform atomic operations in CUDA, which are often essential for many algorithms.

CUDA - Tutorial 4 - Atomic Operations

Atomic operations are easy to use, and extremely useful in many applications. Atomic operations help avoid race conditions and can be used to make code simpler to write. C - malloc-ating multidimensional array in function. C++ - How do I start a new CUDA project in Visual Studio 2008. Copying a struct containing pointers to CUDA device.

Boost C++

Using strings in C++ template metaprograms. Of all the reasons to love metaprogramming,1 probably the most compelling is that it lets us embed “little languages” in our programs. For example, we might want to express a parser for complex numbers this way, rather than explicitly writing a recursive descent parser ourselves: auto parse_complex = '(' >> double_ >> -(',' >> double_) >> ')' | double_; Or, instead of hand-coding the state machine for a CD player, we might want to express its transition table like this: auto player = Stopped + play [some_guard] / (some_action , start_playback) == Playing , Stopped + open_close/ open_drawer == Open , Stopped + stop == Stopped , Open + open_close / close_drawer == Empty , Empty + open_close / open_drawer == Open , Empty + cd_detected [good_disk_format] / store_cd_info == Stopped These two examples, using Boost’s Spirit and Meta State Machine libraries respectively, show how one can write a parser and a state machine.

Expression Templates auto all_caps = [A-Z]+; // SYNTAX ERROR. C++ Reflection: Type MetaData: Introduction. C++ - How to add element by element of two STL vectors. Containers In Memory: How Big Is Big? This article appeared in C/C++ Users Journal, 19(1), January 2001.

Containers In Memory: How Big Is Big?

This column addresses two topics: An update on what's going on in the C++ standards process, and a technical question. For information about the former, see the accompanying "Standards Update" sidebar for breaking news about the 1998 C++ standard's first official update, whose ink should be drying as you read this, and how it affects you.

The technical question is this: How much memory do the various standard containers use to store the same number of objects of the same type T? To answer this question, we have to consider two major items: Let's begin with a brief recap of dynamic memory allocation and then work our way back up to what it means for the standard library. Memory Managers and Their Strategies: A Brief Survey Here, in brief, are two popular memory management strategies. In practice, you'll often see combinations of the above. The obvious next question is, Who selects the memory management strategy? 1. 2. Summary. C++ - Is it impossible to use stl map with struct. Sectorzero/maestri. James Reinders. INTEL, United States. C, C++ Programming Tutorials. Welcome!

C, C++ Programming Tutorials

My programming ramblings. C++11 multithreading tutorial - part 3 Posted on May 9, 2012 by Sol The code for this tutorial is on GitHub: In my previous two tutorials about C++11 threads: we’ve seen that C++11 allows us to use a clean syntax (compared with the one used by POSIX for e.g.) for managing multithread applications.

My programming ramblings

The second tutorial presents an example of threads synchronization using mutex and atomic operations. We’ll start with a simple example of a C++11 thread with a member function: In the above example we use a dummy class with a public function that can be called from a thread, at line 21 in the source file you can see the way in which you can pass an argument to this function. C++11 also allows us to use anonymous functions, or lambdas, in a thread: The above codes can be compiled with gcc-4.7 on Linux and Mac or with Visual Studio 11 on Windows.