Data dodania Pytanie
2017-01-27 03:01 How can I invoke an Objective C header file from a C++ file? »
I wish to call an Objective C function from a C++ file. The build fails when I include the header to the Objective C file(UnZip.h) in the C++ file(Alg...
(1) odpowiedzi
2017-01-26 17:01 Best practice: A compose B, DerivedA compose DerivedB »
struct B holds data. struct DerivedB: B adds some specific data to B. class A holds a reference to an object of type B. class DerivedA holds a refere...
(2) odpowiedzi
2017-01-26 15:01 Why do native threads behave different when app is in background? »
In my app I use native threads to process audio data. The code looks very much like this: std::thread([this] () { while (enabled) { if (c...
(2) odpowiedzi
2017-01-26 11:01 Why would I std::move an std::shared_ptr? »
I have been looking through the Clang source code and I found this snippet: void CompilerInstance::setInvocation( std::shared_ptr<CompilerInv...
(5) odpowiedzi
2017-01-26 11:01 Check if stream reference is NULL doesn't compile anymore »
I am compiling an outdated project with my latest gcc g++ compilers, (version > 6) There is a class CodeWriter with an ostream reference variable. c...
(3) odpowiedzi
2017-01-26 07:01 Is it safe to use the address of a static local variable within a function template as a type identifier? »
I wish to create an alternative to std::type_index that does not require RTTI: template <typename T> int* type_id() { static int x; ret...
(4) odpowiedzi
2017-01-25 14:01 Concerning Struct Constructor and Destructor behavior - C++ »
I don't understand why the output of this program is as follows. Why isn't there a compilation error? I thought when trying to construct B, the compil...
(2) odpowiedzi
2017-01-25 14:01 Does Using a Pointer as a Container Iterator Violate the Standard »
Angew made a comment that a vector using a raw pointer as it's iterator type was fine. That kinda threw me for a loop. I started researching it and f...
(3) odpowiedzi
2017-01-25 01:01 Why does one still need to disambiguate a dependent type with typename in the RHS of a using statement? »
I know very well why one needs to use typename for dependent types, since the compiler may not be able to disambiguate between a type and a variable d...
(0) odpowiedzi
2017-01-24 19:01 Qt pointcloud slow performance in scene3d »
I'm seeing major performance issues in a QML app I wrote to show a point cloud in a Scene3d. With 1000 points/sec it's alright, but at 10,000 it basic...
(0) odpowiedzi
2017-01-24 19:01 Enum constants behaving differently in C and C++ »
Why does this: #include <stdio.h> #include <limits.h> #include <inttypes.h> int main() { enum en_e { en_e_foo, ...
(6) odpowiedzi
2017-01-24 17:01 C++17 class template partial deduction »
My understanding about the Template argument deduction for class templates proposal was to homogenize the behaviour of template functions and template...
(2) odpowiedzi
2017-01-24 11:01 Implicit conversion of both operands for operator== »
The following code compiles and executed without error even though no equality operator is defined: class A { public: operator bool() const { ret...
(1) odpowiedzi
2017-01-23 23:01 Why does code mutating a shared variable across threads apparently NOT suffer from a race condition? »
I'm using Cygwin GCC and run this code: #include <iostream> #include <thread> #include <vector> using namespace std; unsigned u = ...
(5) odpowiedzi
2017-01-23 23:01 Does the standard state that copies must be equivalent? »
Suppose I have a weird string type, that either owns or doesn't own it's underlying buffer: class WeirdString { private: char* buffer; size_t...
(2) odpowiedzi
2017-01-23 16:01 "pure virtual function called" on gcc 4.4 but not on newer version or clang 3.4 »
I've got an MCVE which, on some of my machines crashes when compiled with g++ version 4.4.7 but does work with clang++ version 3.4.2 and g++ version 6...
(2) odpowiedzi
2017-01-22 20:01 Strange algorithm performance »
For context, I wrote this algorithm to get the number of unique substrings of any string. It builds the suffix tree for the string counting the nodes ...
(3) odpowiedzi
2017-01-22 16:01 Differentiating between const references to immutable vs. mutable objects »
Is there any accepted way in C++ to differentiate between const references to immutable objects vs. mutable ones? e.g. class DataBuffer { // ... ...
(5) odpowiedzi
2017-01-22 01:01 Why does gcc reject `new v < new v` when `v` is not a template? »
Simple test case: #include <iostream> struct v {}; int main() { std::cout << __VERSION__ << '\n' << (new v < new v) &l...
(1) odpowiedzi
2017-01-21 22:01 Implicitly default-constructible meaning? »
On this reference page for std::tuple it is said that the default constructor for the type is "explicit if and only if Ti is not implicitly default-co...
(2) odpowiedzi
2017-01-21 14:01 Deduce the std::function result type and use it as a parameter »
This is how my simple class looks like. template <class T> class A { T first; T second; public: A(T f, T s) : first(f), second(s) {}; templat...
(2) odpowiedzi
2017-01-21 13:01 Dynamic allocation of class array with protected destructor »
If I have a class defined like class A { protected: ~A(){ } }; then I can dynamically allocate the individual as well as array of objects like ...
(3) odpowiedzi
2017-01-21 00:01 Inheriting from std::basic_streambuf to write to a socket »
I would like to write a logging library of my own that provides abstraction for wherever the log entries are sent to. The IO library of C++ already p...
(1) odpowiedzi
2017-01-20 21:01 How to use "using" for a function? »
How to use "using" for a function? For example class A; void f(int); struct B { using BA = A; using Bf = f; ??? }; ...
(4) odpowiedzi
2017-01-20 19:01 GCC causes segfault for lambda-captured parameter pack »
I have the following SSCCE: #include <iostream> #include <string> void foo(const std::string &a) { std::cout << a << s...
(1) odpowiedzi
2017-01-20 18:01 VS2015 and clang compile this code, but g++ rejects it. Which one is correct? »
VS2015 and clang compile this code, but g++ rejects it. namespace A { struct B { friend void f(); }; } void A::f() {} int main(){ } I ...
(1) odpowiedzi
2017-01-19 21:01 What is the best way to mark a "should never happen" line in C/C++ »
Please, consider the following example: enum option { opt_ex_a = 'A', opt_ex_b, opt_ex_c }; void provide_option(enum option opt) { s...
(0) odpowiedzi
2017-01-19 17:01 Weird behavior with a manually defined strlen »
Accidentally, I wrote the following interesting snippet: #include <iostream> #include <cstring> size_t strlen(const char* str) { std...
(3) odpowiedzi
2017-01-19 16:01 Why does cout print "2 + 3 = 15" in this snippet of code? »
Why is the output of the below program what it is? #include <iostream> using namespace std; int main(){ cout << "2+3 = " << ...
(5) odpowiedzi
2017-01-19 09:01 Why are pointers to inline functions allowed? »
I have two questions: 1) Why are pointers to inline functions allowed in C++? I have read that the code of inline functions just gets copied to the f...
(5) odpowiedzi
2017-01-18 14:01 Detecting matching bits in C++ »
I'm trying to take two bitset objects, for example a = 10010111 b = 01110010 and remove bits from both variables if they match in the same positio...
(8) odpowiedzi
2017-01-18 14:01 Why does a lambda convert to a bool whose value is true? »
#include <iostream> void IsTrue(const bool value) { if (value) { std::cout << "value is True!\n"; } } int main() { IsTrue([]()...
(1) odpowiedzi
2017-01-18 10:01 Why does shared_ptr use placement new »
I've read at many places that when using make_shared<T> to create a shared_ptr<T>, its control block contains a block of storage large eno...
(2) odpowiedzi
2017-01-17 23:01 Making `std::get` play nice with SFINAE »
std::get does not seem to be SFINAE-friendly, as shown by the following test case: template <class T, class C> auto foo(C &c) -> decltyp...
(3) odpowiedzi
2017-01-17 18:01 Calling subproject binary with system() function 4 times faster than linking subproject »
I need to call a subproject from a main project and implemented two ways of doing that. It turns out, that the second way is a factor 4 slower than t...
(0) odpowiedzi