Data dodania Pytanie
2017-01-02 04:01 Looping over file, only get one line »
Say we have a text file with this contents: dogs cats bears trees fish rocks sharks these are just words separated by newline chars. I am trying to...
(1) odpowiedzi
2017-01-02 04:01 Faster way to convert a number from range to another range »
According to this SO question, it is possible to convert a number range to another (linear conversion) by calculating: NewValue = (((OldValue - OldMi...
(1) odpowiedzi
2017-01-02 02:01 Namespace alias in c++ »
I use c++11 while I need some classes from c++17 library. When using boost from which classes were added I wish to do the following: #if __cplusp...
(2) odpowiedzi
2017-01-01 15:01 Are compiler optimization solving thread safety issues? »
I'm writing a C++ multi-threaded code. When testing the overhead of different mutex lock I found that the thread unsafe code seem to yield the corre...
(1) odpowiedzi
2017-01-01 10:01 Insertion operator not producing the expected output? »
Here is the code #include<iostream> using namespace std; main() { cout<<"Hellow World"<<endl; cout.operator<<("Hello...
(2) odpowiedzi
2017-01-01 06:01 C++1z coroutine threading context and coroutine scheduling »
Per this latest C++ TS: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4628.pdf, and based on the understanding of C# async/await language s...
(1) odpowiedzi
2017-01-01 00:01 Is this function call really ambiguous? »
I'm learning about multiple inheritance and the diamond problem, and when I make a function call from the most derived class Visual Studio tells me th...
(3) odpowiedzi
2016-12-31 11:12 How can I retrieve the return type of a function to use in a template? »
I have a function somewhere called x that returns a know value and has known parameters: int x(int y); I have somewhere else, I want to create a co...
(4) odpowiedzi
2016-12-31 11:12 Why does the C++ standard specifically grant leeway regarding memory layout of class data members with different access specifiers? »
The C++11 standard mandates an ordering in memory for the non-static data members of a class but then specifically carves out an exemption for members...
(1) odpowiedzi
2016-12-31 00:12 structured binding with [[maybe_unused]] »
Functional languages with pattern matching (sometimes?) have the possibility to ignore some bound values, but with C++17 structured bindings there see...
(1) odpowiedzi
2016-12-30 21:12 C2694 on destructor when base class' member's destructor has non-empty noexcept specifier and a body »
This is my first time posting on Stack Overflow. Please let me know how I might improve in the way I should post questions in the future. I am experi...
(1) odpowiedzi
2016-12-30 18:12 What is the largest amount of memory I can allocate on my MacBook Pro? »
I'm trying to figure out how much memory I can allocate before the allocation will fail. This simple C++ code allocates a buffer (of size 1024 bytes)...
(3) odpowiedzi
2016-12-30 16:12 Error message "undefined reference to template function passed as template parameter" »
When I pass a template function as a template parameter of a base class, the linker complains that it cannot link the function: #include <stdio.h&...
(2) odpowiedzi
2016-12-29 18:12 Does std::move() invalidate iterators? »
Consider the following program: struct list_wrapper { std::vector<int> m_list; }; int main() { std::vector<int> myList { 1, 1...
(2) odpowiedzi
2016-12-29 10:12 Is there a simple way to get the number of characters printed in C++? »
printf(...) returns the number of characters output to the console, which I find very helpful in designing certain programs. So, I was wondering if th...
(2) odpowiedzi
2016-12-29 09:12 Should the loop limit be evaluated or stored? »
In C++, is it faster to store the limit of a loop in a variable than evaluating the value? For example: Is it a slower approach to use for(int i=0;...
(7) odpowiedzi
2016-12-28 10:12 Is if else faster than if + default? »
I conducted a simple experiment, to compare if-else to only an if (with default values preset). Example: void test0(char c, int *x) { *x = 0; ...
(1) odpowiedzi
2016-12-28 10:12 Has there been a proposal to add std::bin to the c++ standard? »
C++14 adds ability to use binary literals by typing 0b prefix for the value: int v = 0b1111; // 15 in decimal But there is no std::bin manipulator ...
(1) odpowiedzi
2016-12-28 04:12 Is it possible to manually set istream fail bit in C++11 »
I've made this class: class object { // data... public: friend std::istream& operator>>(std::istream& in, object& o) { cha...
(2) odpowiedzi
2016-12-27 23:12 Does "std::string + char" expression create another std::string? »
Does the expression below create another std::string and then add it to s1? std::string s1 = "abc", s2 = "xyz"; s1 += s2 + 'b'; Should it p...
(2) odpowiedzi
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