Collection of DPF-based plugins for packaging
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.

79 lines
2.5KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_cxx_delete_method.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CXX_DELETE_METHOD
  8. #
  9. # DESCRIPTION
  10. #
  11. # Check whether the C++11 '= delete' syntax, for suppressing undesired
  12. # implicit methods, is supported. If it is, the macro DELETE_METHOD is
  13. # defined to '= delete'; otherwise it is defined to nothing. Thus, you
  14. # can write
  15. #
  16. # class foo {
  17. # ...
  18. # private:
  19. # foo(foo const&) DELETE_METHOD;
  20. # };
  21. #
  22. # to delete the 'foo' copy constructor or fall back to the idiom of a
  23. # private undefined method if the compiler doesn't support this.
  24. #
  25. # Does not test '= delete' on a template specialization. Does not ensure
  26. # that the compiler is in C++11 mode.
  27. #
  28. # LICENSE
  29. #
  30. # Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
  31. #
  32. # Copying and distribution of this file, with or without modification, are
  33. # permitted in any medium without royalty provided the copyright notice
  34. # and this notice are preserved. This file is offered as-is, without any
  35. # warranty.
  36. #serial 2
  37. AC_DEFUN([AX_CXX_DELETE_METHOD], [dnl
  38. AC_LANG_ASSERT([C++])
  39. # This compilation should succeed...
  40. AC_CACHE_CHECK(whether $CXX accepts method deletion,
  41. ax_cv_cxx_delete_method_syntax, [
  42. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  43. struct foo {
  44. foo(double);
  45. foo(int) = delete;
  46. };
  47. extern void t(foo const&);
  48. void tt(double n) { t(n); }
  49. ]])],
  50. [ax_cv_cxx_delete_method_syntax=yes],
  51. [ax_cv_cxx_delete_method_syntax=no])])
  52. # ... and this one should fail.
  53. AC_CACHE_CHECK(whether $CXX enforces method deletion,
  54. ax_cv_cxx_delete_method_enforced, [
  55. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  56. struct foo {
  57. foo(double);
  58. foo(int) = delete;
  59. };
  60. extern void t(foo const&);
  61. void tt(int n) { t(n); }
  62. ]])],
  63. [ax_cv_cxx_delete_method_enforced=no],
  64. [ax_cv_cxx_delete_method_enforced=yes])])
  65. if test $ax_cv_cxx_delete_method_syntax = yes &&
  66. test $ax_cv_cxx_delete_method_enforced = yes
  67. then
  68. AC_DEFINE([DELETE_METHOD], [= delete],
  69. [Define as `= delete' if your compiler supports C++11 method
  70. deletion, as nothing otherwise.])
  71. else
  72. AC_DEFINE([DELETE_METHOD], [],
  73. [Define as `= delete' if your compiler supports C++11 method
  74. deletion, as nothing otherwise.])
  75. fi
  76. ])