The tag has no wiki summary.

learn more… | top users | synonyms (1)

-3
votes
0answers
39 views

What to consider in coding guidelines for C++11/14? [on hold]

My company recently decided to fully switch to C++11 standard. It means that we have to update our C++ coding guidelines. What rules / recommendations should we add to the guidelines document so that ...
2
votes
5answers
235 views

Unit test private method in c++ using a friend class

I know that this is a debated practice, but let's suppose that this is the best option for me. I am wondering about what is the actual technique to do this. The approach that I see is this: 1) Make a ...
-2
votes
2answers
78 views

Comparing doubles [duplicate]

I need to compare to double variables like this if (distance <= radius) both distance and radius are doubles and I remember in class how to use epsilon comparisons for checking equality but how ...
-2
votes
0answers
43 views

Code beautifier converting const int -> int const and training return type [on hold]

Is there any beautifier that can do more than just indent and add braces? I would like to convert C++ code to use the Type const style rather than const Type use C++11 trailing return types ...
0
votes
1answer
28 views

confusion regarding handling of new smart pointers on stack frames?

Let me try to elaborate it. Stack Frame: When we execute any function it create stack where all local variables and instructions reside. And Smart Pointer: smart pointer like std::unique_ptr allows ...
1
vote
3answers
277 views

C++: Metaprogramming with a compiler API rather than with C++ features

This started out as a SO question but I realized that it is quite unconventional and based on the actual description on the websites, it might be better suited to programmers.se since the question has ...
-3
votes
2answers
106 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
2answers
140 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
86 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 ...
0
votes
0answers
24 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
155 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
104 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
71 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
200 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
563 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
259 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
968 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 ...
0
votes
3answers
294 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 ...
1
vote
1answer
137 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). ...
1
vote
4answers
241 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 ...
1
vote
1answer
297 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 ...
4
votes
3answers
653 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
214 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 ...
2
votes
3answers
337 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 ...
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++, ...
9
votes
3answers
2k 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, ...
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 ...
1
vote
2answers
283 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 ...
3
votes
2answers
269 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 ...
2
votes
3answers
307 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) ...
3
votes
2answers
818 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
713 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 ...
2
votes
2answers
400 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
734 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
445 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 ...
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. ...
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 ...
73
votes
12answers
9k 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 ...
3
votes
2answers
451 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). ...
17
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 ...
3
votes
2answers
628 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 ...
32
votes
4answers
7k 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 ...
7
votes
1answer
2k views

C++11 support for higher-order list functions

Most functional programming languages (e.g. Common Lisp, Scheme / Racket, Clojure, Haskell, Scala, Ocaml, SML) support some common higher-order functions on lists, such as map, filter, takeWhile, ...
9
votes
5answers
1k views

How do you pronounce the '…' operator [closed]

Now, in c++ '...' became a first class operator. In speech, how do you pronounce it? So far I've heard: dot dot dot triple dot ellipsis related: Is it OK to replace ... with ellipsis in writing? ...
3
votes
3answers
1k views

How to setup the c++ rule of three in a virtual base class

I am trying to create a pure virtual base class (or simulated pure virtual) my goal: User can't create instances of BaseClass. Derived classes have to implement default constructor, copy ...
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 ...