aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/bit
AgeCommit message (Collapse)AuthorFilesLines
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-11-18libstdc++: Fix some -Wsystem-headers warningsJonathan Wakely1-1/+3
* include/bits/alloc_traits.h (allocator_traits::construct) (allocator_traits::destroy, allocator_traits::max_size): Add unused attributes to parameters that are not used in C++20. * include/std/bit (__ceil2): Add braces around assertion to avoid -Wmissing-braces warning. From-SVN: r278401
2019-10-30Fix some missing/incorrect feature test macrosJonathan Wakely1-0/+2
* include/std/bit (__cpp_lib_bitops): Define. * include/std/version (__cpp_lib_constexpr): Remove. (__cpp_lib_bitops, __cpp_lib_constexpr_dynamic_alloc): Define. * testsuite/26_numerics/bit/header.cc: New test. * testsuite/26_numerics/bit/header-2.cc: New test. * testsuite/20_util/allocator_traits/header.cc: New test. * testsuite/20_util/allocator_traits/header-2.cc: New test. From-SVN: r277633
2019-07-31Add Doxygen comments to <bit> headerJonathan Wakely1-0/+28
* include/std/bit: Add Doxygen comments. From-SVN: r273938
2019-07-26Define __cpp_lib_endian feature test macroJonathan Wakely1-0/+2
This macro was added as part of moving std::endian from <type_traits> to <bit>. * include/std/bit (__cpp_lib_endian): Define. * include/std/version (__cpp_lib_endian): Define. * testsuite/26_numerics/endian/2.cc: New. * testsuite/26_numerics/endian/3.cc: New. * testsuite/26_numerics/endian/4.cc: New. From-SVN: r273828
2019-07-25Relocate std::endian from <type_traits> to <bit>Jonathan Wakely1-0/+7
This change to an early C++2a feature was just approved (P1612R1). * include/std/bit (endian): Move definition here as per P1612R1. * include/std/type_traits (endian): Remove definition from here. * testsuite/20_util/endian/1.cc: Rename to ... * testsuite/26_numerics/endian/1.cc: ... here. Adjust header. From-SVN: r273816
2019-07-22Adjust std::rotl, std::rotr etc to match final P0553R4 proposalJonathan Wakely1-15/+23
This proposal has now been accepted for C++20, with a few changes. This patch adjusts std::rotl and std::rotr to match the final specification and declares the additions for C++2a mode even when __STRICT_ANSI__ is defined. * include/std/bit (__rotl, __rotr): Change second parameter from unsigned int to int and handle negative values. (rotl, rotr): Remove check for __STRICT_ANSI__. Change second parameter from unsigned int to int. Add nodiscard attribute. * testsuite/26_numerics/bit/bitops.rot/rotl.cc: Rename to ... * testsuite/26_numerics/bit/bit.rotate/rotl.cc: Here. Test negative shifts. * testsuite/26_numerics/bit/bitops.rot/rotr.cc: Rename to ... * testsuite/26_numerics/bit/bit.rotate/rotr.cc: Here. Test negative shifts. From-SVN: r273706
2019-07-22Change std::ceil2 to be undefined if the result can't be representedJonathan Wakely1-3/+21
* include/std/bit (__ceil2): Make unrepresentable results undefined, as per P1355R2. Add debug assertion. Perform one left shift, not two, so that out of range values cause undefined behaviour. Ensure that shift will still be undefined if left operand is promoted. * testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Replace checks for unrepresentable values with checks that they are not core constant expressions. * testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: New test. From-SVN: r273705
2019-06-26Add new helper traits for signed/unsigned integer typesJonathan Wakely1-59/+1
Reuse the __is_one_of alias in additional places, and define traits to check for signed/unsigned integer types so we don't have to duplicate those checks elsewhere. The additional overloads for std::byte in <bit> were reviewed by LEWG and considered undesirable, so this patch removes them. * include/bits/fs_path.h (path::__is_encoded_char): Use __is_one_of. * include/std/bit (_If_is_unsigned_integer_type): Remove. (_If_is_unsigned_integer): Use __is_unsigned_integer. (rotl(byte, unsigned), rotr(byte, unsigned), countl_zero(byte)) (countl_one(byte), countr_zero(byte), countr_one(byte)) (popcount(byte), ispow2(byte), ceil2(byte), floor2(byte)) (log2p1(byte)): Remove. * include/std/charconv (__detail::__is_one_of): Move to <type_traits>. (__detail::__is_int_to_chars_type): Remove. (__detail::__integer_to_chars_result_type): Use __is_signed_integer and __is_unsigned_integer. * include/std/type_traits (__is_one_of): Move here from <charconv>. (__is_signed_integer, __is_unsigned_integer): New helpers. * testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Remove test for std::byte overload. * testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countl_one.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countl_zero.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countr_one.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countr_zero.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/popcount.cc: Likewise. * testsuite/26_numerics/bit/bitops.rot/rotl.cc: Likewise. * testsuite/26_numerics/bit/bitops.rot/rotr.cc: Likewise. From-SVN: r272695
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-08-30Avoid undefined shifts in ceil2 operationsJonathan Wakely1-2/+4
For values where the result cannot be represented the shift width would be equal to the width of the type, which is undefined. Perform two well-defined shifts instead of one possible undefined shift. * include/bits/hashtable_policy.h (__clp2): Fix calculation for LLP64 targets where sizeof(size_t) > sizeof(long). Avoid undefined shifts of the number of bits in the type. * include/std/bit (__ceil2): Avoid undefined shifts. * testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Test values with the most signifiant bit set. From-SVN: r263986
2018-07-24Minor refactoring in <bit> headerJonathan Wakely1-45/+44
* include/std/bit (__countl_zero, __countr_zero, __popcount): Use local variables for number of digits instead of type aliases. (__log2p1): Remove redundant branch also checked in __countl_zero. From-SVN: r262947
2018-07-04Fix std::__rotl and std::__rotrJonathan Wakely1-2/+2
2018-07-04 Jonathan Wakely <jwakely@redhat.com> Jakub Jelinek <jakub@redhat.com> * include/std/bit (__rotl, __rotr): Fix for non-power of two sizes. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r262414
2018-07-04Optimize std::rotl and std::rotr, add test for std::popcountJonathan Wakely1-7/+3
* include/std/bit (__rotl, __rotr): Avoid branch. (_If_is_unsigned_integer): Use remove_cv_t. * testsuite/26_numerics/bit/bitops.count/popcount.cc: New. From-SVN: r262378
2018-07-03P0556R3 Integral power-of-2 operations, P0553R2 Bit operationsJonathan Wakely1-0/+359
P0553R2 is not in the C++2a working draft yet, but is likely to be approved soon. Neither proposal supports std::byte but this adds overloads of each function for std::byte, assuming that will also get added. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include new header. * include/std/bit: New header. (__rotl, __rotr, __countl_zero, __countl_one, __countr_zero) (__countr_one, __popcount, __ispow2, __ceil2, __floor2, __log2p1): Define for C++14. [!__STRICT_ANSI__] (rotl, rotr, countl_zero, countl_one, countr_zero) (countr_one, popcount): Define for C++2a. Also overload for std::byte. (ispow2, ceil2, floor2, log2p1): Define for C++2a. [!__STRICT_ANSI__] (ispow2, ceil2, floor2, log2p1): Overload for std::byte. * testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: New. * testsuite/26_numerics/bit/bit.pow.two/floor2.cc: New. * testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: New. * testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: New. * testsuite/26_numerics/bit/bitops.rot/rotl.cc: New. * testsuite/26_numerics/bit/bitops.rot/rotr.cc: New. * testsuite/26_numerics/bit/bitops.count/countl_one.cc: New. * testsuite/26_numerics/bit/bitops.count/countl_zero.cc: New. * testsuite/26_numerics/bit/bitops.count/countr_one.cc: New. * testsuite/26_numerics/bit/bitops.count/countr_zero.cc: New. From-SVN: r262360