[Bug 284167] math/givaro: only declare std::bool_constant if it does not exist yet

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 19 Jan 2025 15:56:14 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284167

            Bug ID: 284167
           Summary: math/givaro: only declare std::bool_constant if it
                    does not exist yet
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: pi@FreeBSD.org
          Reporter: dim@FreeBSD.org
          Assignee: pi@FreeBSD.org
             Flags: maintainer-feedback?(pi@FreeBSD.org)

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

-- 
You are receiving this mail because:
You are the assignee for the bug.