C++14 | C++17 |
---|---|
namespace A {
namespace B {
namespace C {
struct Foo { };
//...
}
}
} |
namespace A::B::C {
struct Foo { };
//...
} |
C++14 | C++17 |
---|---|
static_assert(sizeof(short) == 2, "sizeof(short) == 2") |
static_assert(sizeof(short) == 2) |
Output | |
static assertion failure: sizeof(short) == 2 |
C++14 | C++17 |
---|---|
// foo.h
extern int foo;
// foo.cpp
int foo = 10; |
// foo.h
inline int foo = 10; |
C++14 | C++17 |
---|---|
// foo.h
struct Foo {
static int foo;
};
// foo.cpp
int Foo::foo = 10; |
// foo.h
struct Foo {
static inline int foo = 10;
}; |
C++17 |
---|
// header <mutex>
namespace std
{
template <typename M>
struct lock_guard
{
explicit lock_guard(M & mutex);
// not copyable, not movable:
lock_guard(lock_guard const & ) = delete;
//...
}
}
// your code
lock_guard<mutex> grab_lock(mutex & mtx)
{
return lock_guard<mutex>(mtx);
}
mutex mtx;
void foo()
{
auto guard = grab_lock(mtx);
/* do stuff holding lock */
}
|