mirror of
https://github.com/boostorg/config.git
synced 2025-07-30 04:17:16 +02:00
Merge config doc and test updates.
[SVN r84462]
This commit is contained in:
@ -2974,6 +2974,18 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">BOOST_NO_CXX11_USER_DEFINED_LITERALS</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The compiler does not support user defined literals.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">BOOST_NO_CXX11_VARIADIC_TEMPLATES</span></code>
|
||||
@ -3382,6 +3394,54 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">BOOST_FALLTHROUGH</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
|
||||
between switch labels:
|
||||
</p>
|
||||
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">switch</span> <span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">{</span>
|
||||
<span class="keyword">case</span> <span class="number">40</span><span class="special">:</span>
|
||||
<span class="keyword">case</span> <span class="number">41</span><span class="special">:</span>
|
||||
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">truth_is_out_there</span><span class="special">)</span> <span class="special">{</span>
|
||||
<span class="special">++</span><span class="identifier">x</span><span class="special">;</span>
|
||||
<span class="identifier">BOOST_FALLTHROUGH</span><span class="special">;</span> <span class="comment">// Use instead of/along with annotations in </span>
|
||||
<span class="comment">// comments. </span>
|
||||
<span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">case</span> <span class="number">42</span><span class="special">:</span>
|
||||
<span class="special">...</span>
|
||||
</pre>
|
||||
<p>
|
||||
As shown in the example above, the BOOST_FALLTHROUGH macro should
|
||||
be followed by a semicolon. It is designed to mimic control-flow
|
||||
statements like 'break;', so it can be placed in most places where
|
||||
'break;' can, but only if there are no statements on the execution
|
||||
path between it and the next switch label.
|
||||
</p>
|
||||
<p>
|
||||
When compiled with Clang >3.2 in C++11 mode, the BOOST_FALLTHROUGH
|
||||
macro is expanded to <code class="computeroutput"><span class="special">[[</span><span class="identifier">clang</span><span class="special">::</span><span class="identifier">fallthrough</span><span class="special">]]</span></code>
|
||||
attribute, which is analysed when performing switch labels fall-through
|
||||
diagnostic ('-Wimplicit-fallthrough'). See clang <a href="http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough" target="_top">documentation
|
||||
on language extensions for details.</a>
|
||||
</p>
|
||||
<p>
|
||||
When used with unsupported compilers, the BOOST_FALLTHROUGH macro
|
||||
has no effect on diagnostics.
|
||||
</p>
|
||||
<p>
|
||||
In either case this macro has no effect on runtime behavior and
|
||||
performance of code.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">BOOST_EXPLICIT_TEMPLATE_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> <code class="computeroutput"><span class="identifier">BOOST_EXPLICIT_TEMPLATE_NON_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">,</span><span class="identifier">v</span><span class="special">)</span></code> <code class="computeroutput"><span class="identifier">BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">)</span></code> <code class="computeroutput"><span class="identifier">BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE</span><span class="special">(</span><span class="identifier">t</span><span class="special">,</span><span class="identifier">v</span><span class="special">)</span></code>
|
||||
|
@ -951,7 +951,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: February 19, 2013 at 16:25:18 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: April 28, 2013 at 17:55:14 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -675,6 +675,8 @@ Unicode (`u8`, `u`, `U`) literals.
|
||||
[[`BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX`][The compiler does not support
|
||||
the [@http://en.wikipedia.org/wiki/C%2B%2B0x#Uniform_initialization C++11 Unified Initialization Syntax].
|
||||
]]
|
||||
[[`BOOST_NO_CXX11_USER_DEFINED_LITERALS`][The compiler does not support user defined literals.
|
||||
]]
|
||||
[[`BOOST_NO_CXX11_VARIADIC_TEMPLATES`][The compiler does not support
|
||||
variadic templates.
|
||||
]]
|
||||
@ -862,6 +864,41 @@ struct foo{
|
||||
Normally evaluates to nothing, but evaluates to return x; if the compiler
|
||||
requires a return, even when it can never be reached.
|
||||
]]
|
||||
[[`BOOST_FALLTHROUGH`][
|
||||
The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through
|
||||
between switch labels:
|
||||
``
|
||||
switch (x) {
|
||||
case 40:
|
||||
case 41:
|
||||
if (truth_is_out_there) {
|
||||
++x;
|
||||
BOOST_FALLTHROUGH; // Use instead of/along with annotations in
|
||||
// comments.
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
case 42:
|
||||
...
|
||||
``
|
||||
As shown in the example above, the BOOST_FALLTHROUGH macro should be
|
||||
followed by a semicolon. It is designed to mimic control-flow statements
|
||||
like 'break;', so it can be placed in most places where 'break;' can, but
|
||||
only if there are no statements on the execution path between it and the
|
||||
next switch label.
|
||||
|
||||
When compiled with Clang >3.2 in C++11 mode, the BOOST_FALLTHROUGH macro is
|
||||
expanded to `[[clang::fallthrough]]` attribute, which is analysed when
|
||||
performing switch labels fall-through diagnostic ('-Wimplicit-fallthrough').
|
||||
See clang [@http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough
|
||||
documentation on language extensions for details.]
|
||||
|
||||
When used with unsupported compilers, the BOOST_FALLTHROUGH macro has no
|
||||
effect on diagnostics.
|
||||
|
||||
In either case this macro has no effect on runtime behavior and performance
|
||||
of code.
|
||||
]]
|
||||
[[`BOOST_EXPLICIT_TEMPLATE_TYPE(t)`
|
||||
`BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t,v)`
|
||||
`BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)`
|
||||
|
@ -65,4 +65,5 @@ test-suite config
|
||||
]
|
||||
[ compile-fail threads/test_thread_fail1.cpp ]
|
||||
[ compile-fail threads/test_thread_fail2.cpp ]
|
||||
[ compile boost_fallthrough_test.cpp : <toolset>clang:<cxxflags>"-std=c++11 -Wimplicit-fallthrough" <warnings-as-errors>on <warnings>all ]
|
||||
;
|
||||
|
File diff suppressed because it is too large
Load Diff
20
test/boost_fallthrough_test.cpp
Normal file
20
test/boost_fallthrough_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
int test(int n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 0:
|
||||
n++;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 1:
|
||||
n++;
|
||||
break;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
67
test/boost_no_cxx11_user_lit.ipp
Normal file
67
test/boost_no_cxx11_user_lit.ipp
Normal file
@ -0,0 +1,67 @@
|
||||
// (C) Copyright John Maddock 2013
|
||||
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/config for more information.
|
||||
|
||||
// MACRO: BOOST_NO_CXX11_USER_DEFINED_LITERALS
|
||||
// TITLE: C++11 user defined literals.
|
||||
// DESCRIPTION: The compiler does not support the C++11 literals including user-defined suffixes.
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace boost_no_cxx11_user_defined_literals {
|
||||
|
||||
struct my_literal
|
||||
{
|
||||
constexpr my_literal() : val(0) {}
|
||||
constexpr my_literal(int i) : val(i) {}
|
||||
constexpr my_literal(const my_literal& a) : val(a.val) {}
|
||||
constexpr bool operator==(const my_literal& a) { return val == a.val; }
|
||||
int val;
|
||||
};
|
||||
|
||||
template <unsigned base, unsigned long long val, char... Digits>
|
||||
struct parse_int
|
||||
{
|
||||
// The default specialization is also the termination condition:
|
||||
// it gets invoked only when sizeof...Digits == 0.
|
||||
static_assert(base<=16u,"only support up to hexadecimal");
|
||||
static constexpr unsigned long long value{ val };
|
||||
};
|
||||
|
||||
template <unsigned base, unsigned long long val, char c, char... Digits>
|
||||
struct parse_int<base, val, c, Digits...>
|
||||
{
|
||||
static constexpr unsigned long long char_value = (c >= '0' && c <= '9')
|
||||
? c - '0'
|
||||
: (c >= 'a' && c <= 'f')
|
||||
? c - 'a'
|
||||
: (c >= 'A' && c <= 'F')
|
||||
? c - 'A'
|
||||
: 400u;
|
||||
static_assert(char_value < base, "Encountered a digit out of range");
|
||||
static constexpr unsigned long long value{ parse_int<base, val * base +
|
||||
char_value, Digits...>::value };
|
||||
};
|
||||
|
||||
constexpr my_literal operator "" _suf1(unsigned long long v)
|
||||
{
|
||||
return my_literal(v);
|
||||
}
|
||||
template <char...PACK>
|
||||
constexpr my_literal operator "" _bin()
|
||||
{
|
||||
return parse_int<2, 0, PACK...>::value;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
constexpr my_literal a = 0x23_suf1;
|
||||
constexpr my_literal b = 1001_bin;
|
||||
return ((a == my_literal(0x23)) && (b == my_literal(9))) ? 0 : 1;
|
||||
}
|
||||
|
||||
}
|
@ -563,6 +563,8 @@ void print_stdlib_macros()
|
||||
PRINT_MACRO(_HAS_EXCEPTIONS);
|
||||
PRINT_MACRO(_HAS_MEMBER_TEMPLATES_REBIND);
|
||||
PRINT_MACRO(_HAS_TEMPLATE_PARTIAL_ORDERING);
|
||||
// Libc++:
|
||||
PRINT_MACRO(_LIBCPP_VERSION);
|
||||
// STLPort and generic SGI STL options:
|
||||
PRINT_MACRO(__SGI_STL_NO_ARROW_OPERATOR);
|
||||
PRINT_MACRO(__SGI_STL_OWN_IOSTREAMS);
|
||||
@ -1037,6 +1039,7 @@ void print_boost_macros()
|
||||
PRINT_MACRO(BOOST_NO_CXX11_TEMPLATE_ALIASES);
|
||||
PRINT_MACRO(BOOST_NO_CXX11_UNICODE_LITERALS);
|
||||
PRINT_MACRO(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX);
|
||||
PRINT_MACRO(BOOST_NO_CXX11_USER_DEFINED_LITERALS);
|
||||
PRINT_MACRO(BOOST_NO_CXX11_VARIADIC_MACROS);
|
||||
PRINT_MACRO(BOOST_NO_CXX11_VARIADIC_TEMPLATES);
|
||||
PRINT_MACRO(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS);
|
||||
@ -1098,25 +1101,6 @@ void print_boost_macros()
|
||||
PRINT_MACRO(BOOST_NO_USING_TEMPLATE);
|
||||
PRINT_MACRO(BOOST_NO_VOID_RETURNS);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// END GENERATED BLOCK
|
||||
@ -1130,6 +1114,7 @@ void print_boost_macros()
|
||||
PRINT_MACRO(BOOST_STATIC_CONSTEXPR);
|
||||
PRINT_MACRO(BOOST_NOEXCEPT);
|
||||
PRINT_MACRO(BOOST_FORCEINLINE);
|
||||
PRINT_MACRO(BOOST_FALLTHROUGH);
|
||||
}
|
||||
|
||||
void print_separator()
|
||||
|
2980
test/config_test.cpp
2980
test/config_test.cpp
File diff suppressed because it is too large
Load Diff
37
test/no_cxx11_user_lit_fail.cpp
Normal file
37
test/no_cxx11_user_lit_fail.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// This file was automatically generated on Sun Apr 28 18:36:48 2013
|
||||
// by libs/config/tools/generate.cpp
|
||||
// Copyright John Maddock 2002-4.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/config for the most recent version.//
|
||||
// Revision $Id: generate.cpp 72327 2011-06-01 14:51:03Z eric_niebler $
|
||||
//
|
||||
|
||||
|
||||
// Test file for macro BOOST_NO_CXX11_USER_DEFINED_LITERALS
|
||||
// This file should not compile, if it does then
|
||||
// BOOST_NO_CXX11_USER_DEFINED_LITERALS should not be defined.
|
||||
// See file boost_no_cxx11_user_lit.ipp for details
|
||||
|
||||
// Must not have BOOST_ASSERT_CONFIG set; it defeats
|
||||
// the objective of this file:
|
||||
#ifdef BOOST_ASSERT_CONFIG
|
||||
# undef BOOST_ASSERT_CONFIG
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include "test.hpp"
|
||||
|
||||
#ifdef BOOST_NO_CXX11_USER_DEFINED_LITERALS
|
||||
#include "boost_no_cxx11_user_lit.ipp"
|
||||
#else
|
||||
#error "this file should not compile"
|
||||
#endif
|
||||
|
||||
int main( int, char *[] )
|
||||
{
|
||||
return boost_no_cxx11_user_defined_literals::test();
|
||||
}
|
||||
|
37
test/no_cxx11_user_lit_pass.cpp
Normal file
37
test/no_cxx11_user_lit_pass.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// This file was automatically generated on Sun Apr 28 18:36:48 2013
|
||||
// by libs/config/tools/generate.cpp
|
||||
// Copyright John Maddock 2002-4.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/config for the most recent version.//
|
||||
// Revision $Id: generate.cpp 72327 2011-06-01 14:51:03Z eric_niebler $
|
||||
//
|
||||
|
||||
|
||||
// Test file for macro BOOST_NO_CXX11_USER_DEFINED_LITERALS
|
||||
// This file should compile, if it does not then
|
||||
// BOOST_NO_CXX11_USER_DEFINED_LITERALS should be defined.
|
||||
// See file boost_no_cxx11_user_lit.ipp for details
|
||||
|
||||
// Must not have BOOST_ASSERT_CONFIG set; it defeats
|
||||
// the objective of this file:
|
||||
#ifdef BOOST_ASSERT_CONFIG
|
||||
# undef BOOST_ASSERT_CONFIG
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include "test.hpp"
|
||||
|
||||
#ifndef BOOST_NO_CXX11_USER_DEFINED_LITERALS
|
||||
#include "boost_no_cxx11_user_lit.ipp"
|
||||
#else
|
||||
namespace boost_no_cxx11_user_defined_literals = empty_boost;
|
||||
#endif
|
||||
|
||||
int main( int, char *[] )
|
||||
{
|
||||
return boost_no_cxx11_user_defined_literals::test();
|
||||
}
|
||||
|
Reference in New Issue
Block a user