Skip to content

Commit 4f53b21

Browse files
committed
Adding a macro for library writers to do version namespaces.
1 parent d77c825 commit 4f53b21

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2015, Chris Blume
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are
6+
// met:
7+
//
8+
// * Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// * Redistributions in binary form must reproduce the above
11+
// copyright notice, this list of conditions and the following disclaimer
12+
// in the documentation and/or other materials provided with the
13+
// distribution.
14+
// * Neither the name of Chris Blume nor the
15+
// names of its contributors may be used to endorse or promote products
16+
// derived from this software without specific prior written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
#ifndef MAX_COMPILING_CURRENTVERSIONNAMESPACE_HPP
31+
#define MAX_COMPILING_CURRENTVERSIONNAMESPACE_HPP
32+
33+
// Note: These two macro definitions do not behave identically.
34+
// Inline namespaces from C++11 allow templated types to be specialized
35+
// from their included namespace. Using namespace does not allow that.
36+
// Additionally, the parent namespace is included in ADL with
37+
// inline namespaces.
38+
39+
#include <max/Compiling/Configuration/Compiler.hpp>
40+
41+
#ifndef MAX_INLINE_NAMESPACES_SUPPORTED
42+
#define MAX_CURRENT_VERSION_NAMESPACE_BEGIN( Name ) inline namespace Name
43+
#define MAX_CURRENT_VERSION_NAMESPACE_END( Name )
44+
#else
45+
#define MAX_CURRENT_VERSION_NAMESPACE_BEGIN( Name ) namespace Name
46+
#define MAX_CURRENT_VERSION_NAMESPACE_END( Name ) using namespace Name;
47+
#endif
48+
49+
#endif // #ifndef MAX_COMPILING_CURRENTVERSIONNAMESPACE_HPP

0 commit comments

Comments
 (0)