Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
1 answer
61 views

Get templated struct without knowing initial template arguments

I am looking for a way to get a specified templated struct from the custom Node classes I am building without having to static_cast or dynamic_cast when I get the pointers. What ways can I use to ...
JemmaFromJupiter's user avatar
-2 votes
0 answers
80 views

Are there objects for primitive data types? [duplicate]

If the object represents a data type, is the variable for a primitive data type like an integer also an object representing this type, or do objects not represent primitive data types? // Let's assume ...
Ahmed Hamed's user avatar
0 votes
1 answer
161 views

How to parameter pack pairs of types?

Here's an example usage of a parameter pack: template <typename... T> bool foo(A x) { return (baz<T>(x) || ...); } I'd like to do something similar, but with pairs of types. Here's an ...
user129393192's user avatar
-2 votes
2 answers
94 views

Custom integer-like datatype with support for static casts without warnings

I'm writing my own little utility library, and I've opted to do something which I don't really see often (and there might be a reason) - I'm trying to implement a 'perfect' wrapper around C++ integer ...
Goubermouche's user avatar
1 vote
1 answer
87 views

Inherited functions returning self reference with derived type

I am trying to create a system where one base class has a bunch of functions, then derived classes can inherit it and add more functions. However, all of these functions return the this keyword and I ...
CreeperCrafter979's user avatar
0 votes
0 answers
76 views

c++ warning: non-void function does not return a value in all control paths

warning: non-void function does not return a value in all control paths... I know what it means, because the for loops don't return something when the data is empty. How should I fix it? template<...
Marius Romeiser's user avatar
0 votes
2 answers
68 views

Static variable and type: could there be another simpler way to implement a function that returns the same ID for each user-defined type?

I was working on creating an entity-component system on my own, and in doing this I have gotten help from a lot of YouTube videos, C++ references, recommended books, etc. While I was implementing a ...
Luffy_one's user avatar
0 votes
1 answer
81 views

Compile time map of type string name to types in C++

In C++ is it possible to generate a compile time map of stringified type names to types. I am aware types themselves can't be mapped but could we for example map to template metafunctions which expose ...
Frank Peterson's user avatar
1 vote
1 answer
147 views

Calculating numbers that require greater than 16 byte data type in C++

I'm working on a function to calculate Fibonacci numbers and return the lowest value digit of that number in C++. I've found that in C++, the largest data type is __uint128_t, which gives me 16 bytes ...
Dwayne St George's user avatar
0 votes
0 answers
36 views

Create Clamped Datatype [duplicate]

I want to create a c++ datatype that will always clamp it's value between 0.0 and 360.0. Other than that, it should behave exactly as a double. I would use it like this: degree my_num1 = 3.5; //...
Invader88's user avatar
-1 votes
1 answer
105 views

Why is having two default constructors only an error if you construct an object of that type?

Here's an example: #include <stdio.h> struct C { ...
user129393192's user avatar
0 votes
3 answers
89 views

How to get the class type of an unnamed struct in a typedef inside the unnamed class?

This is a theoritcal question whether it is possible to get the type of the unnamed struct inside its definition. int main() { struct { using ThisType = ???? //what do i put here? } _;...
user24551355's user avatar
0 votes
2 answers
67 views

The underline type for uint_fast8_t may be wider than a single byte, so the uint_fast8_t b = 0xF0; b<<4; isn't determined across different compilers?

uint_fast8_t is intended to provide the fastest possible 8-bit (or wider) integer type on the target platform, while uint8_t is a fixed 8-bit unsigned integer type. So the uint_fast8_t b = 0xF0; b<...
John's user avatar
  • 3,354
1 vote
2 answers
59 views

C++ class template: define a type used in superclass parameterization and value_type definition

I'm writing a small wrapper around iterators and my code ends up looking like this: template <typename Iterator> class Class: public Superclass<typename std::remove_reference<Iterator>::...
Charlie Vanaret's user avatar
1 vote
2 answers
101 views

Similar types (`int16_t` and `short`) produce different behaviors during reference instantiation

I'm running into the following error depending on which type I choose for a variable. /home/zak/Development/Arduino/generated_examples/ArduinoIoTCloud_Basic/thingProperties.h: In function 'void ...
Zak's user avatar
  • 12.5k

15 30 50 per page
1
2 3 4 5
159