From fe063709724f63d328fd2e07235e26bfe070bcba Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 29 May 2017 01:16:47 -0400 Subject: [PATCH] Add BOOST_NO_CXX17_STRUCTURED_BINDINGS detection --- checks/Jamfile.v2 | 3 +- checks/test_case.cpp | 7 +++- include/boost/config/compiler/borland.hpp | 8 ++++ include/boost/config/compiler/clang.hpp | 4 ++ include/boost/config/compiler/codegear.hpp | 9 +++++ include/boost/config/compiler/common_edg.hpp | 5 +++ include/boost/config/compiler/digitalmars.hpp | 5 +++ include/boost/config/compiler/gcc.hpp | 5 +++ include/boost/config/compiler/gcc_xml.hpp | 5 +++ include/boost/config/compiler/metrowerks.hpp | 5 +++ include/boost/config/compiler/mpw.hpp | 5 +++ include/boost/config/compiler/pathscale.hpp | 5 +++ include/boost/config/compiler/pgi.hpp | 5 +++ include/boost/config/compiler/sunpro_cc.hpp | 5 +++ include/boost/config/compiler/vacpp.hpp | 5 +++ include/boost/config/compiler/visualc.hpp | 2 + include/boost/config/compiler/xlcpp.hpp | 4 ++ include/boost/config/compiler/xlcpp_zos.hpp | 1 + test/all/Jamfile.v2 | 5 ++- test/boost_no_cxx17_structured_bindings.ipp | 36 ++++++++++++++++++ test/config_info.cpp | 2 + test/config_test.cpp | 12 +++++- test/no_cxx17_structured_bindings_fail.cpp | 37 +++++++++++++++++++ test/no_cxx17_structured_bindings_pass.cpp | 37 +++++++++++++++++++ 24 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 test/boost_no_cxx17_structured_bindings.ipp create mode 100644 test/no_cxx17_structured_bindings_fail.cpp create mode 100644 test/no_cxx17_structured_bindings_pass.cpp diff --git a/checks/Jamfile.v2 b/checks/Jamfile.v2 index 961501c3..73ece5f5 100644 --- a/checks/Jamfile.v2 +++ b/checks/Jamfile.v2 @@ -1,6 +1,6 @@ # # *** DO NOT EDIT THIS FILE BY HAND *** -# This file was automatically generated on Sun May 28 10:05:49 2017 +# This file was automatically generated on Mon May 29 09:56:04 2017 # by libs/config/tools/generate.cpp # Copyright John Maddock. # Use, modification and distribution are subject to the @@ -111,6 +111,7 @@ obj cxx14_std_exchange : test_case.cpp : TEST_BOOST_NO_CXX14_STD_EXCHANG obj cxx14_variable_templates : test_case.cpp : TEST_BOOST_NO_CXX14_VARIABLE_TEMPLATES ; obj cxx17_std_apply : test_case.cpp : TEST_BOOST_NO_CXX17_STD_APPLY ; obj cxx17_std_invoke : test_case.cpp : TEST_BOOST_NO_CXX17_STD_INVOKE ; +obj cxx17_structured_bindings : test_case.cpp : TEST_BOOST_NO_CXX17_STRUCTURED_BINDINGS ; obj cxx98_binders : test_case.cpp : TEST_BOOST_NO_CXX98_BINDERS ; obj cxx98_function_base : test_case.cpp : TEST_BOOST_NO_CXX98_FUNCTION_BASE ; obj cxx98_random_shuffle : test_case.cpp : TEST_BOOST_NO_CXX98_RANDOM_SHUFFLE ; diff --git a/checks/test_case.cpp b/checks/test_case.cpp index 76a12223..f27fb2bd 100644 --- a/checks/test_case.cpp +++ b/checks/test_case.cpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Sun May 28 10:05:49 2017 +// This file was automatically generated on Mon May 29 09:56:04 2017 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the @@ -511,6 +511,11 @@ # error "Defect macro BOOST_NO_CXX17_STD_INVOKE is defined." # endif #endif +#ifdef TEST_BOOST_NO_CXX17_STRUCTURED_BINDINGS +# ifdef BOOST_NO_CXX17_STRUCTURED_BINDINGS +# error "Defect macro BOOST_NO_CXX17_STRUCTURED_BINDINGS is defined." +# endif +#endif #ifdef TEST_BOOST_NO_CXX98_BINDERS # ifdef BOOST_NO_CXX98_BINDERS # error "Defect macro BOOST_NO_CXX98_BINDERS is defined." diff --git a/include/boost/config/compiler/borland.hpp b/include/boost/config/compiler/borland.hpp index b749496e..45b5afd1 100644 --- a/include/boost/config/compiler/borland.hpp +++ b/include/boost/config/compiler/borland.hpp @@ -228,6 +228,14 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif + #if __BORLANDC__ >= 0x590 # define BOOST_HAS_TR1_HASH diff --git a/include/boost/config/compiler/clang.hpp b/include/boost/config/compiler/clang.hpp index 175229c6..d7f7ecc1 100644 --- a/include/boost/config/compiler/clang.hpp +++ b/include/boost/config/compiler/clang.hpp @@ -282,6 +282,10 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + #if __cplusplus < 201103L #define BOOST_NO_CXX11_SFINAE_EXPR #endif diff --git a/include/boost/config/compiler/codegear.hpp b/include/boost/config/compiler/codegear.hpp index 3c5262fe..9aead59e 100644 --- a/include/boost/config/compiler/codegear.hpp +++ b/include/boost/config/compiler/codegear.hpp @@ -154,6 +154,15 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif + // // TR1 macros: // diff --git a/include/boost/config/compiler/common_edg.hpp b/include/boost/config/compiler/common_edg.hpp index eab93784..b1eea14d 100644 --- a/include/boost/config/compiler/common_edg.hpp +++ b/include/boost/config/compiler/common_edg.hpp @@ -138,6 +138,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + #ifdef c_plusplus // EDG has "long long" in non-strict mode // However, some libraries have insufficient "long long" support diff --git a/include/boost/config/compiler/digitalmars.hpp b/include/boost/config/compiler/digitalmars.hpp index e371a68e..5c680248 100644 --- a/include/boost/config/compiler/digitalmars.hpp +++ b/include/boost/config/compiler/digitalmars.hpp @@ -114,6 +114,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + #if (__DMC__ <= 0x840) #error "Compiler not supported or configured - please reconfigure" #endif diff --git a/include/boost/config/compiler/gcc.hpp b/include/boost/config/compiler/gcc.hpp index c82cbc7e..0272333a 100644 --- a/include/boost/config/compiler/gcc.hpp +++ b/include/boost/config/compiler/gcc.hpp @@ -288,6 +288,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + // // Unused attribute: #if __GNUC__ >= 4 diff --git a/include/boost/config/compiler/gcc_xml.hpp b/include/boost/config/compiler/gcc_xml.hpp index 63b08ac4..a71c1682 100644 --- a/include/boost/config/compiler/gcc_xml.hpp +++ b/include/boost/config/compiler/gcc_xml.hpp @@ -92,6 +92,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + #define BOOST_COMPILER "GCC-XML C++ version " __GCCXML__ diff --git a/include/boost/config/compiler/metrowerks.hpp b/include/boost/config/compiler/metrowerks.hpp index 8d42563c..24b26437 100644 --- a/include/boost/config/compiler/metrowerks.hpp +++ b/include/boost/config/compiler/metrowerks.hpp @@ -157,6 +157,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + #define BOOST_COMPILER "Metrowerks CodeWarrior C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) // diff --git a/include/boost/config/compiler/mpw.hpp b/include/boost/config/compiler/mpw.hpp index 1b8d39ea..687a3595 100644 --- a/include/boost/config/compiler/mpw.hpp +++ b/include/boost/config/compiler/mpw.hpp @@ -106,6 +106,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + // // versions check: // we don't support MPW prior to version 8.9: diff --git a/include/boost/config/compiler/pathscale.hpp b/include/boost/config/compiler/pathscale.hpp index 709f8cf8..aa5cc8c1 100644 --- a/include/boost/config/compiler/pathscale.hpp +++ b/include/boost/config/compiler/pathscale.hpp @@ -118,4 +118,9 @@ #if !defined(__cpp_variable_templates) || (__cpp_variable_templates < 201304) # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif + +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif #endif diff --git a/include/boost/config/compiler/pgi.hpp b/include/boost/config/compiler/pgi.hpp index af700514..4f851b9a 100644 --- a/include/boost/config/compiler/pgi.hpp +++ b/include/boost/config/compiler/pgi.hpp @@ -151,6 +151,11 @@ #if !defined(__cpp_variable_templates) || (__cpp_variable_templates < 201304) # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif + +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif // // version check: // probably nothing to do here? diff --git a/include/boost/config/compiler/sunpro_cc.hpp b/include/boost/config/compiler/sunpro_cc.hpp index cdd30b14..8efd0bfb 100644 --- a/include/boost/config/compiler/sunpro_cc.hpp +++ b/include/boost/config/compiler/sunpro_cc.hpp @@ -172,6 +172,11 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + // Turn on threading support for Solaris 12. // Ticket #11972 #if (__SUNPRO_CC >= 0x5140) && defined(__SunOS_5_12) && !defined(BOOST_HAS_THREADS) diff --git a/include/boost/config/compiler/vacpp.hpp b/include/boost/config/compiler/vacpp.hpp index b75a1bd1..a31fd12f 100644 --- a/include/boost/config/compiler/vacpp.hpp +++ b/include/boost/config/compiler/vacpp.hpp @@ -162,3 +162,8 @@ #if !defined(__cpp_variable_templates) || (__cpp_variable_templates < 201304) # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif + +// C++17 +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif diff --git a/include/boost/config/compiler/visualc.hpp b/include/boost/config/compiler/visualc.hpp index f51f0e1d..4786616d 100644 --- a/include/boost/config/compiler/visualc.hpp +++ b/include/boost/config/compiler/visualc.hpp @@ -218,6 +218,8 @@ // #define BOOST_NO_TWO_PHASE_NAME_LOOKUP #define BOOST_NO_CXX11_SFINAE_EXPR +// C++ 17: +#define BOOST_NO_CXX17_STRUCTURED_BINDINGS // // Things that don't work in clr mode: diff --git a/include/boost/config/compiler/xlcpp.hpp b/include/boost/config/compiler/xlcpp.hpp index 2aaafc3b..2bce08ac 100644 --- a/include/boost/config/compiler/xlcpp.hpp +++ b/include/boost/config/compiler/xlcpp.hpp @@ -238,6 +238,10 @@ # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif +#if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) +# define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#endif + #if !__has_feature(cxx_thread_local) # define BOOST_NO_CXX11_THREAD_LOCAL #endif diff --git a/include/boost/config/compiler/xlcpp_zos.hpp b/include/boost/config/compiler/xlcpp_zos.hpp index 7f6d2ad0..cc5e2363 100644 --- a/include/boost/config/compiler/xlcpp_zos.hpp +++ b/include/boost/config/compiler/xlcpp_zos.hpp @@ -150,6 +150,7 @@ #define BOOST_NO_CXX14_DECLTYPE_AUTO #define BOOST_NO_CXX14_CONSTEXPR #define BOOST_NO_CXX14_BINARY_LITERALS +#define BOOST_NO_CXX17_STRUCTURED_BINDINGS // ------------------------------------- diff --git a/test/all/Jamfile.v2 b/test/all/Jamfile.v2 index 22be62f8..c47fd69c 100644 --- a/test/all/Jamfile.v2 +++ b/test/all/Jamfile.v2 @@ -1,7 +1,7 @@ # # Regression test Jamfile for boost configuration setup. # *** DO NOT EDIT THIS FILE BY HAND *** -# This file was automatically generated on Sun May 28 10:05:49 2017 +# This file was automatically generated on Mon May 29 09:56:04 2017 # by libs/config/tools/generate.cpp # Copyright John Maddock. # Use, modification and distribution are subject to the @@ -322,6 +322,9 @@ test-suite "BOOST_NO_CXX17_STD_APPLY" : test-suite "BOOST_NO_CXX17_STD_INVOKE" : [ run ../no_cxx17_std_invoke_pass.cpp ] [ compile-fail ../no_cxx17_std_invoke_fail.cpp ] ; +test-suite "BOOST_NO_CXX17_STRUCTURED_BINDINGS" : +[ run ../no_cxx17_structured_bindings_pass.cpp ] +[ compile-fail ../no_cxx17_structured_bindings_fail.cpp ] ; test-suite "BOOST_NO_CXX98_BINDERS" : [ run ../no_cxx98_binders_pass.cpp ] [ compile-fail ../no_cxx98_binders_fail.cpp ] ; diff --git a/test/boost_no_cxx17_structured_bindings.ipp b/test/boost_no_cxx17_structured_bindings.ipp new file mode 100644 index 00000000..c5c72598 --- /dev/null +++ b/test/boost_no_cxx17_structured_bindings.ipp @@ -0,0 +1,36 @@ +/* +Copyright 2017 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_CXX17_STRUCTURED_BINDINGS +// TITLE: C++17 structured bindings +// DESCRIPTION: C++17 structured bindings are not supported. + +#include + +namespace boost_no_cxx17_structured_bindings { + +struct P { + int x; + int y; +}; + +int test() +{ + auto [c, d] = std::make_tuple(1, 2); + if (c != 1 || d != 2) { + return 1; + } + auto [a, b] = P{1, 2}; + if (a != 1 || b != 2) { + return 1; + } + return 0; +} + +} /* boost_no_cxx17_structured_bindings */ diff --git a/test/config_info.cpp b/test/config_info.cpp index 2b6b862b..dee413c7 100644 --- a/test/config_info.cpp +++ b/test/config_info.cpp @@ -1069,6 +1069,7 @@ void print_boost_macros() PRINT_MACRO(BOOST_NO_CXX14_VARIABLE_TEMPLATES); PRINT_MACRO(BOOST_NO_CXX17_STD_APPLY); PRINT_MACRO(BOOST_NO_CXX17_STD_INVOKE); + PRINT_MACRO(BOOST_NO_CXX17_STRUCTURED_BINDINGS); PRINT_MACRO(BOOST_NO_CXX98_BINDERS); PRINT_MACRO(BOOST_NO_CXX98_FUNCTION_BASE); PRINT_MACRO(BOOST_NO_CXX98_RANDOM_SHUFFLE); @@ -1156,6 +1157,7 @@ void print_boost_macros() + // END GENERATED BLOCK diff --git a/test/config_test.cpp b/test/config_test.cpp index a263c911..6860b00b 100644 --- a/test/config_test.cpp +++ b/test/config_test.cpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Sun May 28 10:05:49 2017 +// This file was automatically generated on Mon May 29 09:56:04 2017 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the @@ -342,6 +342,11 @@ namespace boost_no_cxx17_std_apply = empty_boost; #else namespace boost_no_cxx17_std_invoke = empty_boost; #endif +#ifndef BOOST_NO_CXX17_STRUCTURED_BINDINGS +#include "boost_no_cxx17_structured_bindings.ipp" +#else +namespace boost_no_cxx17_structured_bindings = empty_boost; +#endif #ifndef BOOST_NO_CXX98_BINDERS #include "boost_no_cxx98_binders.ipp" #else @@ -1461,6 +1466,11 @@ int main( int, char *[] ) std::cerr << "Failed test for BOOST_NO_CXX17_STD_INVOKE at: " << __FILE__ << ":" << __LINE__ << std::endl; ++error_count; } + if(0 != boost_no_cxx17_structured_bindings::test()) + { + std::cerr << "Failed test for BOOST_NO_CXX17_STRUCTURED_BINDINGS at: " << __FILE__ << ":" << __LINE__ << std::endl; + ++error_count; + } if(0 != boost_no_cxx98_binders::test()) { std::cerr << "Failed test for BOOST_NO_CXX98_BINDERS at: " << __FILE__ << ":" << __LINE__ << std::endl; diff --git a/test/no_cxx17_structured_bindings_fail.cpp b/test/no_cxx17_structured_bindings_fail.cpp new file mode 100644 index 00000000..9b7b1fb1 --- /dev/null +++ b/test/no_cxx17_structured_bindings_fail.cpp @@ -0,0 +1,37 @@ +// This file was automatically generated on Mon May 29 09:56:04 2017 +// 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_CXX17_STRUCTURED_BINDINGS +// This file should not compile, if it does then +// BOOST_NO_CXX17_STRUCTURED_BINDINGS should not be defined. +// See file boost_no_cxx17_structured_bindings.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 +#include "test.hpp" + +#ifdef BOOST_NO_CXX17_STRUCTURED_BINDINGS +#include "boost_no_cxx17_structured_bindings.ipp" +#else +#error "this file should not compile" +#endif + +int main( int, char *[] ) +{ + return boost_no_cxx17_structured_bindings::test(); +} + diff --git a/test/no_cxx17_structured_bindings_pass.cpp b/test/no_cxx17_structured_bindings_pass.cpp new file mode 100644 index 00000000..312e0c0c --- /dev/null +++ b/test/no_cxx17_structured_bindings_pass.cpp @@ -0,0 +1,37 @@ +// This file was automatically generated on Mon May 29 09:56:04 2017 +// 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_CXX17_STRUCTURED_BINDINGS +// This file should compile, if it does not then +// BOOST_NO_CXX17_STRUCTURED_BINDINGS should be defined. +// See file boost_no_cxx17_structured_bindings.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 +#include "test.hpp" + +#ifndef BOOST_NO_CXX17_STRUCTURED_BINDINGS +#include "boost_no_cxx17_structured_bindings.ipp" +#else +namespace boost_no_cxx17_structured_bindings = empty_boost; +#endif + +int main( int, char *[] ) +{ + return boost_no_cxx17_structured_bindings::test(); +} +