Implement BOOST_OVERRIDE

This commit is contained in:
Glen Fernandes
2020-04-09 13:10:15 -04:00
parent b9eac83cb3
commit c6817bf70e
29 changed files with 181 additions and 2 deletions

View File

@ -93,6 +93,7 @@ obj cxx11_hdr_unordered_set : test_case.cpp : <define>TEST_BOOST_NO_CXX11_HDR_UN
obj cxx11_inline_namespaces : test_case.cpp : <define>TEST_BOOST_NO_CXX11_INLINE_NAMESPACES ;
obj cxx11_non_public_defaulted_functions : test_case.cpp : <define>TEST_BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS ;
obj cxx11_numeric_limits : test_case.cpp : <define>TEST_BOOST_NO_CXX11_NUMERIC_LIMITS ;
obj cxx11_override : test_case.cpp : <define>TEST_BOOST_NO_CXX11_OVERRIDE ;
obj cxx11_pointer_traits : test_case.cpp : <define>TEST_BOOST_NO_CXX11_POINTER_TRAITS ;
obj cxx11_ref_qualifiers : test_case.cpp : <define>TEST_BOOST_NO_CXX11_REF_QUALIFIERS ;
obj cxx11_sfinae_expr : test_case.cpp : <define>TEST_BOOST_NO_CXX11_SFINAE_EXPR ;

View File

@ -421,6 +421,11 @@
# error "Defect macro BOOST_NO_CXX11_NUMERIC_LIMITS is defined."
# endif
#endif
#ifdef TEST_BOOST_NO_CXX11_OVERRIDE
# ifdef BOOST_NO_CXX11_OVERRIDE
# error "Defect macro BOOST_NO_CXX11_OVERRIDE is defined."
# endif
#endif
#ifdef TEST_BOOST_NO_CXX11_POINTER_TRAITS
# ifdef BOOST_NO_CXX11_POINTER_TRAITS
# error "Defect macro BOOST_NO_CXX11_POINTER_TRAITS is defined."

View File

@ -685,6 +685,8 @@ compilers implementing an early draft of the C++11 standard (in particular, inco
[[`BOOST_NO_CXX11_NUMERIC_LIMITS`][The standard library `<limits>` header does
not support the C++11 version of `numeric_limits`.
]]
[[`BOOST_NO_CXX11_OVERRIDE`][The compiler does not support `override`.
]]
[[`BOOST_NO_CXX11_POINTER_TRAITS`][The standard library does not provide a
C++11 version of `std::pointer_traits` in <memory>.]]
[[`BOOST_NO_CXX11_RANGE_BASED_FOR`][The compiler does not support
@ -793,6 +795,10 @@ with:
static BOOST_CONSTEXPR_OR_CONST UIntType xor_mask = a;
``
]]
[[`BOOST_OVERRIDE`][
If `BOOST_NO_CXX11_OVERRIDE` is not defined (i.e. C++11 compliant compilers),
expands to `override` keyword, otherwise expands to nothing.
]]
[[`BOOST_STATIC_CONSTEXPR`][
This is a shortcut for `static BOOST_CONSTEXPR_OR_CONST`. For example, when defining const expr variables replace:
``

View File

@ -198,6 +198,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -250,6 +250,7 @@
#if !__has_feature(cxx_override_control)
# define BOOST_NO_CXX11_FINAL
# define BOOST_NO_CXX11_OVERRIDE
#endif
#if !__has_feature(cxx_unrestricted_unions)

View File

@ -251,6 +251,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_DECLTYPE_N3276
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -107,6 +107,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -201,6 +201,7 @@
#define BOOST_NO_CXX11_DELETED_FUNCTIONS
#define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
#define BOOST_NO_CXX11_LAMBDAS
#define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
@ -275,6 +276,7 @@
#undef BOOST_NO_CXX11_DELETED_FUNCTIONS
#undef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#undef BOOST_NO_CXX11_FINAL
#undef BOOST_NO_CXX11_OVERRIDE
#undef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
#undef BOOST_NO_CXX11_LAMBDAS
#undef BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
@ -346,6 +348,7 @@
#undef BOOST_NO_CXX11_CHAR32_T
#undef BOOST_NO_CXX11_INLINE_NAMESPACES
#undef BOOST_NO_CXX11_FINAL
#undef BOOST_NO_CXX11_OVERRIDE
#undef BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS
#undef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
#define BOOST_NO_CXX11_SFINAE_EXPR // This is correct, even though '*_fail.cpp' test fails.

View File

@ -83,6 +83,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -249,6 +249,7 @@
# define BOOST_NO_CXX11_TEMPLATE_ALIASES
# define BOOST_NO_CXX11_USER_DEFINED_LITERALS
# define BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS
# define BOOST_NO_CXX11_OVERRIDE
#endif
// C++0x features in 4.8.n and later

View File

@ -61,6 +61,7 @@
# define BOOST_NO_CXX11_INLINE_NAMESPACES
# define BOOST_NO_CXX11_REF_QUALIFIERS
# define BOOST_NO_CXX11_FINAL
# define BOOST_NO_CXX11_OVERRIDE
# define BOOST_NO_CXX11_THREAD_LOCAL
# define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -501,8 +501,10 @@ template<> struct assert_intrinsic_wchar_t<unsigned short> {};
#endif
// BOOST_NO_CXX11_FINAL
// BOOST_NO_CXX11_OVERRIDE
#if (BOOST_INTEL_CXX_VERSION >= 1400) && (!defined(BOOST_INTEL_GCC_VERSION) || (BOOST_INTEL_GCC_VERSION >= 40700)) && (!defined(_MSC_VER) || (_MSC_VER >= 1700))
# undef BOOST_NO_CXX11_FINAL
# undef BOOST_NO_CXX11_OVERRIDE
#endif
// BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -126,6 +126,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -75,6 +75,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -88,6 +88,7 @@
# define BOOST_NO_CXX11_INLINE_NAMESPACES
# define BOOST_NO_CXX11_REF_QUALIFIERS
# define BOOST_NO_CXX11_FINAL
# define BOOST_NO_CXX11_OVERRIDE
# define BOOST_NO_CXX11_THREAD_LOCAL
# define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -123,6 +123,7 @@
#define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_UNRESTRICTED_UNION
#endif

View File

@ -137,6 +137,7 @@
#define BOOST_NO_CXX11_INLINE_NAMESPACES
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_UNRESTRICTED_UNION

View File

@ -144,6 +144,7 @@
# define BOOST_NO_CXX11_FINAL
# define BOOST_NO_CXX11_RANGE_BASED_FOR
# define BOOST_NO_CXX11_SCOPED_ENUMS
# define BOOST_NO_CXX11_OVERRIDE
#endif // _MSC_VER < 1700
// C++11 features supported by VC++ 12 (aka 2013).

View File

@ -194,6 +194,7 @@
#if !__has_feature(cxx_override_control)
# define BOOST_NO_CXX11_FINAL
# define BOOST_NO_CXX11_OVERRIDE
#endif
#if !__has_feature(cxx_unrestricted_unions)

View File

@ -140,6 +140,7 @@
#define BOOST_NO_CXX11_THREAD_LOCAL
#define BOOST_NO_CXX11_REF_QUALIFIERS
#define BOOST_NO_CXX11_FINAL
#define BOOST_NO_CXX11_OVERRIDE
#define BOOST_NO_CXX11_ALIGNAS
#define BOOST_NO_CXX11_UNRESTRICTED_UNION
#define BOOST_NO_CXX14_VARIABLE_TEMPLATES

View File

@ -667,6 +667,12 @@ namespace std{ using ::type_info; }
# define BOOST_UNLIKELY(x) x
#endif
#if !defined(BOOST_NO_CXX11_OVERRIDE)
# define BOOST_OVERRIDE override
#else
# define BOOST_OVERRIDE
#endif
// Type and data alignment specification
//
#if !defined(BOOST_ALIGNMENT)

View File

@ -110,6 +110,7 @@ test-suite config
[ run helper_macros_test.cpp ]
[ compile pragma_message_test.cpp ]
[ compile header_deprecated_test.cpp ]
[ compile boost_override_test.cpp ]
;
obj has_clang_implicit_fallthrough : cmd_line_check.cpp :

View File

@ -1,7 +1,7 @@
#
# Regression test Jamfile for boost configuration setup.
# *** DO NOT EDIT THIS FILE BY HAND ***
# This file was automatically generated on Mon Dec 09 09:47:37 2019
# This file was automatically generated on Thu Apr 9 14:27:07 2020
# by libs/config/tools/generate.cpp
# Copyright John Maddock.
# Use, modification and distribution are subject to the
@ -268,6 +268,9 @@ test-suite "BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS" :
test-suite "BOOST_NO_CXX11_NUMERIC_LIMITS" :
[ run ../no_cxx11_numeric_limits_pass.cpp ]
[ compile-fail ../no_cxx11_numeric_limits_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_OVERRIDE" :
[ run ../no_cxx11_override_pass.cpp ]
[ compile-fail ../no_cxx11_override_fail.cpp ] ;
test-suite "BOOST_NO_CXX11_POINTER_TRAITS" :
[ run ../no_cxx11_pointer_traits_pass.cpp ]
[ compile-fail ../no_cxx11_pointer_traits_fail.cpp ] ;

View File

@ -0,0 +1,32 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
// MACRO: BOOST_NO_CXX11_OVERRIDE
// TITLE: C++11 SFINAE for expressions
// DESCRIPTION: C++11 SFINAE for expressions not supported.
namespace boost_no_cxx11_override {
struct base {
virtual void first() = 0;
virtual void second() { }
};
struct derived
: base {
void first() override { }
void second() override { }
};
int test()
{
return 0;
}
} /* boost_no_cxx11_override */

View File

@ -0,0 +1,19 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
struct base {
virtual void first() = 0;
virtual void second() { }
};
struct derived
: base {
void first() BOOST_OVERRIDE { }
void second() BOOST_OVERRIDE { }
};

View File

@ -1131,6 +1131,7 @@ void print_boost_macros()
PRINT_MACRO(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS);
PRINT_MACRO(BOOST_NO_CXX11_NULLPTR);
PRINT_MACRO(BOOST_NO_CXX11_NUMERIC_LIMITS);
PRINT_MACRO(BOOST_NO_CXX11_OVERRIDE);
PRINT_MACRO(BOOST_NO_CXX11_POINTER_TRAITS);
PRINT_MACRO(BOOST_NO_CXX11_RANGE_BASED_FOR);
PRINT_MACRO(BOOST_NO_CXX11_RAW_LITERALS);
@ -1234,6 +1235,7 @@ void print_boost_macros()
PRINT_MACRO(BOOST_NO_VOID_RETURNS);
// END GENERATED BLOCK
PRINT_MACRO(BOOST_INTEL);

View File

@ -1,4 +1,4 @@
// This file was automatically generated on Mon Dec 09 09:47:37 2019
// This file was automatically generated on Thu Apr 9 14:27:07 2020
// by libs/config/tools/generate.cpp
// Copyright John Maddock 2002-4.
// Use, modification and distribution are subject to the
@ -247,6 +247,11 @@ namespace boost_no_cxx11_non_public_defaulted_functions = empty_boost;
#else
namespace boost_no_cxx11_numeric_limits = empty_boost;
#endif
#ifndef BOOST_NO_CXX11_OVERRIDE
#include "boost_no_cxx11_override.ipp"
#else
namespace boost_no_cxx11_override = empty_boost;
#endif
#ifndef BOOST_NO_CXX11_POINTER_TRAITS
#include "boost_no_cxx11_pointer_traits.ipp"
#else
@ -1431,6 +1436,11 @@ int main( int, char *[] )
std::cerr << "Failed test for BOOST_NO_CXX11_NUMERIC_LIMITS at: " << __FILE__ << ":" << __LINE__ << std::endl;
++error_count;
}
if(0 != boost_no_cxx11_override::test())
{
std::cerr << "Failed test for BOOST_NO_CXX11_OVERRIDE at: " << __FILE__ << ":" << __LINE__ << std::endl;
++error_count;
}
if(0 != boost_no_cxx11_pointer_traits::test())
{
std::cerr << "Failed test for BOOST_NO_CXX11_POINTER_TRAITS at: " << __FILE__ << ":" << __LINE__ << std::endl;

View File

@ -0,0 +1,37 @@
// This file was automatically generated on Thu Apr 9 14:27:07 2020
// 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$
//
// Test file for macro BOOST_NO_CXX11_OVERRIDE
// This file should not compile, if it does then
// BOOST_NO_CXX11_OVERRIDE should not be defined.
// See file boost_no_cxx11_override.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_OVERRIDE
#include "boost_no_cxx11_override.ipp"
#else
#error "this file should not compile"
#endif
int main( int, char *[] )
{
return boost_no_cxx11_override::test();
}

View File

@ -0,0 +1,37 @@
// This file was automatically generated on Thu Apr 9 14:27:07 2020
// 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$
//
// Test file for macro BOOST_NO_CXX11_OVERRIDE
// This file should compile, if it does not then
// BOOST_NO_CXX11_OVERRIDE should be defined.
// See file boost_no_cxx11_override.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_OVERRIDE
#include "boost_no_cxx11_override.ipp"
#else
namespace boost_no_cxx11_override = empty_boost;
#endif
int main( int, char *[] )
{
return boost_no_cxx11_override::test();
}