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