Let's suppose that I've either a function or a class template that should work only for certains types, e.g. std::wstring and std::string. I know tha ...
Let's suppose that I've either a function or a class template that should work only for certains types, e.g. std::wstring and std::string. I know tha ...
The code in this question is based on this answer. I am a little confused about how this produces the output it does, and whether it is all well defin ...
I'm following "Implementing functional languages: a tutorial" by SPJ, and I'm stuck on Exercise 2.18 (page 70), reproduced below. This is in the chapt ...
Is use in a default member initializer still an odr-use, even if the default member initializer is not used by any constructor? For example, is this ...
This is a follow up of this question: Does PIMPL idiom actually work using std::unique_ptr? The full example uses multiple files, so for the sake of ...
The following code compiles fine: But if I define f()s inside a namespace, e.g. by uncommenting the above code, then the compiler generates an erro ...
I have a method (in a class A) that has a lot of different overloads, and i am making a class B that inherits from A, changing the behavior of the met ...
So I have a class template for example in Template.h and I separated the float and double specialization into different .h files float.h ...
I would like to prevent the compiler from implicitly instantiating some template with extern template. The following snippets works as expected (the ...
From the previous example I've posted here about when the template is instantiated?, I got the answer that only when a template is used the compiler i ...
The fact that a template is not instantiated until it is used so for example if I have this class template: So when exactly the template is inst ...
As i started experimenting more in depth with C++1x features i ran into some thinking. For example when there is this construct template<unsigned i ...
I was trying to write a class that will fill a container with random numbers with the type that the container has: But here an error occurs somewhe ...
This is a follow up of this question. The original case was something else, but in the course of me writing a poor answer and OP clarifying, it turned ...
I would like to load images from a filetype which can hold many different kinds of data : the pixels can be encoded as floats, doubles, unsigned chars ...
Here is an exercise from C++ primer 5th edition: "Exercise 16.26: Assuming NoDefault is a class that does not have a default constructor, can we expl ...
In Memory.h I have: And in main.cpp I have: And this compiles fine even though Foo isn't fully defined until after I pasted in Memory.h. I'm con ...
This codes run on G++, but not on Visual C++. Here is the error from Visual C++ :- error C2206: 'foo': typedef cannot be used for function defi ...
Suppose that I am writing an iterator and const_iterator for singly linked list. Suppose that I have a following classes: My question is whether i ...
(This question has been significantly edited, sorry.) Suppose I have several non-constexpr function templates, which default to being deleted: and ...