Stack Overflow Weekly Newsletter
Stack Overflow Weekly Newsletter

Top new questions this week:

Difference between string.empty and string[0] == '\0'

Suppose we have a string std::string str; // some value is assigned What is the difference between str.empty() and str[0] == '\0'?

c++ string  
asked by Pro Account 42 votes
answered by NathanOliver 74 votes

Violating of strict-aliasing in C, even without any casting?

How can *i and u.i print different numbers in this code, even though i is defined as int *i = &u.i;? I can only assuming that I'm triggering UB here, but I can't see how exactly. (ideone demo ...

c strict-aliasing  
asked by Aaron McDaid 34 votes
answered by Grzegorz Szpetkowski 38 votes

Fast algorithm to write data from a std::vector to a text file

I currently write a set of doubles from a vector to a text file like this: std::ofstream fout; fout.open("vector.txt"); for (l = 0; l < vector.size(); l++) fout << std::setprecision(10) ...

c++ std ofstream  
asked by Diego Fernando Pava 29 votes
answered by hungptit 12 votes

C / C++ best practices with signed / unsigned ints and function calls

I am asking this question for two different languages: C and C++. What is best practice when calling functions that have an opposite integer sign expectation to what we require in our code? For ...

c++ c  
asked by IamIC 28 votes
answered by zwol 8 votes

What is the arithmetic mean of an empty sequence?

Disclaimer: No, I didn't find any obvious answer, contrary to what I expected! When looking for code examples wrt. the arithmetic mean, the first several examples I can turn up via Google seem to be ...

c++ algorithm math floating-point nan  
asked by Martin Ba 26 votes
answered by R.M. 25 votes

Restrict variadic template arguments

Can we restrict variadic template arguments to a certain type? I.e., achieve something like this (not real C++ of course): struct X {}; auto foo(X... args) Here my intention is to have a function ...

c++ templates variadic-templates c++1z c++-faq  
asked by bolov 25 votes
answered by bolov 31 votes

In C++, why isn't it possible to friend a template class member function using the template type of another class?

In other words, why does this compile fine : template<typename Type> class A{ public: void f(); }; class B{ friend void A<int>::f(); }; template<> void A<int>::f(){ ...

c++ templates friend  
asked by user1729422 21 votes
answered by Tunichtgut 2 votes

Greatest hits from previous weeks:

How to rename a local Git branch?

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories. Instead, I want to use the simplest way to rename a local branch, which hasn't ...

git git-branch  
asked by Forrest 4263 votes
answered by siride 6818 votes

Redirect from an HTML page?

Is it possible to set up a basic HTML page to redirect to another page on load?

html  
asked by chobo 899 votes
answered by Valerij 1384 votes

Can you answer these?

Proguard removes Anonymous class in Anonymous class in Java

I have a issue that Proguard is not working when you declare a anonymous class within a anonymous class. This is what it looks like in a basic example: public class Class1 { public void function1 ...

java android proguard anonymous-class  
asked by Arne Fischer 7 votes

Grove Pi+ CO2 MH-Z16 sensor

I am using a Raspberry Pi 3 B model with a Grove Pi+ (1.2.2 firmware), and Raspbian for Robots Image. I have plugged in the CO2 MH-Z16 sensor in RPISER port, and I am trying to execute the code that ...

raspberry-pi raspbian grovepi+  
asked by Aitul 4 votes

Private member access in template substitution and SFINAE

class A { int a; }; template<typename, typename = void> class test {}; template<typename T> class test<T,decltype(T::a)> {}; int main() { test<A> a; } The code above ...

c++ templates gcc clang sfinae  
asked by Eichhörnchen 12 votes
Subscribe to more Stack Exchange newsletters


Unsubscribe from this newsletter or change your email preferences by visiting your subscriptions page on stackexchange.com.

Questions? Comments? Let us know on our feedback site. If you no longer want to receive mail from Stack Exchange, unsubscribe from all stackexchange.com emails.

Stack Exchange, Inc. 110 William St, 28th Floor, NY NY 10038 <3