Data dodania Pytanie
2017-03-09 08:03 C++ discourages base class of collection - is there anyway to fake it? »
There are no similar concept of (Java) Collection in C++. I can understand the reason, but I want to know whether there is any way to fake it e...
(2) odpowiedzi
2017-03-09 01:03 Splitting loops and cache performance »
I've written some C++ code to average the nearest-neighbour values of elements in a 2D array, and write the result into the corresponding element of a...
(0) odpowiedzi
2017-03-08 18:03 Is generate_canonical output consistent across platforms? »
The C++ standard specifies pretty closely under [rand.util.canonical] just how the template function std::generate_canonical works (though it only pre...
(1) odpowiedzi
2017-03-08 12:03 Why is <> required when specifying a template class which has defaults for all its template parameters? »
Is there a good reason why <> is required when specifying a template class which has defaults for all its template parameters? e.g. #include &...
(1) odpowiedzi
2017-03-08 06:03 Correct way to allocate memory to std::shared_ptr »
I have implemented a function where the identity is given to me and out of my control. It returns std::shared_ptr<const void>. In the function i...
(1) odpowiedzi
2017-03-07 23:03 Sorting arrays and checking for order? »
I have a question that I am stuck on. My code below first sorts the user inputted array and checks if they are consecutive numbers. Everything works j...
(0) odpowiedzi
2017-03-07 20:03 Stroustrup and overflowing size_type in a loop »
I am reading "Programming Principles and Practices using C++" by Bjarne Stroustrup, and I would need a clarification about a surprising bit that I fou...
(2) odpowiedzi
2017-03-07 15:03 Is it safe to change the funtionpointer (std::function) inside a called function? »
I have a std::function pointing to a function. Inside this function I change the pointer to another function. std::function<void()> fun; void ...
(2) odpowiedzi
2017-03-07 14:03 Calling function in a namespace without qualification »
Looking at the source code of boost::polygon, I have seen many applications of the following theme: #include <iostream> namespace B { struct ...
(1) odpowiedzi
2017-03-06 17:03 How can several comparisons be slower than some calculations? »
We were developing a piece of code that would check whenever the user should not be allowed to get into a sector within a time period, one of my colle...
(2) odpowiedzi
2017-03-06 08:03 Simple concept check »
Say I have a simple template like this: template<typename T> class A {}; And I want to specify that the type-parameter T is of some unrelated...
(2) odpowiedzi
2017-03-06 07:03 Why isn't this C++ member function optimized by the compiler with -O3? »
The norm member function in the C++ vector class declared below is marked as const and (as far as I can tell) does not contain any side effects. temp...
(1) odpowiedzi
2017-03-05 16:03 Must constexpr expressions be captured by a lambda in C++? »
Here is a piece of code that won't compile in MSVC 2015 (ignore the uninitialized value access): #include <array> int main() { constexpr in...
(2) odpowiedzi
2017-03-05 14:03 an error in the order of the lines using struct help c++ »
The problem: Define a struct type student that consists of two variables name of type string and age of type int. Write a function getOlder to receiv...
(0) odpowiedzi
2017-03-05 02:03 Simplify (A & B) && !(A & C) »
A, B, and C are variables of some unsigned integral type. Conceptually, A is a test vector, B is a bitmask of 'required' bits (at least one correspon...
(2) odpowiedzi
2017-03-05 00:03 Why can I use initializer lists on the right-hand side of operator += but not operator+? »
This is a follow-up to an earlier question about why I can't use a brace-enclosed initializer as an argument to operator+, which was resolved by looki...
(3) odpowiedzi
2017-03-04 18:03 Is it allowed to call destructor explicitly followed by placement new on a variable with fixed lifetime? »
I know that calling destructor explicitly can lead to undefined behavior because of double destructor calling, like here: #include <vector> in...
(2) odpowiedzi
2017-03-04 12:03 How to efficiently count the highest power of 2 that is less than or equal to a given number? »
I came up with three solutions so far: The extremely inefficient standard library pow and log2 functions: int_fast16_t powlog(uint_fast16_t n) { r...
(6) odpowiedzi
2017-03-04 08:03 Why is my C++ disk write test much slower than a simply file copy using bash? »
Using below program I try to test how fast I can write to disk using std::ofstream. I achieve around 300 MiB/s when writing a 1 GiB file. However, ...
(4) odpowiedzi
2017-03-03 22:03 Why is `std::array` slower than `std::vector`? »
Note: This has only been confirmed in an online IDE, tests on my own laptop do not confirm this. Let us test the performance of the two containers wi...
(0) odpowiedzi
2017-03-03 20:03 Double brace initialization »
Which constructor should be called in the following code and why? struct S { int i; S() = default; S(void *) : i{1} { ; } }; S s{{}}; ...
(1) odpowiedzi
2017-03-03 15:03 Check if one set of types is a subset of the other »
How can one check if one parameter pack (interpreted as a set) is a subset of another one? So far I only have the frame (using std::tuple), but no fu...
(9) odpowiedzi
2017-03-03 14:03 Why does "std::begin()" always return "const_iterator" in such a case? »
#include <vector> #include <iostream> using namespace std; int main() { vector<int> coll; decltype(std::begin(std::declva...
(2) odpowiedzi
2017-03-02 22:03 Surprising behavior of literal type at runtime »
I'm a bit perplexed by the behavior of this code compiled with clang 3.9: struct A { constexpr A() = default; A(const A&) = delete; c...
(2) odpowiedzi
2017-03-02 21:03 Why are these matrix transposition times so counter-intuitive? »
The following example code generates a matrix of size N, and transposes it SAMPLES number of times. When N = 512 the average execution time of the tra...
(1) odpowiedzi
2017-03-02 16:03 Why is std::fill(0) slower than std::fill(1)? »
I have observed on a system that std::fill on a large std::vector<int> was significantly and consistently slower when setting a constant value 0...
(1) odpowiedzi
2017-03-01 21:03 What is the function execution order in code like foo(bar())? »
Assume we have code like this in C or C++: foo(bar()); What is the function execution order in this case? Is it required that bar() is called fir...
(6) odpowiedzi
2017-03-01 18:03 Possible C/C++ compiler bug in Visual Studio 2013 »
The following C or C++ code should have as output "11,11,11," however using Visual Studio Professional 2013 (Version 12.0.40629.00 Update 5) the outpu...
(1) odpowiedzi
2017-03-01 14:03 Why does std::set not have a "contains" member function? »
I'm heavily using std::set<int> and often I simply need to check if such a set contains a number or not. I'd find it natural to write: if (mys...
(7) odpowiedzi
2017-03-01 10:03 Call C++ class methods or function from Java on android without recreating class/variable on every call »
I have a pretty complex NLP code written on C++ and now I want to use it from my android app. My idea is to build app using client-server architecture...
(1) odpowiedzi
2017-03-01 02:03 Placement-new address alignment »
According to https://isocpp.org/wiki/faq/dtors#placement-new the address passed into placement-new has to be properly aligned. But the example it give...
(3) odpowiedzi
2017-03-01 01:03 How does std::set comparator function work? »
Currently working on an algorithm problems using set. set<string> mySet; mySet.insert("(())()"); mySet.insert("()()()"); //print mySet: (())(...
(4) odpowiedzi
2017-02-28 19:02 I just can not understand DR 712 »
DR 712 was responsible for the change in the wording of [basic.def.odr]/2 in C++11 to the current wording today, in [basic.def.odr]2 and 3. But I'm st...
(2) odpowiedzi
2017-02-28 15:02 casting uint32_t to uint64_t results in different value? »
Using Visual Studio 2015 C++, 14.0.25431.01 Update 3. I have unexpected behavior in my code. Compile and run with 64bit, Release: #include <iostre...
(2) odpowiedzi
2017-02-28 00:02 Packing and de-interleaving two __m256 registers »
I have a row-wise array of floats (~20 cols x ~1M rows) from which I need to extract two columns at a time into two __m256 registers. ...a0.........b...
(3) odpowiedzi