Data dodania Pytanie
2016-12-27 18:12 Do I have to explicitly destroy objects in order »
I know that when the implicit constructors are provided for you your class members are initialised from left to right and top to bottom. In other word...
(4) odpowiedzi
2016-12-27 13:12 Get size of std::array without an instance »
Given this struct: struct Foo { std::array<int, 8> bar; }; How can I get the number of elements of the bar array if I don't have an instanc...
(6) odpowiedzi
2016-12-27 10:12 Why is_default_constructible<Class>::value fails within the same class scope »
Following works fine: struct X { }; // OK static_assert(std::is_default_constructible<X>::value, "Error"); Following assert fails to compil...
(1) odpowiedzi
2016-12-26 13:12 What are the constraints on the user using STL's parallel algorithms? »
At the Jacksonville meeting the proposal P0024r2 effectively adopting the specifications from the Parallelism TS was accepted into the C++17 (draft). ...
(1) odpowiedzi
2016-12-26 10:12 decltype deducted result of in-class defined function »
Why does struct MyStruct { auto foo () { return 1; } auto bar () { return foo(); } }; compile, but when using a trailing return type like so:...
(1) odpowiedzi
2016-12-26 07:12 Is "new int[8]()" equivalent to "new int[8]{}" in C++11? »
Is new int[8]() equivalent to new int[8]{} in C++11? In other words: Does the C++11 standard guarantee each of new int[8]() and new int[8]{} returns...
(1) odpowiedzi
2016-12-26 02:12 Can low memory cause seg faults in native code? »
I have a group of crashes in native code that are rare but happen consistently inolving SEGV_MAPERR or SEGV_ACCERR. These crashes are almost always re...
(1) odpowiedzi
2016-12-25 15:12 Why does a narrowing conversion warning appear only in case of list initialization? »
I have the following code: class A { public: A(const unsigned int val) : value(val) {} unsigned int value; }; int main() { ...
(3) odpowiedzi
2016-12-25 13:12 Should I refer std::vector size when the number is explicitly given »
I'm coding a simple function using std::vector below where input is an integer vector and the function proceeds the iteration based on the number of e...
(1) odpowiedzi
2016-12-25 11:12 Passing different types of parameters to a function template »
Consider this template: template<typename t> t add(t a, t b) { return a+b; } How can I pass different types of parameters so the return v...
(3) odpowiedzi
2016-12-25 00:12 Adding smallest possible float to a float »
I want to add the smallest possible value of a float to a float. So, for example, I tried doing this to get 1.0 + the smallest possible float: float ...
(4) odpowiedzi
2016-12-24 22:12 Should non-capturing generic lambdas decay to function pointers? »
Consider the following code: int main() { auto l = [](auto){}; void(*p)(int) = l; } It works just fine both with GCC and clang. Let's consi...
(1) odpowiedzi
2016-12-24 21:12 Is it undefined behavior to refer to class members in an initialiser list? »
Let's say I have the following: class A { B member1; C member2; public: A(); }; class B { public: C& ref_to_c; B( C& ref_to_c...
(2) odpowiedzi
2016-12-24 01:12 Mixing C++11 atomics and OpenMP »
OpenMP has its own support for atomic access, however, there are at least two reasons for preferring C++11 atomics: they are significantly more flexib...
(1) odpowiedzi
2016-12-23 12:12 Making identical C++ type aliases incompatible »
I use std::vector<int> for two different kinds of information. I want to be sure that I don't accidentally mix the two uses. In short, I want s...
(4) odpowiedzi
2016-12-23 11:12 Will C++17 support the simpler Range-based For Loop? »
Since C++11, we can write: vector<int> v{1, 2, 3, 4}; for (auto x : v) { cout << x << endl; } According to Essentials of Mode...
(3) odpowiedzi
2016-12-23 00:12 Big differences in GCC code generation when compiling as C++ vs C »
I've been playing around a little bit with x86-64 assembly trying to learn more about the various SIMD extensions that are available (MMX, SSE, AVX). ...
(1) odpowiedzi
2016-12-22 21:12 How to avoid decay with template parameter deduction »
Simplified: // CHAR_TYPE == char, wchar_t, ... template <typename CHAR_TYPE, unsigned CHAR_COUNT> void Foo(CHAR_TYPE const (&value)[CHAR_CO...
(2) odpowiedzi
2016-12-22 13:12 Deleted constructor - MSVC reports an error, Clang doesn't »
Consider the following code: class SILPassPipelinePlan final { public: SILPassPipelinePlan() = default; ~SILPassPipelinePlan() = default; SILPa...
(2) odpowiedzi
2016-12-22 08:12 A 'for' loop that appears to be practically infinite »
I'm debugging some code at the moment, and I've come across this line: for (std::size_t j = M; j <= M; --j) (Written by my boss, who's on holida...
(3) odpowiedzi
2016-12-21 14:12 How should a Variable Template be referred to when declared at Class scope? »
For example: class example{ public: template <class T> static constexpr T var = T(1.5); }; int main(){ int a = example::var&l...
(0) odpowiedzi
2016-12-21 11:12 Multithreaded Files Reading »
I need to read / parse a large binary file (4 ~ 6 GB) that comes in fixed chunks of 8192 bytes. My current solution involves streaming the file chunks...
(2) odpowiedzi
2016-12-21 07:12 In C++17, why do associative containers have an `erase` member function that takes (non-`const`) `iterator`? »
See, e.g., http://en.cppreference.com/w/cpp/container/map/erase In C++03 there were three overloads: void erase( iterator pos ); void erase( iterato...
(1) odpowiedzi
2016-12-21 06:12 Why const_iterator could be used with std::map::erase »
I was under the impression that one cant use erase on a const iterator. See also here Calling erase with iterator vs const_iterator Why does the belo...
(2) odpowiedzi
2016-12-20 20:12 Matrix multiplication speed issues »
I am investigating how cache misses influence speed of computation. I know there are many algorithms better for multiplying two matrices (even simple ...
(0) odpowiedzi
2016-12-20 18:12 Why can't we trivially copy std::function »
The reason for me to ask this is I need to store std::function in a vector, and the in-house vector we have in company basically is doing realloc if i...
(4) odpowiedzi
2016-12-20 17:12 Difference between inner and outer overloaded C++ operator »
I have the following code that will not compile, complaining that += operator does not exist. += operator is here declared outside of class A. templa...
(5) odpowiedzi
2016-12-20 14:12 Neither clang nor g++ compile the snippet below. Why? »
Neither clang nor g++ compile this snippet: struct A{ protected: struct B{}; }; struct D: A::B, A{}; According to [class.access]/7, we hav...
(0) odpowiedzi
2016-12-19 15:12 Does the compiler optimize references to constant variables? »
When it comes to the C and C++ languages, does the compiler optimize references to constant variables so that the program automatically knows what val...
(3) odpowiedzi
2016-12-19 11:12 Is it possible to change a C++ object's class after instantiation? »
I have a bunch of classes which all inherit the same attributes from a common base class. The base class implements some virtual functions that work i...
(15) odpowiedzi
2016-12-19 11:12 check if a c++11 feature is enabled in compiler with CMAKE »
I'm developing a project with CMake. My code contains constexpr methods, that are allowed in Visual Studio 2015, but not in Visual Studio 2013. How c...
(1) odpowiedzi
2016-12-19 02:12 When to use multiple CPP files (Good Coding Practice) »
When writing a C++ program what is considered to be good practice in regards to using multiple cpp files? IE If you are writing a rather large (lines...
(2) odpowiedzi
2016-12-19 00:12 Is there any way to know which headers are automatically included in C++ »
This is a follow-up question for this which says that In C++, unlike C, standard headers are allowed to #include other standard headers. Is ther...
(3) odpowiedzi
2016-12-18 22:12 C++ operators overloading when having constructor conversion »
So I'm not too sure if the title well describes the problem. Essentially I'm wondering if I have a class A, which has a constructor from const & f...
(1) odpowiedzi
2016-12-18 20:12 Understanding the weird syntax with curly braces in a constructor initializer list »
So I was just browsing the source code of a library when I encountered this. Font::Font(const sf::Font& font) : m_font{std::make_shared&l...
(3) odpowiedzi