170 похожих чатов

В книге вандервуда есть сноска про реализацию max - "Note

that the max() template according to [StepanovNotes] intentionally returns “b < a ? a : b” instead of “a < b ? b : a” to ensure that the function behaves correctly even if the two values are equivalent but not equal." т.е. если значения еквивалентны ты вернет B. но на cppref для std::max написано что вернет A. wtf?

3 ответов

5 просмотров

в MSC if (_Left < _Right) { return _Right; }

Requires: For the first form, type T shall be Cpp17LessThanComparable ([tab:lessthancomparable]Table *tab:lessthancomparable). 10 # Returns: The larger value. 11 # Remarks: Returns the first argument when the arguments are equivalent. An invocation may explicitly specify an argument for the template parameter T of the overloads in namespace std. 12 # Complexity: Exactly one comparison and two applications of the projection, if any.

Правильно вернуть а

Похожие вопросы

Обсуждают сегодня

type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
45
А чем вам питонисты не угодили?😂
.
79
Можно ли загрузить скрипт py в бота чтобы он работал по нему? как это сделать?
huskadam #RCC Фанат? @hitlerpvp
13
А дин типизация это хорошо или плохо?
Alexey
12
Исходники плюс документация? Вы гоните)) демок хватит всем
zamtmn
11
Язык Си можно выучить за день? По книжке ANSI C на 230 страниц
Vincent Vegan
29
Hello. Could you please help me with finding all coordinates within a radius using a spatial index, given that I have a table with coordinates? SET @lng = 37.57925; SET @lat ...
Rinchin G
7
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
76
а что есть "статистика" ? просто подсчет фактов обращения и времен выполнения ?
Сергей
9
Карта сайта