The tag has no wiki summary.

learn more… | top users | synonyms (1)

9
votes
4answers
1k views

What is use of universal character names in identifiers in C++

The C++ standard (I noticed it in the new one, but it did already exist in C++03) specifies universal character names, written as \uNNNN and \UNNNNNNNN and representing the characters with unicode ...
-3
votes
2answers
103 views

Why friend in C++ should be in the header file? [closed]

Friend function/class, FriendOfX for some arbitrary class X is an implementation detail of class X. Why in C++ we have to declare them in the header file? Are there any compelling reasons to make this ...
0
votes
0answers
71 views

initializer_list combined with other parameters [migrated]

Suppose I have a class which takes a parameter of type T and a collection of parameters of type U in the constructor. The following solution works: struct Q { Q(T t, ...
1
vote
1answer
273 views

Binary Tree/Knowledge Base design C++

Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main ...
1
vote
2answers
129 views

Is it an anti-pattern to use void* and enums to enable type-checking?

Say in a game engine, you have Objects that composited of different components. One of these is a RenderComponent which can be either a Mesh, a Sprite or a Light. Now, all these are vastly different ...
0
votes
1answer
84 views

In C++11 can Auto be used to get around mis-casting of void * parameters in functions?

If I have a generic function that takes a void* as a parameter, can Auto in C++11 help stop any bad casting of that parameter? For instance, we may have an event system that sends events and a ...
16
votes
10answers
17k views

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

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 ...
0
votes
0answers
23 views

Using rvalue references to signal function behaviour [duplicate]

I have been using functions accepting rvalue ref signatures to make explicit at call site that the object passed in effectively ceases to exist. This ensures that I don't mistake this function for one ...
0
votes
4answers
152 views

Cross Platform Compilation of C++ .exe

I have been asked to re-write an old C/C++ project in C++11. The old project is multi-platform, however, in order to deploy the system on other architectures the current process is to log into a ...
1
vote
2answers
102 views

The destination of cout messages in a GUI program

I've been building some classes and functions in a static library which has the familiar printing of text messages to stdout: cout << "Hello World!" << endl; I've been developing this ...
2
votes
1answer
70 views

How to define different names for the same type and have the compiler check them? [duplicate]

I would like to define several names for the same type and have the compiler distinguish between them. My motivation is that different int variables could represent very different units, and I would ...
3
votes
1answer
197 views

High-level description of how experimental C++ features are developed?

Herb Sutter in a video answers a question about the concepts proposal considered for C++11 and from his remarks it sounds like multiple groups offered prototype implementations but all of them left ...
15
votes
2answers
510 views

C++ strongly typed typedef

I've been trying to think of a way of declaring strongly typed typedefs, to catch a certain class of bugs in the compilation stage. It's often the case that I'll typedef an int into several types of ...
3
votes
1answer
230 views

How to maintain encapsulation with composition in C++?

I am designing a class Master that is composed from multiple other classes, A, Base, C and D. These four classes have absolutely no use outside of Master and are meant to split up its functionality ...
5
votes
2answers
964 views

Should I feel “uncomfortable” using auto in C++? [duplicate]

C++11 features the new auto type declaration, allowing you to work with an object without ever knowing its actual type. I use only strongly typed languages - C++, Delphi (Object Pascal), Go, etc and ...
1
vote
1answer
130 views

heading in right direction? C++ and class templates

I'm working on some inherited code in C++ and am trying to use 2 classes with templates as I need 2-types of each class to operate on floating point or integer data (double v uint64_t to be exact). ...
0
votes
3answers
283 views

Why std::allocators are not that popular? [closed]

With the latest trends about C and C++ applications, and with latest I mean the latest years, I was expecting to see std::allocators to be used way more frequently than what it really is. Modern ...
3
votes
2answers
264 views

Intersection of geometric entities

I was trying to design a small C++ geometric API for learning purposes, but came across a problem when dealing with intersections of geometric entities. For example, the intersection of a line and a ...
9
votes
5answers
12k views

Should I use the new C++11 'auto' feature, especially in loops?

What are the pros/cons to using the auto keyword, especially in for loops? for(std::vector<T>::iterator it = x.begin(); it != x.end(); i++) { it->something(); } ...
2
votes
3answers
335 views

Why are pointers to literals not possible?

Reference to a literal is possible only if the reference is declared as constant. But why is a pointer to a const object not possible in case of literals? i.e. int const& ref = 5;// But why ...
22
votes
4answers
7k views

Using scoped enums for bit flags in C++

An enum X : int (C#) or enum class X : int (C++11) is a type that has a hidden inner field of int that can hold any value. In addition, a number of predefined constants of X are defined on the enum. ...
1
vote
4answers
238 views

Learning programming from a book which uses C++98 [closed]

I am learning programming from a book called "Programming Principles and Practice" by Bjarne Stroustrup. It has been highly recommended over here and elsewhere. My only issue is that it uses C++98 and ...
28
votes
6answers
6k views

What does the latest “C++ Renaissance” mean? [closed]

There's recently some voice about C++ renaissance, among which the most noteworthy one is from Herb Sutter, Chairman of the C++ Standard Committee. You can search for "C++ renaissance" on Google and ...
4
votes
3answers
615 views

What are my options for using a C++11 library in a C# WPF application? [closed]

I am writing a cross-platform (OS X and Windows) desktop application in C++11. I intend to use the same C++11 core on both platforms, utilizing native frameworks for the UI (Cocoa and Objective-C on ...
1
vote
3answers
208 views

C API in C++ with RAII, two alternatives to implement error handling (Exceptions)

I have an API written in C, which produces a result by returning a pointer to allocated memory. For using it with C++ (C++11) I've wrapped the function calls in objects, which keep the result in a ...
25
votes
10answers
6k views

I am a beginner. Can I directly start learning C++11? or I have to learn old C++? [closed]

I'm a beginner and have only little knowledge in programming. Would it be good if I directly learn C++ from books which cover new C++11 or should I study through the old best C++ books? Should I ...
9
votes
3answers
1k views

Style guide for C++

Right now I am using Google C++ Style Guide in my C++ code and I was pretty happy with it. Recently I was told that this guide is very bad: it is used internally by Google (I knew that), is outdated, ...
1
vote
1answer
92 views

argument grouping with parenthesis are valid in C++?

On python I can group arguments into a tuple, something like def func((a, b, c, d), x): print a, b, c, d, x I was wondering if it is possible to group arguments in the same way on C++, ...
21
votes
8answers
2k views

Deprecation considered harmful? [closed]

I've just been compiling some of my own code with the -std=c++0x flag in GCC, as I want to vaguely keep up with what all the young folks are doing (provided they stay of my lawn), and I ended up with ...
0
votes
2answers
269 views

Documenting the effect of std::move

As my team move towards embracing the new features in C++11 I'm struggling with how to make the side-effects of std::move self-documenting in the code. The issue is that an object that has been moved ...
0
votes
0answers
78 views

why c++11 define closure as a process of capturing variables

when using closure in other languages, it just feels nature, variables from outer scope are captured automatically , without the need of declaring such captures. in c++11, good to see we have ...
2
votes
3answers
304 views

Can compilers check whether certain axioms hold for a user defined type?

Suppose the following type is defined (C++ syntax, can be conceptually applied to any statically typed language.) class T { int val; friend bool operator<(const T& lhs, const T& rhs) ...
8
votes
3answers
1k views

Achieving forward compatibility with C++11

I work on a large software application that must run on several platforms. Some of these platforms support some features of C++11 (e.g. MSVS 2010) and some don't support any (e.g. GCC 4.3.x). I ...
3
votes
2answers
788 views

How to deal with pointers from child to parent?

I have a class that represents a file in specific binary format on disk (the parent in the title) and another class that represents an object inside that file (child). When the object changes, it ...
5
votes
2answers
680 views

C++11 Header-only Library: in-class body vs. out-class body code?

BACKGROUND:optional Since 2002 I've been slowly building my own Windows Native C++ library. And let's just say that I have jumped 150KLOC (reusable code) having everything I need and the kitchen sink ...
1
vote
4answers
2k views

Help with learning the C++ Qt Framework [closed]

I've been a longtime PHP web developer. But now I've reached the limits and web doesn't fascinate me anymore. I am interested in learning cross-platform development. I have learned Java for almost a ...
32
votes
4answers
6k views

How to make the switch to C++11?

I've been programming in C++ for a while now, but mostly things centered around the low-level features of C++. By that I mean mostly working with pointers and raw arrays. I think this behavior is ...
73
votes
12answers
8k views

Does auto make C++ code harder to understand?

I saw a conference by Herb Sutter where he encourages every C++ programmer to use auto. I had to read C# code some time ago where var was extensively used and the code was very hard to ...
2
votes
2answers
396 views

New C++11 analogous to python 2 ->3?

I'm a Python2 developer and I just ordered The C++ programming language, 4th edition, from Bjarne Stroustrup's, to learn C++11. But right after I ordered it, I started to wonder if I made a mistake. ...
8
votes
2answers
705 views

Would Task-based programming in C++ require new language standard features?

So I saw this video on Youtube with all these C++ masters on GoingNative 2012 : Interactive panel where everybody could ask the questions. This is the video I was talking about: GoingNative 2012 - ...
0
votes
3answers
2k views

Two-Dimensional vector in C++ – inefficient with dynamic-sized sub vectors?

I know that std::vector uses a contiguous block of memory, but I often see people use vectors of vectors, even when they modify the number of elements in these vectors contained within an outer ...
-2
votes
1answer
442 views

How can I learn to like C++? [closed]

I'm a wimpy web programmer by trade -- I enjoy programming in JavaScript, CoffeeScript, TypeScript, and Ruby. I have to program in C++ for my computer science degree, and it frustrates me. I don't ...
31
votes
3answers
6k views

Is GCC dying without threads support on Windows?

I need some opinion. GCC was always a very good compiler, but recently it is losing "appeal". I have just found that on Windows GCC does not have std::thread support, forcing Windows users to use ...
33
votes
9answers
19k views

std::shared_ptr as a last resort?

I was just watching the "Going Native 2012" streams and I noticed the discussion about std::shared_ptr. I was a bit surprised to hear Bjarne's somewhat negative view on std::shared_ptr and his comment ...
3
votes
3answers
944 views

What is the necessity to go for lambda functions and expressions in C++?

What is the necessity to use lambda functions and expressions in C++? Can you explain or show through examples how to use lambda functions and expressions? I already gone through the related ...
16
votes
3answers
2k views

Did C++11 address concerns passing std lib objects between dynamic/shared library boundaries? (ie dlls and so)?

One of my major complaints about C++ is how hard in practice it is to pass std library objects outside of dynamic library (ie dll/so) boundaries. The std library is often header-only. Which is great ...
63
votes
3answers
11k views

Is C++11 Uniform Initialization a replacement for the old style syntax?

I understand that C++11's uniform initialization solves some syntactical ambiguity in the language, but in a lot of Bjarne Stroustrup's presentations (particularly those during the GoingNative 2012 ...
16
votes
1answer
2k views

Motivation and pitfalls (?) of the auto keyword in C++11

I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in auto x = 1; Since var seems more common in other ...
3
votes
2answers
449 views

How do .so files avoid problems associated with passing header-only templates like MS dll files have?

Based on the discussion around this question. I'd like to know how .so files/the ELF format/the gcc toolchain avoid problems passing classes defined purely in header files (like the std library). ...
3
votes
2answers
613 views

Simplifying C++11 optimal parameter passing when a copy is needed

It seems to me that in C++11 lots of attention was made to simplify returning values from functions and methods, i.e.: with move semantics it's possible to simply return heavy-to-copy but ...