c++


c++ - What is the difference between #include <filename> and #include "filename"?

In practice, the difference is in the location where the preprocessor searches for the included file. For #include <filename> the preprocessor searches in an implementation dependent manner, normall... Read More


c++ - How can I reliably get an object's address when operator& is overloaded?

Update: in C++11, one may use std::addressof instead of boost::addressof. Let us first copy the code from Boost, minus the compiler work around bits: template<class T> struct addr_impl_ref { T & v... Read More


c++ - Is it a premature optimization to use std::move()?

I'm not sure how the compiler would optimize away the copy (if at all) without the std::move(). Only a very clever compiler could optimise that away, so if the copy could be expensive (e.g. a very... Read More


c++ - Memory alignment in C-structs

At least on most machines, a type is only ever aligned to a boundary as large as the type itself [Edit: you can't really demand any "more" alignment than that, because you have to be able to create a... Read More


c++ - Bitcoin value as int64_t or as double

I want to do program that doing some calculations with bitcoin values. I know bitcoin have 8 digits after decimal point (please correct me). There is no decimal in bitcoin at code level. There is n... Read More


c++ - Why would code explicitly call a static method via a null pointer?

Static member functions were added into C++ in 1989, in Release 2.0 of the AT&T C++ Language System (pre-standardisation). Prior to that, the static keyword could not be used to declare static member... Read More


C++ Best way to get integer division and remainder

On x86 the remainder is a by-product of the division itself so any half-decent compiler should be able to just use it (and not perform a div again). This is probably done on other architectures too.... Read More


c++ - Why does modulus division (%) only work with integers?

Because the normal mathematical notion of "remainder" is only applicable to integer division. i.e. division that is required to generate integer quotient. In order to extend the concept of "remainder... Read More


c++ - Why are std::begin and std::end "not memory safe"?

The get_data function returns an object. When used the way shown, that object will be a temporary object, which will be destructed once the full expression ends. The iterator now references a vector... Read More


c++ - Is there a reason why not to use link-time optimization (LTO)?

I assume that by "production software" you mean software that you ship to the customers / goes into production. The answers at Why not always use compiler optimization? (kindly pointed out by Mankars... Read More