c++03 Questions
2
Solved
I have the unfortunate task in 2024 of adding some code to a codebase that needs to be used in a C++03 setting - where unfortunately the original class myclass can't be changed.
I've gotten stuck o...
3
Solved
Is it possible to check (in C++), if types are castable (implicitly or explicitly)?
Is there something in the std or is it possible write a function like in C# (C# same Question)?
I want to perfor...
4
Solved
I have built a working C library, that uses constants, in header files defined as
typedef struct Y {
union {
struct bit_field bits;
uint8_t raw[4];
} X;
} CardInfo;
static const CardInfo Y_CO...
Tab asked 19/7, 2012 at 7:16
2
Solved
I'm porting a Linux C++03 application to Darwin OS X and have some code that reads the symbolic link at /proc/self/exe to determine the directory in which the executable running is located.
How ca...
Crossly asked 26/3, 2014 at 23:46
2
This seems to be similar to POD structs containing constant member, but sort of reversed.
#include <iostream>
struct A
{
int a;
};
union U
{
volatile A a;
long b;
};
int main()
{
U u1...
Enneahedron asked 5/2, 2015 at 1:53
14
Solved
I'm using an API that requires me to pass a function pointer as a callback. I'm trying to use this API from my class but I'm getting compilation errors.
Here is what I did from my constructor:
m...
Trounce asked 30/12, 2008 at 13:35
2
As the title says, the functionality I'm after is provided by C++11's math libraries to find the next floating point value towards a particular value.
Aside from pulling the code out of the std li...
Hyperbaton asked 2/5, 2013 at 10:41
1
The code below uses std::map::at which was introduced in c++11, however, while specifying an older version (I've tried -std=c++03, -std=c++0x and -std=c++98) in g++ and cmake, it still gets compile...
2
Solved
before all:
In C++98, C++03 - Non-static data member initialisers (NSDMIs) do not exist.
https://wandbox.org/ - online compiler you can change the gcc version etc.
Okay now let's consider some cod...
8
Solved
After answering this question I was trying to find is_complete template in Boost library and I realized that there is no such template in Boost.TypeTraits. Why there is no such template in Boost li...
Sutter asked 26/10, 2009 at 14:21
4
The base components of my hobby library has to work with C++98 and C++11 compilers. To learn and to enjoy myself I created the C++98 implementations of several type support functionality (like enab...
Skintight asked 5/11, 2016 at 15:25
3
Solved
I am very confused about value- & default- & zero-initialization.
and especially when they kick in for the different standards C++03 and C++11 (and C++14).
I am quoting and trying to extend...
5
Solved
If I have a class:
template <typename T>
class MyClass
{
// ...
};
and I explicitly instantiate it:
template class MyClass<int>;
template class MyClass<int>; // second time
...
4
Solved
Previously that was std::string::c_str()'s job, but as of C++11, data() also provides it, why was c_str()'s null-terminating-character added to std::string::data()? To me it seems like a waste of C...
2
Solved
Consider the following code:
#define A -100
//later..
void Foo()
{
int bar = -A;
//etc..
}
Now, this compiles fine on some major compilers I tested (MSVC, GCC, Clang) and bar == 100 as expect...
Giron asked 20/5, 2019 at 18:40
4
Solved
I have to use IAR compiller in embedded application (it does not have namespaces, exceptions, multiple/virtual inheritance, templates are bit limited and only C++03 is supported).
I can't use para...
Polarimeter asked 17/4, 2019 at 13:31
0
Consider the following code:
aligned_storage<sizeof(T)> buffer;
T& ref(*reinterpret_cast<T*>(&buffer));
new (&buffer) T();
Use(ref);
The context for this is refactoring s...
3
Solved
I am looking for a solution using the C++03 standard (I am constrained to using this version of the standard for several years yet). Solutions for C++11 are also welcome, but will not be "accepted"...
Feints asked 16/10, 2013 at 16:5
3
Solved
My team is developing a embedded system where we need to follow MISRA C++.
We are refactoring the code to use less virtual methods so we are trying to implement the CRTP to use static polymorphism...
Amalamalbena asked 11/10, 2018 at 8:42
3
Solved
I have a base class, BaseObject, and two derived class DerivedObject1 and DerivedObject2. They share a common behavior and methods, but DerivedObject1 has an additional method. My main class MyClas...
Indifference asked 3/10, 2018 at 12:43
1
Solved
In C++11, it is easy to SFINAE on whether or not an expression is valid. As an example, imagine checking if something is streamable:
template <typename T>
auto print_if_possible(std::o...
1
Solved
I have some const variables that I would like the values of to be shared between multiple source files. I would also like the variable's scope to be limited to a namespace. I am unsure of the best/...
4
I am implementing a binomial coefficient (n choose k) function in C++.
Besides using a "normal" function (which is evaluated at runtime) this also can be accomplished using template metaprogramming...
Kinshasa asked 28/7, 2017 at 16:9
2
Solved
A (file-local; .cpp) const-qualified variable declared at namespace-scope has internal linkage and is thus translation unit local. Is there any reason to/effect of still wrapping the constant in an...
Chlores asked 10/8, 2018 at 9:12
4
Solved
As per this answer, I tried printing a uint64_t, but it gives me an error:
error: expected ``)' before 'PRIu64'
Following is the minimal code showing what I am trying to do:
#define __STDC_FO...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.