Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jan 2025 18:10:51 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 238564b86a50 - main - math/givaro: only declare std::bool_constant if it does not exist yet
Message-ID:  <202501191810.50JIApbc020999@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/ports/commit/?id=238564b86a506b7ec6e8a3b7b6be7a423cb50337

commit 238564b86a506b7ec6e8a3b7b6be7a423cb50337
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-01-19 15:56:44 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-01-19 18:09:20 +0000

    math/givaro: only declare std::bool_constant if it does not exist yet
    
    While doing test builds for bug 284159 (math/linbox), I ran into an
    issue compiling against one of the math/givaro headers, with clang and
    libc++ 19:
    
      /usr/local/include/givaro/random-integer.h:40:14: error: reference to 'bool_constant' is ambiguous
         40 |         std::bool_constant<_Exact_Size>::type _Exact_Size_t;
            |              ^
      /usr/include/c++/v1/__type_traits/integral_constant.h:42:1: note: candidate found by name lookup is 'std::__1::bool_constant'
         42 | using bool_constant = integral_constant<bool, __b>;
            | ^
      /usr/local/include/givaro/random-integer.h:16:5: note: candidate found by name lookup is 'std::bool_constant'
         16 |     using bool_constant = integral_constant<bool, B>;
            |     ^
    
    The problem is that random-integer.h attempts to declare
    std::bool_constant, even though libc++ headers already have this
    template.
    
    Conditionalize it on __cpp_lib_bool_constant [1], so it is only declared
    when necessary (i.e. if somebody compiles against and older C++
    library).
    
    [1] https://en.cppreference.com/w/cpp/feature_test#cpp_lib_bool_constant
    
    PR:             284167
    Approved by:    pi (maintainer)
    MFH:            2025Q1
---
 .../files/patch-src_kernel_integer_random-integer.h       | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/math/givaro/files/patch-src_kernel_integer_random-integer.h b/math/givaro/files/patch-src_kernel_integer_random-integer.h
index 901ddd8ea8e3..f8c7c62f7c21 100644
--- a/math/givaro/files/patch-src_kernel_integer_random-integer.h
+++ b/math/givaro/files/patch-src_kernel_integer_random-integer.h
@@ -1,6 +1,19 @@
 --- src/kernel/integer/random-integer.h.orig	2021-12-14 10:00:03 UTC
 +++ src/kernel/integer/random-integer.h
-@@ -91,7 +91,6 @@ namespace Givaro
+@@ -11,10 +11,12 @@
+ 
+ #include "gmp++/gmp++.h"
+ 
++#if __cpp_lib_bool_constant < 201505L
+ namespace std {
+     template <bool B>
+     using bool_constant = integral_constant<bool, B>;
+ }
++#endif
+ 
+ namespace Givaro
+ {
+@@ -91,7 +93,6 @@ namespace Givaro
              if (this != &R) {
                  _bits = R._bits;
                  _integer = R._integer;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501191810.50JIApbc020999>