I am a bit confused by the inline variable introduced by C++17. What are the differences between inline variable and inline static variable? Also will this be affected by scope?
inline T var_no_scope;
inline static T static_var_no_scope;
namespace scope {
inline T var_scope;
inline static T static_var_scope;
}
Any explanation will be appreciated!
For me it becomes more interesting when it is a data members. In
C++17you can declare your static data members asinline. The advantage is that you don't have to allocate space for them in asource file. For example:So
int A::b;can be removed from the source file.