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.

52 lines
1.6KB

  1. # =============================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_cxx_enum_computations.html
  3. # =============================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CXX_ENUM_COMPUTATIONS
  8. #
  9. # DESCRIPTION
  10. #
  11. # If the compiler handle computations inside an enum, define
  12. # HAVE_ENUM_COMPUTATIONS.
  13. #
  14. # LICENSE
  15. #
  16. # Copyright (c) 2008 Todd Veldhuizen
  17. # Copyright (c) 2008 Luc Maisonobe <luc@spaceroots.org>
  18. #
  19. # Copying and distribution of this file, with or without modification, are
  20. # permitted in any medium without royalty provided the copyright notice
  21. # and this notice are preserved. This file is offered as-is, without any
  22. # warranty.
  23. #serial 7
  24. AU_ALIAS([AC_CXX_ENUM_COMPUTATIONS], [AX_CXX_ENUM_COMPUTATIONS])
  25. AC_DEFUN([AX_CXX_ENUM_COMPUTATIONS],
  26. [AC_CACHE_CHECK(whether the compiler handle computations inside an enum,
  27. ax_cv_cxx_enum_computations,
  28. [AC_LANG_SAVE
  29. AC_LANG_CPLUSPLUS
  30. AC_TRY_COMPILE([
  31. struct A { enum { a = 5, b = 7, c = 2 }; };
  32. struct B { enum { a = 1, b = 6, c = 9 }; };
  33. template<class T1, class T2> struct Z
  34. { enum { a = (T1::a > T2::a) ? T1::a : T2::b,
  35. b = T1::b + T2::b,
  36. c = (T1::c * T2::c + T2::a + T1::a)
  37. };
  38. };],[
  39. return (((int)Z<A,B>::a == 5)
  40. && ((int)Z<A,B>::b == 13)
  41. && ((int)Z<A,B>::c == 24)) ? 0 : 1;],
  42. ax_cv_cxx_enum_computations=yes, ax_cv_cxx_enum_computations=no)
  43. AC_LANG_RESTORE
  44. ])
  45. if test "$ax_cv_cxx_enum_computations" = yes; then
  46. AC_DEFINE(HAVE_ENUM_COMPUTATIONS,,
  47. [define if the compiler handle computations inside an enum])
  48. fi
  49. ])