Data dodania Pytanie
2017-09-27 08:09 What exactly is std::labs() there for? »
I read about the std::abs() function when browsing cppreference. On that page I have also seen a std::labs() function. Which has the same prototype a...
(1) odpowiedzi
2017-09-26 22:09 Overloading template class with template function »
C++ allows to use class and function with the same name in one namespace: struct S {}; void S() {} In this case pure name S means function S. To us...
(2) odpowiedzi
2017-09-26 21:09 incorporating a line of objC in C++ header »
I am using the Syphon framework to serve video frames to a client. There is one line of code I need to use to serve the frames through the server, and...
(1) odpowiedzi
2017-09-26 15:09 Do uninitialized objects exist in C++? »
If all objects have at least one constructor be it default c'tor defined by the compiler or user defined then how can objects be uninitialized. ...
(2) odpowiedzi
2017-09-26 12:09 Having issues with code now giving expected output »
Having issues getting this graded properly. It keeps showing up as 87% out of 100, but all of the prerequisites are functioning as they should. The pr...
(2) odpowiedzi
2017-09-26 12:09 What is the difference between typedef int array[3] and typedef int(array)[3]? »
I recently came across this unorthodox way to define a int array type: typedef int(array)[3]; At first I thought it was an array of function pointe...
(3) odpowiedzi
2017-09-26 04:09 For C++ Vector3 utility class implementations, is array faster than struct and class? »
just out of curiosity, I implemented vector3 utilities in 3 ways: array (with a typedef), class and struct This is the array implementation: typedef...
(2) odpowiedzi
2017-09-25 13:09 Can I implement max(A, max(B, max(C, D))) using fold expressions? »
While trying to play around with C++17 fold expressions, I tried to implement max sizeof where result is maximum of the sizeof of types. I have an ugl...
(8) odpowiedzi
2017-09-25 11:09 Is "enum class" a class type in C++? »
I read about enumeration declaration in C++ using cppreference. Then I have made Enum class and check whether it is a class type or not using std::is...
(2) odpowiedzi
2017-09-25 07:09 Silent breaking of constructor calls after adding initializer_list constructor »
Let's consider the following: #include <iostream> #include <initializer_list> class Foo { public: Foo(int) { std::cout <&...
(3) odpowiedzi
2017-09-24 13:09 ambiguous call of overloaded template with parameter (const T&, const T&) or (const char (&)[N], const char (&)[M]) »
For the following code: #include <iostream> using std::cout; using std::endl; template <typename T> int compare(const T&, const T&am...
(1) odpowiedzi
2017-09-24 12:09 C++ STL set usage »
I have a std::set of a structure like the one given below: struct weight{ int y; int w; }; with the comparator defined as: bool operator <(con...
(2) odpowiedzi
2017-09-24 11:09 When to use std::invoke instead of simply calling the invokable? »
As I understand, std::invoke allows me to do something like: std::invoke(f, arg1, arg2, ...); Is there a scenario when it's more advantageous than ...
(1) odpowiedzi
2017-09-24 11:09 Add pointer to defined Objective-C class in .h file of Objective-C++ »
Is possible to create class in Objective-C++ which has field that is a pointer to an Objective-C interface ( inside the .h file ) ? To clarify a litt...
(1) odpowiedzi
2017-09-24 09:09 Can bitwise operators have undefined behavior? »
Bitwise operators (~, &, | and ^) operate on the bitwise representation of their promoted operands. Can such operations cause undefined behavior? ...
(1) odpowiedzi
2017-09-23 15:09 GetThreadContext() returning 87 »
I'm trying to get the thread context of suspended WordPad. However, no matter what changes I make to the code, it returns 87. STARTUPINFO si = { ...
(1) odpowiedzi
2017-09-23 14:09 Is static initialization guaranteed here? »
Look at this code: struct Foo { void *ptr; constexpr Foo() : ptr(nullptr) { } }; Foo f; Is it guaranteed that f will be staticall...
(3) odpowiedzi
2017-09-23 08:09 What is the purpose of "int mask = ~0;"? »
I saw the following line of code here in C. int mask = ~0; I have printed the value of mask in C and C++. It always prints -1. So I do have some ...
(6) odpowiedzi
2017-09-22 22:09 Infinity not constexpr »
I wanted to test the behavior of floats near infinity. For that I naively wrote the following code: #include <limits> #include <iostream>...
(1) odpowiedzi
2017-09-22 14:09 Expand two parameter packs »
Consider following piece of code: static constexpr size_t Num {2}; struct S { std::array<size_t, Num> get () { return {1, 2}; } }; struct ...
(4) odpowiedzi
2017-09-22 09:09 Visual Studio C++ enum takes a long time to compile »
I have a dll with an enum (and many other things) enum class KIT_API VoxelTypes : uint16_t { ... about a hundred entries ... ModellingClay_00 =...
(1) odpowiedzi
2017-09-21 17:09 What differences are between capturing by [&captured] and by [&local = captured] in lambdas? »
vector<int> vec; //a auto foo = [&vec](){ //do something }; //b auto foo = [&v = vec](){ //do something }; Do I understand i...
(2) odpowiedzi
2017-09-21 09:09 Different output from stringstream using g++ and clang »
The following code gives different results with the g++ 7 compiler and Apple clang++. Did I run into a bug in clang in the alignment of bool output wh...
(1) odpowiedzi
2017-09-21 08:09 Why does function overloading generate an ambiguous error in C++? »
In the following code snippets, In function call f(1), 1 is a literal of type int and in first function void f(double d) argument type is double and s...
(1) odpowiedzi
2017-09-20 22:09 In the comma operator, is the left operand guaranteed not to be actually executed if it hasn't side effects? »
To show the topic I'm going to use C, but the same macro can be used also in C++ (with or without struct), raising the same question. I came up with ...
(6) odpowiedzi
2017-09-20 12:09 Is there any warning for writing `this-field` instead of `this->field`? »
This following code (containing a vicious bug) compiles with GCC without any warning. But, of course, it doesn't work as expected by the developer (me...
(4) odpowiedzi
2017-09-20 11:09 What's the modern C++ way to cast absolute addresses to pointer variables? »
In the embedded world for ages people wrote hardware(-configuration)-register-mappings as structures, a really simple example for a 32-bit hardware: ...
(2) odpowiedzi
2017-09-19 12:09 Does using heap memory (malloc/new) create a non-deterministic program? »
I started developing software for real-time systems a few months ago in C for space applications, and also for microcontrollers with C++. There's a ru...
(11) odpowiedzi
2017-09-19 10:09 Call operator with auto return type being chosen instead of constructor when using std::function »
The following snippet: #include <functional> struct X { X(std::function<double(double)> fn); // (1) X(double, double); ...
(1) odpowiedzi
2017-09-19 08:09 SBCL returns handle-win32-exception »
I wanna call c++ function from SBCL using cffi. I tried to call the following very simple function. #include <stdio.h> void print1() { printf(...
(0) odpowiedzi
2017-09-19 07:09 Is it better to remove "const" in front of "primitive" types used as function parameters in the header? »
In the code review process, one of my coworkers mentioned to me that "const"s in front of "primitive types" used as a function parameter in a header i...
(5) odpowiedzi
2017-09-18 14:09 Variadic templates and switch statement? »
I have the following function which can take N arguments of different types, and forwards them to N functions templated on each individual type, in th...
(5) odpowiedzi
2017-09-18 10:09 Const reference field as readonly property in C++ class »
Is it good to use a const reference field as a readonly getter in C++ classes? I mean, does this code meet good practices? class check{ private: ...
(4) odpowiedzi
2017-09-18 08:09 Why 'is_convertible' here in <utility> std::pair (STL)? »
template<class _Other1, class _Other2, class = enable_if_t<is_constructible<_Ty1, _Other1>::value &&am...
(2) odpowiedzi
2017-09-17 19:09 Iteratively filtering arguments matching a predicate at compile-time »
Context Firstly, some context: I'm using an empty struct called nothing to emulate something similar to "regular void" in order to prettify some inte...
(2) odpowiedzi