Relative Content

Tag Archive for c++c++17

Unexpected result (C++)

using namespace std; #define mod 1e9+7 int main(){ cout<<mod; cout<<endl<<fixed<<mod; } Output: 1e+009 1000000007.000000 I know that in this case ,mod is a floating point number and so first one gives 1e+009 as output due to floating point precision. But then after while using fixed, why the output is not 1000000000.000000. (All necessary header files […]

How to Efficiently Use std::variant for Error Handling in C++?

I’ve recently started exploring the use of std::variant in modern C++ (C++17 and later) to handle errors and return values simultaneously from functions, somewhat similar to Rust’s Result type. I understand the basic usage of std::variant, but I’m looking for efficient and elegant patterns specifically tailored for error handling.

Underscore in header files in C++ does not give any error

So I have a main file and a bunch of other dependent files with their own header files. So while building it throws an error that a object which is created using another file(structure.cpp) and to make things within scope i used another header file extra.hpp with