You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

962 lines
19 KiB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Check for baseline language coverage in the compiler for the specified
  12. # version of the C++ standard. If necessary, add switches to CXX and
  13. # CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
  14. # or '14' (for the C++14 standard).
  15. #
  16. # The second argument, if specified, indicates whether you insist on an
  17. # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
  18. # -std=c++11). If neither is specified, you get whatever works, with
  19. # preference for no added switch, and then for an extended mode.
  20. #
  21. # The third argument, if specified 'mandatory' or if left unspecified,
  22. # indicates that baseline support for the specified C++ standard is
  23. # required and that the macro should error out if no mode with that
  24. # support is found. If specified 'optional', then configuration proceeds
  25. # regardless, after defining HAVE_CXX${VERSION} if and only if a
  26. # supporting mode is found.
  27. #
  28. # LICENSE
  29. #
  30. # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
  31. # Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
  32. # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
  33. # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
  34. # Copyright (c) 2015 Paul Norman <penorman@mac.com>
  35. # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
  36. # Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
  37. # Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
  38. # Copyright (c) 2020 Jason Merrill <jason@redhat.com>
  39. #
  40. # Copying and distribution of this file, with or without modification, are
  41. # permitted in any medium without royalty provided the copyright notice
  42. # and this notice are preserved. This file is offered as-is, without any
  43. # warranty.
  44. #serial 12
  45. dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
  46. dnl (serial version number 13).
  47. AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  48. m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
  49. [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
  50. [$1], [17], [ax_cxx_compile_alternatives="17 1z"],
  51. [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
  52. m4_if([$2], [], [],
  53. [$2], [ext], [],
  54. [$2], [noext], [],
  55. [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
  56. m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
  57. [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
  58. [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
  59. [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
  60. AC_LANG_PUSH([C++])dnl
  61. ac_success=no
  62. m4_if([$2], [], [dnl
  63. AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
  64. ax_cv_cxx_compile_cxx$1,
  65. [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  66. [ax_cv_cxx_compile_cxx$1=yes],
  67. [ax_cv_cxx_compile_cxx$1=no])])
  68. if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
  69. ac_success=yes
  70. fi])
  71. m4_if([$2], [noext], [], [dnl
  72. if test x$ac_success = xno; then
  73. for alternative in ${ax_cxx_compile_alternatives}; do
  74. switch="-std=gnu++${alternative}"
  75. cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  76. AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  77. $cachevar,
  78. [ac_save_CXX="$CXX"
  79. CXX="$CXX $switch"
  80. AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  81. [eval $cachevar=yes],
  82. [eval $cachevar=no])
  83. CXX="$ac_save_CXX"])
  84. if eval test x\$$cachevar = xyes; then
  85. CXX="$CXX $switch"
  86. if test -n "$CXXCPP" ; then
  87. CXXCPP="$CXXCPP $switch"
  88. fi
  89. ac_success=yes
  90. break
  91. fi
  92. done
  93. fi])
  94. m4_if([$2], [ext], [], [dnl
  95. if test x$ac_success = xno; then
  96. dnl HP's aCC needs +std=c++11 according to:
  97. dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
  98. dnl Cray's crayCC needs "-h std=c++11"
  99. for alternative in ${ax_cxx_compile_alternatives}; do
  100. for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
  101. cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  102. AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  103. $cachevar,
  104. [ac_save_CXX="$CXX"
  105. CXX="$CXX $switch"
  106. AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  107. [eval $cachevar=yes],
  108. [eval $cachevar=no])
  109. CXX="$ac_save_CXX"])
  110. if eval test x\$$cachevar = xyes; then
  111. CXX="$CXX $switch"
  112. if test -n "$CXXCPP" ; then
  113. CXXCPP="$CXXCPP $switch"
  114. fi
  115. ac_success=yes
  116. break
  117. fi
  118. done
  119. if test x$ac_success = xyes; then
  120. break
  121. fi
  122. done
  123. fi])
  124. AC_LANG_POP([C++])
  125. if test x$ax_cxx_compile_cxx$1_required = xtrue; then
  126. if test x$ac_success = xno; then
  127. AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
  128. fi
  129. fi
  130. if test x$ac_success = xno; then
  131. HAVE_CXX$1=0
  132. AC_MSG_NOTICE([No compiler with C++$1 support was found])
  133. else
  134. HAVE_CXX$1=1
  135. AC_DEFINE(HAVE_CXX$1,1,
  136. [define if the compiler supports basic C++$1 syntax])
  137. fi
  138. AC_SUBST(HAVE_CXX$1)
  139. ])
  140. dnl Test body for checking C++11 support
  141. m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
  142. _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
  143. )
  144. dnl Test body for checking C++14 support
  145. m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
  146. _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
  147. _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
  148. )
  149. m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
  150. _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
  151. _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
  152. _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
  153. )
  154. dnl Tests for new features in C++11
  155. m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
  156. // If the compiler admits that it is not ready for C++11, why torture it?
  157. // Hopefully, this will speed up the test.
  158. #ifndef __cplusplus
  159. #error "This is not a C++ compiler"
  160. #elif __cplusplus < 201103L
  161. #error "This is not a C++11 compiler"
  162. #else
  163. namespace cxx11
  164. {
  165. namespace test_static_assert
  166. {
  167. template <typename T>
  168. struct check
  169. {
  170. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  171. };
  172. }
  173. namespace test_final_override
  174. {
  175. struct Base
  176. {
  177. virtual ~Base() {}
  178. virtual void f() {}
  179. };
  180. struct Derived : public Base
  181. {
  182. virtual ~Derived() override {}
  183. virtual void f() override {}
  184. };
  185. }
  186. namespace test_double_right_angle_brackets
  187. {
  188. template < typename T >
  189. struct check {};
  190. typedef check<void> single_type;
  191. typedef check<check<void>> double_type;
  192. typedef check<check<check<void>>> triple_type;
  193. typedef check<check<check<check<void>>>> quadruple_type;
  194. }
  195. namespace test_decltype
  196. {
  197. int
  198. f()
  199. {
  200. int a = 1;
  201. decltype(a) b = 2;
  202. return a + b;
  203. }
  204. }
  205. namespace test_type_deduction
  206. {
  207. template < typename T1, typename T2 >
  208. struct is_same
  209. {
  210. static const bool value = false;
  211. };
  212. template < typename T >
  213. struct is_same<T, T>
  214. {
  215. static const bool value = true;
  216. };
  217. template < typename T1, typename T2 >
  218. auto
  219. add(T1 a1, T2 a2) -> decltype(a1 + a2)
  220. {
  221. return a1 + a2;
  222. }
  223. int
  224. test(const int c, volatile int v)
  225. {
  226. static_assert(is_same<int, decltype(0)>::value == true, "");
  227. static_assert(is_same<int, decltype(c)>::value == false, "");
  228. static_assert(is_same<int, decltype(v)>::value == false, "");
  229. auto ac = c;
  230. auto av = v;
  231. auto sumi = ac + av + 'x';
  232. auto sumf = ac + av + 1.0;
  233. static_assert(is_same<int, decltype(ac)>::value == true, "");
  234. static_assert(is_same<int, decltype(av)>::value == true, "");
  235. static_assert(is_same<int, decltype(sumi)>::value == true, "");
  236. static_assert(is_same<int, decltype(sumf)>::value == false, "");
  237. static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
  238. return (sumf > 0.0) ? sumi : add(c, v);
  239. }
  240. }
  241. namespace test_noexcept
  242. {
  243. int f() { return 0; }
  244. int g() noexcept { return 0; }
  245. static_assert(noexcept(f()) == false, "");
  246. static_assert(noexcept(g()) == true, "");
  247. }
  248. namespace test_constexpr
  249. {
  250. template < typename CharT >
  251. unsigned long constexpr
  252. strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
  253. {
  254. return *s ? strlen_c_r(s + 1, acc + 1) : acc;
  255. }
  256. template < typename CharT >
  257. unsigned long constexpr
  258. strlen_c(const CharT *const s) noexcept
  259. {
  260. return strlen_c_r(s, 0UL);
  261. }
  262. static_assert(strlen_c("") == 0UL, "");
  263. static_assert(strlen_c("1") == 1UL, "");
  264. static_assert(strlen_c("example") == 7UL, "");
  265. static_assert(strlen_c("another\0example") == 7UL, "");
  266. }
  267. namespace test_rvalue_references
  268. {
  269. template < int N >
  270. struct answer
  271. {
  272. static constexpr int value = N;
  273. };
  274. answer<1> f(int&) { return answer<1>(); }
  275. answer<2> f(const int&) { return answer<2>(); }
  276. answer<3> f(int&&) { return answer<3>(); }
  277. void
  278. test()
  279. {
  280. int i = 0;
  281. const int c = 0;
  282. static_assert(decltype(f(i))::value == 1, "");
  283. static_assert(decltype(f(c))::value == 2, "");
  284. static_assert(decltype(f(0))::value == 3, "");
  285. }
  286. }
  287. namespace test_uniform_initialization
  288. {
  289. struct test
  290. {
  291. static const int zero {};
  292. static const int one {1};
  293. };
  294. static_assert(test::zero == 0, "");
  295. static_assert(test::one == 1, "");
  296. }
  297. namespace test_lambdas
  298. {
  299. void
  300. test1()
  301. {
  302. auto lambda1 = [](){};
  303. auto lambda2 = lambda1;
  304. lambda1();
  305. lambda2();
  306. }
  307. int
  308. test2()
  309. {
  310. auto a = [](int i, int j){ return i + j; }(1, 2);
  311. auto b = []() -> int { return '0'; }();
  312. auto c = [=](){ return a + b; }();
  313. auto d = [&](){ return c; }();
  314. auto e = [a, &b](int x) mutable {
  315. const auto identity = [](int y){ return y; };
  316. for (auto i = 0; i < a; ++i)
  317. a += b--;
  318. return x + identity(a + b);
  319. }(0);
  320. return a + b + c + d + e;
  321. }
  322. int
  323. test3()
  324. {
  325. const auto nullary = [](){ return 0; };
  326. const auto unary = [](int x){ return x; };
  327. using nullary_t = decltype(nullary);
  328. using unary_t = decltype(unary);
  329. const auto higher1st = [](nullary_t f){ return f(); };
  330. const auto higher2nd = [unary](nullary_t f1){
  331. return [unary, f1](unary_t f2){ return f2(unary(f1())); };
  332. };
  333. return higher1st(nullary) + higher2nd(nullary)(unary);
  334. }
  335. }
  336. namespace test_variadic_templates
  337. {
  338. template <int...>
  339. struct sum;
  340. template <int N0, int... N1toN>
  341. struct sum<N0, N1toN...>
  342. {
  343. static constexpr auto value = N0 + sum<N1toN...>::value;
  344. };
  345. template <>
  346. struct sum<>
  347. {
  348. static constexpr auto value = 0;
  349. };
  350. static_assert(sum<>::value == 0, "");
  351. static_assert(sum<1>::value == 1, "");
  352. static_assert(sum<23>::value == 23, "");
  353. static_assert(sum<1, 2>::value == 3, "");
  354. static_assert(sum<5, 5, 11>::value == 21, "");
  355. static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
  356. }
  357. // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
  358. // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
  359. // because of this.
  360. namespace test_template_alias_sfinae
  361. {
  362. struct foo {};
  363. template<typename T>
  364. using member = typename T::member_type;
  365. template<typename T>
  366. void func(...) {}
  367. template<typename T>
  368. void func(member<T>*) {}
  369. void test();
  370. void test() { func<foo>(0); }
  371. }
  372. } // namespace cxx11
  373. #endif // __cplusplus >= 201103L
  374. ]])
  375. dnl Tests for new features in C++14
  376. m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
  377. // If the compiler admits that it is not ready for C++14, why torture it?
  378. // Hopefully, this will speed up the test.
  379. #ifndef __cplusplus
  380. #error "This is not a C++ compiler"
  381. #elif __cplusplus < 201402L
  382. #error "This is not a C++14 compiler"
  383. #else
  384. namespace cxx14
  385. {
  386. namespace test_polymorphic_lambdas
  387. {
  388. int
  389. test()
  390. {
  391. const auto lambda = [](auto&&... args){
  392. const auto istiny = [](auto x){
  393. return (sizeof(x) == 1UL) ? 1 : 0;
  394. };
  395. const int aretiny[] = { istiny(args)... };
  396. return aretiny[0];
  397. };
  398. return lambda(1, 1L, 1.0f, '1');
  399. }
  400. }
  401. namespace test_binary_literals
  402. {
  403. constexpr auto ivii = 0b0000000000101010;
  404. static_assert(ivii == 42, "wrong value");
  405. }
  406. namespace test_generalized_constexpr
  407. {
  408. template < typename CharT >
  409. constexpr unsigned long
  410. strlen_c(const CharT *const s) noexcept
  411. {
  412. auto length = 0UL;
  413. for (auto p = s; *p; ++p)
  414. ++length;
  415. return length;
  416. }
  417. static_assert(strlen_c("") == 0UL, "");
  418. static_assert(strlen_c("x") == 1UL, "");
  419. static_assert(strlen_c("test") == 4UL, "");
  420. static_assert(strlen_c("another\0test") == 7UL, "");
  421. }
  422. namespace test_lambda_init_capture
  423. {
  424. int
  425. test()
  426. {
  427. auto x = 0;
  428. const auto lambda1 = [a = x](int b){ return a + b; };
  429. const auto lambda2 = [a = lambda1(x)](){ return a; };
  430. return lambda2();
  431. }
  432. }
  433. namespace test_digit_separators
  434. {
  435. constexpr auto ten_million = 100'000'000;
  436. static_assert(ten_million == 100000000, "");
  437. }
  438. namespace test_return_type_deduction
  439. {
  440. auto f(int& x) { return x; }
  441. decltype(auto) g(int& x) { return x; }
  442. template < typename T1, typename T2 >
  443. struct is_same
  444. {
  445. static constexpr auto value = false;
  446. };
  447. template < typename T >
  448. struct is_same<T, T>
  449. {
  450. static constexpr auto value = true;
  451. };
  452. int
  453. test()
  454. {
  455. auto x = 0;
  456. static_assert(is_same<int, decltype(f(x))>::value, "");
  457. static_assert(is_same<int&, decltype(g(x))>::value, "");
  458. return x;
  459. }
  460. }
  461. } // namespace cxx14
  462. #endif // __cplusplus >= 201402L
  463. ]])
  464. dnl Tests for new features in C++17
  465. m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
  466. // If the compiler admits that it is not ready for C++17, why torture it?
  467. // Hopefully, this will speed up the test.
  468. #ifndef __cplusplus
  469. #error "This is not a C++ compiler"
  470. #elif __cplusplus < 201703L
  471. #error "This is not a C++17 compiler"
  472. #else
  473. #include <initializer_list>
  474. #include <utility>
  475. #include <type_traits>
  476. namespace cxx17
  477. {
  478. namespace test_constexpr_lambdas
  479. {
  480. constexpr int foo = [](){return 42;}();
  481. }
  482. namespace test::nested_namespace::definitions
  483. {
  484. }
  485. namespace test_fold_expression
  486. {
  487. template<typename... Args>
  488. int multiply(Args... args)
  489. {
  490. return (args * ... * 1);
  491. }
  492. template<typename... Args>
  493. bool all(Args... args)
  494. {
  495. return (args && ...);
  496. }
  497. }
  498. namespace test_extended_static_assert
  499. {
  500. static_assert (true);
  501. }
  502. namespace test_auto_brace_init_list
  503. {
  504. auto foo = {5};
  505. auto bar {5};
  506. static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
  507. static_assert(std::is_same<int, decltype(bar)>::value);
  508. }
  509. namespace test_typename_in_template_template_parameter
  510. {
  511. template<template<typename> typename X> struct D;
  512. }
  513. namespace test_fallthrough_nodiscard_maybe_unused_attributes
  514. {
  515. int f1()
  516. {
  517. return 42;
  518. }
  519. [[nodiscard]] int f2()
  520. {
  521. [[maybe_unused]] auto unused = f1();
  522. switch (f1())
  523. {
  524. case 17:
  525. f1();
  526. [[fallthrough]];
  527. case 42:
  528. f1();
  529. }
  530. return f1();
  531. }
  532. }
  533. namespace test_extended_aggregate_initialization
  534. {
  535. struct base1
  536. {
  537. int b1, b2 = 42;
  538. };
  539. struct base2
  540. {
  541. base2() {
  542. b3 = 42;
  543. }
  544. int b3;
  545. };
  546. struct derived : base1, base2
  547. {
  548. int d;
  549. };
  550. derived d1 {{1, 2}, {}, 4}; // full initialization
  551. derived d2 {{}, {}, 4}; // value-initialized bases
  552. }
  553. namespace test_general_range_based_for_loop
  554. {
  555. struct iter
  556. {
  557. int i;
  558. int& operator* ()
  559. {
  560. return i;
  561. }
  562. const int& operator* () const
  563. {
  564. return i;
  565. }
  566. iter& operator++()
  567. {
  568. ++i;
  569. return *this;
  570. }
  571. };
  572. struct sentinel
  573. {
  574. int i;
  575. };
  576. bool operator== (const iter& i, const sentinel& s)
  577. {
  578. return i.i == s.i;
  579. }
  580. bool operator!= (const iter& i, const sentinel& s)
  581. {
  582. return !(i == s);
  583. }
  584. struct range
  585. {
  586. iter begin() const
  587. {
  588. return {0};
  589. }
  590. sentinel end() const
  591. {
  592. return {5};
  593. }
  594. };
  595. void f()
  596. {
  597. range r {};
  598. for (auto i : r)
  599. {
  600. [[maybe_unused]] auto v = i;
  601. }
  602. }
  603. }
  604. namespace test_lambda_capture_asterisk_this_by_value
  605. {
  606. struct t
  607. {
  608. int i;
  609. int foo()
  610. {
  611. return [*this]()
  612. {
  613. return i;
  614. }();
  615. }
  616. };
  617. }
  618. namespace test_enum_class_construction
  619. {
  620. enum class byte : unsigned char
  621. {};
  622. byte foo {42};
  623. }
  624. namespace test_constexpr_if
  625. {
  626. template <bool cond>
  627. int f ()
  628. {
  629. if constexpr(cond)
  630. {
  631. return 13;
  632. }
  633. else
  634. {
  635. return 42;
  636. }
  637. }
  638. }
  639. namespace test_selection_statement_with_initializer
  640. {
  641. int f()
  642. {
  643. return 13;
  644. }
  645. int f2()
  646. {
  647. if (auto i = f(); i > 0)
  648. {
  649. return 3;
  650. }
  651. switch (auto i = f(); i + 4)
  652. {
  653. case 17:
  654. return 2;
  655. default:
  656. return 1;
  657. }
  658. }
  659. }
  660. namespace test_template_argument_deduction_for_class_templates
  661. {
  662. template <typename T1, typename T2>
  663. struct pair
  664. {
  665. pair (T1 p1, T2 p2)
  666. : m1 {p1},
  667. m2 {p2}
  668. {}
  669. T1 m1;
  670. T2 m2;
  671. };
  672. void f()
  673. {
  674. [[maybe_unused]] auto p = pair{13, 42u};
  675. }
  676. }
  677. namespace test_non_type_auto_template_parameters
  678. {
  679. template <auto n>
  680. struct B
  681. {};
  682. B<5> b1;
  683. B<'a'> b2;
  684. }
  685. namespace test_structured_bindings
  686. {
  687. int arr[2] = { 1, 2 };
  688. std::pair<int, int> pr = { 1, 2 };
  689. auto f1() -> int(&)[2]
  690. {
  691. return arr;
  692. }
  693. auto f2() -> std::pair<int, int>&
  694. {
  695. return pr;
  696. }
  697. struct S
  698. {
  699. int x1 : 2;
  700. volatile double y1;
  701. };
  702. S f3()
  703. {
  704. return {};
  705. }
  706. auto [ x1, y1 ] = f1();
  707. auto& [ xr1, yr1 ] = f1();
  708. auto [ x2, y2 ] = f2();
  709. auto& [ xr2, yr2 ] = f2();
  710. const auto [ x3, y3 ] = f3();
  711. }
  712. namespace test_exception_spec_type_system
  713. {
  714. struct Good {};
  715. struct Bad {};
  716. void g1() noexcept;
  717. void g2();
  718. template<typename T>
  719. Bad
  720. f(T*, T*);
  721. template<typename T1, typename T2>
  722. Good
  723. f(T1*, T2*);
  724. static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
  725. }
  726. namespace test_inline_variables
  727. {
  728. template<class T> void f(T)
  729. {}
  730. template<class T> inline T g(T)
  731. {
  732. return T{};
  733. }
  734. template<> inline void f<>(int)
  735. {}
  736. template<> int g<>(int)
  737. {
  738. return 5;
  739. }
  740. }
  741. } // namespace cxx17
  742. #endif // __cplusplus < 201703L
  743. ]])