From dad856418f8c84954a99b32d417225302412d60f Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 5 Jun 2022 16:59:35 +0100 Subject: [PATCH] Add BOOST_NO_CXX17_DEDUCTION_GUIDES. Replaces https://github.com/boostorg/config/pull/414. --- checks/Jamfile.v2 | 3 +- checks/test_case.cpp | 7 +++- doc/macro_reference.qbk | 1 + include/boost/config/assert_cxx03.hpp | 2 +- include/boost/config/assert_cxx11.hpp | 2 +- include/boost/config/assert_cxx14.hpp | 2 +- include/boost/config/assert_cxx17.hpp | 5 ++- include/boost/config/assert_cxx20.hpp | 2 +- include/boost/config/detail/cxx_composite.hpp | 3 +- include/boost/config/detail/suffix.hpp | 4 ++ test/all/Jamfile.v2 | 5 ++- test/boost_no_cxx17_deduction_guides.ipp | 34 +++++++++++++++++ test/config_info.cpp | 2 + test/config_test.cpp | 12 +++++- test/no_cxx17_deduction_guides_fail.cpp | 37 +++++++++++++++++++ test/no_cxx17_deduction_guides_pass.cpp | 37 +++++++++++++++++++ 16 files changed, 148 insertions(+), 10 deletions(-) create mode 100644 test/boost_no_cxx17_deduction_guides.ipp create mode 100644 test/no_cxx17_deduction_guides_fail.cpp create mode 100644 test/no_cxx17_deduction_guides_pass.cpp diff --git a/checks/Jamfile.v2 b/checks/Jamfile.v2 index 75ee4398..12c75ebc 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 Thu Feb 3 18:10:41 2022 +# This file was automatically generated on Sun Jun 5 16:50:18 2022 # by libs/config/tools/generate.cpp # Copyright John Maddock. # Use, modification and distribution are subject to the @@ -118,6 +118,7 @@ obj cxx14_return_type_deduction : test_case.cpp : TEST_BOOST_NO_CXX14_RE obj cxx14_std_exchange : test_case.cpp : TEST_BOOST_NO_CXX14_STD_EXCHANGE ; obj cxx14_variable_templates : test_case.cpp : TEST_BOOST_NO_CXX14_VARIABLE_TEMPLATES ; obj cxx17 : test_case.cpp : TEST_BOOST_NO_CXX17 ; +obj cxx17_deduction_guides : test_case.cpp : TEST_BOOST_NO_CXX17_DEDUCTION_GUIDES ; obj cxx17_fold_expressions : test_case.cpp : TEST_BOOST_NO_CXX17_FOLD_EXPRESSIONS ; obj cxx17_hdr_any : test_case.cpp : TEST_BOOST_NO_CXX17_HDR_ANY ; obj cxx17_hdr_charconv : test_case.cpp : TEST_BOOST_NO_CXX17_HDR_CHARCONV ; diff --git a/checks/test_case.cpp b/checks/test_case.cpp index d34f871e..844a39c2 100644 --- a/checks/test_case.cpp +++ b/checks/test_case.cpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the @@ -546,6 +546,11 @@ # error "Defect macro BOOST_NO_CXX17 is defined." # endif #endif +#ifdef TEST_BOOST_NO_CXX17_DEDUCTION_GUIDES +# ifdef BOOST_NO_CXX17_DEDUCTION_GUIDES +# error "Defect macro BOOST_NO_CXX17_DEDUCTION_GUIDES is defined." +# endif +#endif #ifdef TEST_BOOST_NO_CXX17_FOLD_EXPRESSIONS # ifdef BOOST_NO_CXX17_FOLD_EXPRESSIONS # error "Defect macro BOOST_NO_CXX17_FOLD_EXPRESSIONS is defined." diff --git a/doc/macro_reference.qbk b/doc/macro_reference.qbk index b21bf08a..d2eac0f0 100644 --- a/doc/macro_reference.qbk +++ b/doc/macro_reference.qbk @@ -1041,6 +1041,7 @@ that are not yet supported by a particular compiler or library. [[`BOOST_NO_CXX17_ITERATOR_TRAITS`][The compiler does not support SFINAE-friendly `std::iterator_traits`.]] [[`BOOST_NO_CXX17_IF_CONSTEXPR`][The compiler does not support `if constexpr`.]] [[`BOOST_NO_CXX17_INLINE_VARIABLES`][The compiler does not support `inline` variables.]] +[[`BOOST_NO_CXX17_DEDUCTION_GUIDES`][The compiler does not class template argument deduction (CTAD) guides.]] ] [endsect] diff --git a/include/boost/config/assert_cxx03.hpp b/include/boost/config/assert_cxx03.hpp index 682309d4..03360a93 100644 --- a/include/boost/config/assert_cxx03.hpp +++ b/include/boost/config/assert_cxx03.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the diff --git a/include/boost/config/assert_cxx11.hpp b/include/boost/config/assert_cxx11.hpp index c3712c27..b029a274 100644 --- a/include/boost/config/assert_cxx11.hpp +++ b/include/boost/config/assert_cxx11.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the diff --git a/include/boost/config/assert_cxx14.hpp b/include/boost/config/assert_cxx14.hpp index 3f979cbf..1d3132a1 100644 --- a/include/boost/config/assert_cxx14.hpp +++ b/include/boost/config/assert_cxx14.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the diff --git a/include/boost/config/assert_cxx17.hpp b/include/boost/config/assert_cxx17.hpp index f06b9ed4..cd41be61 100644 --- a/include/boost/config/assert_cxx17.hpp +++ b/include/boost/config/assert_cxx17.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the @@ -12,6 +12,9 @@ #include #include +#ifdef BOOST_NO_CXX17_DEDUCTION_GUIDES +# error "Your compiler appears not to be fully C++17 compliant. Detected via defect macro BOOST_NO_CXX17_DEDUCTION_GUIDES." +#endif #ifdef BOOST_NO_CXX17_FOLD_EXPRESSIONS # error "Your compiler appears not to be fully C++17 compliant. Detected via defect macro BOOST_NO_CXX17_FOLD_EXPRESSIONS." #endif diff --git a/include/boost/config/assert_cxx20.hpp b/include/boost/config/assert_cxx20.hpp index af7e0414..c1482778 100644 --- a/include/boost/config/assert_cxx20.hpp +++ b/include/boost/config/assert_cxx20.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the diff --git a/include/boost/config/detail/cxx_composite.hpp b/include/boost/config/detail/cxx_composite.hpp index 5178c25a..a243d41f 100644 --- a/include/boost/config/detail/cxx_composite.hpp +++ b/include/boost/config/detail/cxx_composite.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the @@ -163,6 +163,7 @@ #endif #if defined(BOOST_NO_CXX14)\ + || defined(BOOST_NO_CXX17_DEDUCTION_GUIDES)\ || defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS)\ || defined(BOOST_NO_CXX17_HDR_ANY)\ || defined(BOOST_NO_CXX17_HDR_CHARCONV)\ diff --git a/include/boost/config/detail/suffix.hpp b/include/boost/config/detail/suffix.hpp index d266ca98..318ffa9c 100644 --- a/include/boost/config/detail/suffix.hpp +++ b/include/boost/config/detail/suffix.hpp @@ -1219,6 +1219,10 @@ namespace std{ using ::type_info; } # define BOOST_NO_CXX20_HDR_VERSION #endif +#if !defined(__cpp_deduction_guides) || (__cpp_deduction_guides < 201606) +# define BOOST_NO_CXX17_DEDUCTION_GUIDES +#endif + // // Define composite agregate macros: // diff --git a/test/all/Jamfile.v2 b/test/all/Jamfile.v2 index badabbfa..493bb78b 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 Thu Feb 3 18:10:41 2022 +# This file was automatically generated on Sun Jun 5 16:50:18 2022 # by libs/config/tools/generate.cpp # Copyright John Maddock. # Use, modification and distribution are subject to the @@ -343,6 +343,9 @@ test-suite "BOOST_NO_CXX14_VARIABLE_TEMPLATES" : test-suite "BOOST_NO_CXX17" : [ run ../no_cxx17_pass.cpp ] [ compile-fail ../no_cxx17_fail.cpp ] ; +test-suite "BOOST_NO_CXX17_DEDUCTION_GUIDES" : +[ run ../no_cxx17_deduction_guides_pass.cpp ] +[ compile-fail ../no_cxx17_deduction_guides_fail.cpp ] ; test-suite "BOOST_NO_CXX17_FOLD_EXPRESSIONS" : [ run ../no_cxx17_fold_expressions_pass.cpp ] [ compile-fail ../no_cxx17_fold_expressions_fail.cpp ] ; diff --git a/test/boost_no_cxx17_deduction_guides.ipp b/test/boost_no_cxx17_deduction_guides.ipp new file mode 100644 index 00000000..2ce69082 --- /dev/null +++ b/test/boost_no_cxx17_deduction_guides.ipp @@ -0,0 +1,34 @@ +/* + * Copyright 2022 Andrey Semashev + * + * 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_DEDUCTION_GUIDES + // TITLE: C++17 class template argument deduction guides + // DESCRIPTION: C++17 class template argument deduction guides are not supported. + +namespace boost_no_cxx17_deduction_guides { + + template< typename T > + struct foo + { + T m_val; + + template< typename U > + foo(U const& x) : m_val(x) {} + }; + + template< typename T > + foo(T const&)->foo< T >; + + + int test() + { + foo x1(10); + return x1.m_val - 10; + } + +} // boost_no_cxx17_deduction_guides diff --git a/test/config_info.cpp b/test/config_info.cpp index ab374d57..f2eb7779 100644 --- a/test/config_info.cpp +++ b/test/config_info.cpp @@ -1167,6 +1167,7 @@ void print_boost_macros() PRINT_MACRO(BOOST_NO_CXX14_STD_EXCHANGE); PRINT_MACRO(BOOST_NO_CXX14_VARIABLE_TEMPLATES); PRINT_MACRO(BOOST_NO_CXX17); + PRINT_MACRO(BOOST_NO_CXX17_DEDUCTION_GUIDES); PRINT_MACRO(BOOST_NO_CXX17_FOLD_EXPRESSIONS); PRINT_MACRO(BOOST_NO_CXX17_HDR_ANY); PRINT_MACRO(BOOST_NO_CXX17_HDR_CHARCONV); @@ -1266,6 +1267,7 @@ void print_boost_macros() + // END GENERATED BLOCK PRINT_MACRO(BOOST_CXX_VERSION); diff --git a/test/config_test.cpp b/test/config_test.cpp index 06387e7b..b04e74e1 100644 --- a/test/config_test.cpp +++ b/test/config_test.cpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Thu Feb 3 18:10:41 2022 +// This file was automatically generated on Sun Jun 5 16:50:18 2022 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-21. // Use, modification and distribution are subject to the @@ -372,6 +372,11 @@ namespace boost_no_cxx14_variable_templates = empty_boost; #else namespace boost_no_cxx17 = empty_boost; #endif +#ifndef BOOST_NO_CXX17_DEDUCTION_GUIDES +#include "boost_no_cxx17_deduction_guides.ipp" +#else +namespace boost_no_cxx17_deduction_guides = empty_boost; +#endif #ifndef BOOST_NO_CXX17_FOLD_EXPRESSIONS #include "boost_no_cxx17_fold_expressions.ipp" #else @@ -1681,6 +1686,11 @@ int main( int, char *[] ) std::cerr << "Failed test for BOOST_NO_CXX17 at: " << __FILE__ << ":" << __LINE__ << std::endl; ++error_count; } + if(0 != boost_no_cxx17_deduction_guides::test()) + { + std::cerr << "Failed test for BOOST_NO_CXX17_DEDUCTION_GUIDES at: " << __FILE__ << ":" << __LINE__ << std::endl; + ++error_count; + } if(0 != boost_no_cxx17_fold_expressions::test()) { std::cerr << "Failed test for BOOST_NO_CXX17_FOLD_EXPRESSIONS at: " << __FILE__ << ":" << __LINE__ << std::endl; diff --git a/test/no_cxx17_deduction_guides_fail.cpp b/test/no_cxx17_deduction_guides_fail.cpp new file mode 100644 index 00000000..066d17b5 --- /dev/null +++ b/test/no_cxx17_deduction_guides_fail.cpp @@ -0,0 +1,37 @@ +// This file was automatically generated on Sun Jun 5 16:50:17 2022 +// by libs/config/tools/generate.cpp +// Copyright John Maddock 2002-21. +// 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_DEDUCTION_GUIDES +// This file should not compile, if it does then +// BOOST_NO_CXX17_DEDUCTION_GUIDES should not be defined. +// See file boost_no_cxx17_deduction_guides.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_DEDUCTION_GUIDES +#include "boost_no_cxx17_deduction_guides.ipp" +#else +#error "this file should not compile" +#endif + +int main( int, char *[] ) +{ + return boost_no_cxx17_deduction_guides::test(); +} + diff --git a/test/no_cxx17_deduction_guides_pass.cpp b/test/no_cxx17_deduction_guides_pass.cpp new file mode 100644 index 00000000..f89d04a3 --- /dev/null +++ b/test/no_cxx17_deduction_guides_pass.cpp @@ -0,0 +1,37 @@ +// This file was automatically generated on Sun Jun 5 16:50:17 2022 +// by libs/config/tools/generate.cpp +// Copyright John Maddock 2002-21. +// 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_DEDUCTION_GUIDES +// This file should compile, if it does not then +// BOOST_NO_CXX17_DEDUCTION_GUIDES should be defined. +// See file boost_no_cxx17_deduction_guides.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_DEDUCTION_GUIDES +#include "boost_no_cxx17_deduction_guides.ipp" +#else +namespace boost_no_cxx17_deduction_guides = empty_boost; +#endif + +int main( int, char *[] ) +{ + return boost_no_cxx17_deduction_guides::test(); +} +