Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 C++


  C++11 multithreading tutorial

The code for this tutorial is on GitHub: https://github.com/sol-prog/threads.In my previous tutorials I’ve presented some of the newest C++11 additions to the language: regular expressions, raw strings and lambdas.Perhaps one of the biggest change to the language is the addition of multithreading support. Before C++11, it was possible to target multicore computers using OS facilities (pthreads on Unix like systems) or libraries like OpenMP and MPI.This tutorial is meant to get you started with C++11 threads and not to be an exhaustive reference of the standard.Creating and launching a t...

4,147 0       C++ DEMO MULTITHREADING STANDARD 11


  C++ for the Real-Time Web

C++? Why on Earth?C++ seems like one of the least likely languages to write a web application in.C++ is associated with complexity, both with language design and the need tomanually manage memory. Programming in C++ unleashes a whole class of bugsassociated with memory corruption and memory allocation. This is a trade off forgiving more power to the developer along generally being much faster thanequivalent programs in languages such as Python or Ruby.Real-time Web as a Use CaseMaking a hard real-time application1 onthe web is a futile task. Unpredictable network latencies make this animpossib...

4,008 0       C++ WEB DEVELOPMENT REAL TIME


  sorting in C++: 3 times faster than C.

If you don't know C++ well, you might be surprised how fast C++ can be sometimes. This is especially true when code involved is small, because then inlining - which is what C++ is very good at - and templating, which makes excessive inlining possible in the first place - has the most effect.The following code compares C and C++ sorting:  #include <iostream>#include <algorithm>#include <vector>#include "stop_watch.inl" // see https://gist.github.com/2057981#ifndef COUNT#define COUNT 100000000#endifint compare_int(const void* p1, const void* ...

3,939 0       C++ SORTING C FASTER EFFICIENCY


  Why would I learn C++11, having known C and C++?

I am a programmer in C and C++, although I don't stick to either language and write a mixture of the two. Sometimes having code in classes, possibly with operator overloading, or templates and the oh so great STL is obviously a better way. Sometimes use of a simple C function pointer is much much more readable and clear. So I find beauty and practicality in both languages. I don't want to get into the discussion of "If you mix them and compile with a C++ compiler, it's not a mix anymore, it's all C++" I think we all understand what I mean by mixing them. Also, I don't want to talk abou...

3,715 0       NEW FEATURE STUDY C++11


  Understanding lvalues and rvalues in C and C++

The terms lvalue and rvalue are not something one runs into often in C/C++ programming, but when one does, it’s usually not immediately clear what they mean. The most common place to run into these terms are in compiler error & warning messages. For example, compiling the following with gcc:int foo() {return 2;}int main(){ foo() = 2; return 0;}You get:test.c: In function 'main':test.c:8:5: error: lvalue required as left operand of assignmentTrue, this code is somewhat perverse and not something you’d write, but the error message mentions lvalue, which is not a term one ...

3,430 0       C++ ELABORATION LVALUE RVALUE LOCATOR VALUE


  Why do C++ folks make things so complicated?

This morning Miroslav Bajtoš asked “Why do C++ folks make things so complicated?” in response to my article on regular expressions in C++. Other people asked similar questions yesterday.My response has two parts:Why I believe C++ libraries are often complicated.Why I don’t think it has to be that way.Why would someone be using C++ in the first place? Most likely because they need performance or fine-grained control that they cannot get somewhere else. A Ruby programmer, for example, can make a design decision that makes code 10% slower but much easier to use. “Hey, ...

2,918 0       C++ COMPLICATED C++ PROGRAMMER DESIGN PATTERN


  10 Tips To Make Your C Program Effective

The beauty of any code lies not only in finding the solution to a given problem but is in its simplicity, effectiveness, compactness and efficiency( memory ). Designing the code is harder than actually implementing it. Hence every programmer should keep a couple of basic things in mind while programming in C. Here we introduce you to such 10 ways of standardizing your C code.1. Avoid unwarranted function callsConsider the following two functions:view source print?1void str_print( char *str ) 2  3{ 4  5    int i; 6  7    for ...

2,791 0       TIPS C EFFICIENT SPEED INCREMENT RECURSI


  Set Theory in C++11

Have you ever felt the need to perform set theoretic operations on types? Not really? Me neither, but I thought it’s a fun thing to try out. So, if you ever feel the need of using type sets, C++11 makes it quite easy to do so. Especially variadic templates allow for a much more condensed syntax compared to type list constructs formerly used. (Disclaimer: This is rather a proof of concept, but maybe somebody comes up with a useful scenario.)Let’s start by defining an empty type_set type:template<typename ... Types>struct type_set; typedef type_set<>...

2,764 0       C++ MATH SET THEORY