Skip to content

Conversation

@AlexGuteniev
Copy link
Contributor

No description provided.

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner May 1, 2024 17:26
@AlexGuteniev AlexGuteniev changed the title <utility>: unify min/max limit <xutility>: unify min/max limit May 1, 2024
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label May 7, 2024
@StephanTLavavej StephanTLavavej self-assigned this May 7, 2024
@StephanTLavavej
Copy link
Member

Thanks! I verified that _Meow_limit works for all integral types (including bool, even though bool is handled before the new usage occurs):

D:\GitHub\STL\out\x64>type meow.cpp
#include <print>
#include <string_view>
#include <utility>
using namespace std;

template <typename Type, typename As>
void print_limits_as(const string_view name) {
    println("{}: min {}, max {}", name, static_cast<As>(_Min_limit<Type>()), static_cast<As>(_Max_limit<Type>()));
}

int main() {
    print_limits_as<char, int>("char");
    print_limits_as<wchar_t, int>("wchar_t");
    print_limits_as<char8_t, int>("char8_t");
    print_limits_as<char16_t, int>("char16_t");
    print_limits_as<char32_t, unsigned int>("char32_t");
    print_limits_as<bool, int>("bool");
}
D:\GitHub\STL\out\x64>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od meow.cpp && meow
meow.cpp
char: min -128, max 127
wchar_t: min 0, max 65535
char8_t: min 0, max 255
char16_t: min 0, max 65535
char32_t: min 0, max 4294967295
bool: min 0, max 1

@StephanTLavavej StephanTLavavej removed their assignment May 14, 2024
@StephanTLavavej
Copy link
Member

Fused into #4634.

@AlexGuteniev AlexGuteniev deleted the limits branch May 18, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants