Data dodania Pytanie
2017-12-26 18:12 Using std::endl on an ostream makes my file binary »
I am working on a project that uses libzip. I'm working in c++14 and I wrote a tiny wrapper around libzip to make my life easier. I have an std::ostr...
(2) odpowiedzi
2017-12-26 16:12 Accurate C/C++ clock on a multi-core processor with auto-overclock? »
I have looked into several topics to try to get some ideas on how to make a reliable clock with C or C++. However, I also saw some functions used the ...
(1) odpowiedzi
2017-12-26 14:12 Is there an equivalent of the Java <? extends ClassName> in C++? »
I am looking at this https://docs.oracle.com/javase/tutorial/java/generics/subtyping.html and https://docs.oracle.com/javase/tutorial/java/generics/in...
(3) odpowiedzi
2017-12-26 11:12 How to avoid recompiling all the files everytime? »
I have about 20 .cpp files and and as many .h files. When I compile I do g++ -std=c++11 main.cpp -o main in main.cpp I start by some forward declar...
(2) odpowiedzi
2017-12-26 07:12 clang 5: std::optional instantiation screws std::is_constructible trait of the parameter type »
A really strange and unexpected behaviour of clang 5 was detected when switching to c++17 and replacing custom std::optional solution with the standar...
(2) odpowiedzi
2017-12-25 12:12 How does implicit conversion work in C++ »
I'm trying to figure out how implicit conversion works. I have 3 functions Foo(int, int) Foo(short, short) Foo(short, unsigned char) Then I call ...
(1) odpowiedzi
2017-12-25 12:12 c++ include different header files with same implementation of class in multiple source files »
For example a.h class Dummy { public: Dummy() { std::cout << "a.h" << std::endl; } }; b.h class Dummy { public: Dummy() { std::co...
(2) odpowiedzi
2017-12-25 06:12 Constraint on std::optional's forwarding reference constructor »
std::optional has 8 constructors as of this date, listed below (also here http://en.cppreference.com/w/cpp/utility/optional/optional) /* (1) */ const...
(2) odpowiedzi
2017-12-24 18:12 Delegating constructor gives segmentation fault when using class field for argument »
Actually the segmentation fault happens in another program I tried to compile which happens because of this behaviour. My question is: This is a ...
(2) odpowiedzi
2017-12-24 12:12 mmap Mac: Segmentation fault »
The following on my Mac succeeds: int main() { int* addr = (int*) mmap(0, 100, 1 | 2, 2 | 4096, -1, 0); *addr = 25; return 0; } Howev...
(1) odpowiedzi
2017-12-24 00:12 I keep getting an exception even though the code is within a try/catch block »
I wrote some code that encounters an exception if the given user input is invalid so I put it in a try/catch block yet it still threw an exception. Th...
(3) odpowiedzi
2017-12-23 22:12 MySQL C++ connector unresolved external »
I am trying to build a MySQL C++ connector application with Visual Studio 15 2017, using MySQL C++ connector as a static library. However, after caref...
(2) odpowiedzi
2017-12-23 21:12 How to approach explicit template instantiation in the presence of unpredictable type aliases? »
I am attempting to add some extern template into my project, to speed up build times and reduce footprint on disk during build. I've done so by listi...
(4) odpowiedzi
2017-12-23 17:12 Recursive type_traits for member function detection »
I am trying to apply the type_trait has_fun recursively so that C enables its fun member function only if T has one. Is there a way to make C::fun bei...
(4) odpowiedzi
2017-12-23 12:12 Why is S::x not odr-used? »
Consider this example from cppreference: struct S { static const int x = 1; }; void f() { &S::x; } // discarded-value expression does not odr-use...
(0) odpowiedzi
2017-12-22 18:12 What is a temporary object with static storage duration »
Inspired from this answer, from [expr.const] A constant expression is either a glvalue core constant expression that refers to an entity that is a...
(1) odpowiedzi
2017-12-22 11:12 Why can C++ deduce template arguments on the right side of an assignment operator from the left side? »
template <typename T> void func(T&){ } int main(){ void (*p)(int&) = func;//or &func return 0; } I wonder why this code c...
(1) odpowiedzi
2017-12-22 04:12 When overloading a function with multiple inheritance, GCC says calling it is ambiguous, but Clang and MSVC do not »
I am using this variant library: https://github.com/cbeck88/strict-variant. It provides a class similar to std::variant and boost::variant. Given this...
(1) odpowiedzi
2017-12-21 16:12 Why construction of std::unique_ptr for incomplete type compiles? »
Code: #include <memory> struct Data; std::unique_ptr<Data> make_me(); int main() { std::unique_ptr<Data> m = make_me(); r...
(2) odpowiedzi
2017-12-21 15:12 Why are the default constructor and destructor of a class inline? »
I read from multiple sources that: If no user-declared constructors of any kind are provided for a class type (struct, class, or union), the compi...
(2) odpowiedzi
2017-12-21 05:12 Creating OpenGL structures in a multithreaded program? »
I am attempting to do the following in a physics engine I am building: Have 2 threads, one for world logic, one for rendering. The main thread (the ...
(2) odpowiedzi
2017-12-20 17:12 "Inline" static declaration of object with initializer list »
Sorry for the awkward title, but I couldn't find a better one. Consider this sample code (it has no purpose except illustrating the question): #incl...
(5) odpowiedzi
2017-12-20 16:12 Why is this expression not a constant expression? »
The expression b in this code shall be a core constant expression int main() { constexpr int a = 10; const int &b = a; constexpr int ...
(1) odpowiedzi
2017-12-20 06:12 Array pointer data being cleared in between function calls without an explicit command? »
I have the following issue: In a C++ program I have a global data structure declared as Renderer Rendering_Handler, which contains a member field def...
(1) odpowiedzi
2017-12-19 10:12 Where are expressions and constants stored if not in memory? »
From C Programming Language by Brian W. Kernighan & operator only applies to objects in memory: variables and array elements. It cannot be ...
(6) odpowiedzi
2017-12-19 09:12 Why do non-constant static variables need to be initialized outside the class? »
I know that non-constant static variables need to be initialized outside the class definition but, is there a reason for this? class A { static i...
(4) odpowiedzi
2017-12-19 07:12 Constructor called on return statement »
Consider the following example: class X { public: X() = default; X(const X&) = default; X(X&&) = delete; }; X foo() { X ...
(3) odpowiedzi
2017-12-18 21:12 Is std::variant allowed to allocate memory for its members? »
I was wondering if an implementation of std::variant must necessarily be "flat" or whether it is allowed to dynamically allocate memory for its member...
(2) odpowiedzi
2017-12-18 20:12 firefox remote debugging using websocket »
I can debug chrome remotely by passing --remote-debugging-port=9222 then I send request using curl : curl localhost:9222/json to get the ids and debug...
(0) odpowiedzi
2017-12-18 16:12 Is it possible to use the `auto` keyword as a return type in a function pointer declaration with initialization? »
The following code compiles successfully both with clang++ 3.8.0 and g++ 7.2.0 (the compilation flags are -std=c++14 -O0 -Wall -Wextra -Werror -pedant...
(1) odpowiedzi
2017-12-18 11:12 Function with a fixed amount of parameters determined by an integer »
I have a class with a template that accepts an integer: template <unsigned int N> class Example {}; I'm looking for a way to define a (member...
(5) odpowiedzi
2017-12-17 12:12 Is it abuse to deduce parameters of parent template when passing pointer to constexpr function in the scope of a class »
Minimal example I got is a bit complicated: struct A { }; template <int> struct Parent { }; template <int N> constexpr int operator*(A,...
(1) odpowiedzi
2017-12-17 09:12 OpenGL shaders don't compile »
The shaders in my OpenGL project don't compile. I have Ubuntu 16.04 LTS, using CLion. Didn't find any solution, that's why asking here. Here is my er...
(2) odpowiedzi
2017-12-17 03:12 Which is Faster in C++: i<=N or i<N+1 »
Both of the following for-loops will be executed N+1 times: for(int i = 0; i <= N; ++i); for(int i = 0; i < N + 1; ++i); Which of the two exp...
(1) odpowiedzi
2017-12-17 01:12 User-defined vs automatic template deduction guides priorities »
Let's say we have a class like this with a user-defined deduction guide: template<typename T, typename... Args> struct Foo { Foo(Args&&...
(1) odpowiedzi