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