summaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2023-12-27 23:31:58 +0100
committerGitHub <[email protected]>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /library/cpp
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
Import libs 4 (#758)
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/getopt/small/last_getopt_opt.h7
-rw-r--r--library/cpp/ipmath/ipmath.cpp40
-rw-r--r--library/cpp/ipmath/ipmath.h16
-rw-r--r--library/cpp/ipmath/ipmath_ut.cpp10
-rw-r--r--library/cpp/protobuf/json/json2proto.cpp10
-rw-r--r--library/cpp/protobuf/json/proto2json_printer.cpp4
-rw-r--r--library/cpp/sanitizer/include/ya.make4
-rw-r--r--library/cpp/threading/future/core/future-inl.h8
-rw-r--r--library/cpp/threading/future/core/future.h2
-rw-r--r--library/cpp/threading/future/future_ut.cpp22
-rw-r--r--library/cpp/tld/tlds-alpha-by-domain.txt36
11 files changed, 104 insertions, 55 deletions
diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h
index 625f4237dce..5b035dbe6dd 100644
--- a/library/cpp/getopt/small/last_getopt_opt.h
+++ b/library/cpp/getopt/small/last_getopt_opt.h
@@ -670,7 +670,12 @@ namespace NLastGetopt {
// Similar to store_true in Python's argparse
TOpt& StoreTrue(bool* target) {
- return NoArgument().SetFlag(target);
+ return NoArgument().StoreResult(target, true);
+ }
+
+ // Similar to store_false in Python's argparse
+ TOpt& StoreFalse(bool* target) {
+ return NoArgument().StoreResult(target, false);
}
template <typename TpVal, typename T, typename TpFunc>
diff --git a/library/cpp/ipmath/ipmath.cpp b/library/cpp/ipmath/ipmath.cpp
index 53f19dbb017..b2dffcfcfdb 100644
--- a/library/cpp/ipmath/ipmath.cpp
+++ b/library/cpp/ipmath/ipmath.cpp
@@ -139,7 +139,7 @@ TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder
return *this;
}
-TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder::WithPrefix(ui8 len) {
+TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder::WithPrefixImpl(ui8 len, bool checkLowerBound) {
Y_ENSURE_EX(IsValid(Start_), TInvalidIpRangeException() << "Start value must be set before prefix");
const auto type = Start_.Type();
const auto maxLen = MaxPrefixLenForType(type);
@@ -147,14 +147,25 @@ TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder
<< maxLen << ", but requested " << (ui32)len);
const auto lowerBound = LowerBoundForPrefix(Start_, len);
- Y_ENSURE_EX(Start_ == lowerBound, TInvalidIpRangeException() << "Cannot create IP range from start address "
- << Start_ << " with prefix length " << (ui32)len);
+ if (checkLowerBound) {
+ Y_ENSURE_EX(Start_ == lowerBound, TInvalidIpRangeException() << "Cannot create IP range from start address "
+ << Start_ << " with prefix length " << (ui32)len);
+ }
+ Start_ = lowerBound;
End_ = UpperBoundForPrefix(Start_, len);
return *this;
}
+TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder::WithPrefix(ui8 len) {
+ return WithPrefixImpl(len, true);
+}
+
+TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder::WithMaskedPrefix(ui8 len) {
+ return WithPrefixImpl(len, false);
+}
+
void TIpAddressRange::Init(TIpv6Address from, TIpv6Address to) {
Start_ = from;
End_ = to;
@@ -230,7 +241,7 @@ TIpAddressRange TIpAddressRange::FromCidrString(const TStringBuf str) {
ythrow TInvalidIpRangeException() << "Cannot parse " << str << " as a CIDR string";
}
-TMaybe<TIpAddressRange> TIpAddressRange::TryFromCidrString(const TStringBuf str) {
+TMaybe<TIpAddressRange> TIpAddressRange::TryFromCidrStringImpl(const TStringBuf str, bool compact) {
auto idx = str.rfind('/');
if (idx == TStringBuf::npos) {
return Nothing();
@@ -246,8 +257,25 @@ TMaybe<TIpAddressRange> TIpAddressRange::TryFromCidrString(const TStringBuf str)
return Nothing();
}
- return TIpAddressRange::From(address)
- .WithPrefix(prefixLen);
+ return compact ?
+ TIpAddressRange::From(address).WithMaskedPrefix(prefixLen) :
+ TIpAddressRange::From(address).WithPrefix(prefixLen);
+}
+
+TMaybe<TIpAddressRange> TIpAddressRange::TryFromCidrString(const TStringBuf str) {
+ return TryFromCidrStringImpl(str, false);
+}
+
+TIpAddressRange TIpAddressRange::FromCompactString(const TStringBuf str) {
+ if (auto result = TryFromCompactString(str)) {
+ return *result;
+ }
+
+ ythrow TInvalidIpRangeException() << "Cannot parse " << str << " as a CIDR string";
+}
+
+TMaybe<TIpAddressRange> TIpAddressRange::TryFromCompactString(const TStringBuf str) {
+ return TryFromCidrStringImpl(str, true);
}
TIpAddressRange TIpAddressRange::FromRangeString(const TStringBuf str) {
diff --git a/library/cpp/ipmath/ipmath.h b/library/cpp/ipmath/ipmath.h
index f1c15e341ee..8c24bd471cd 100644
--- a/library/cpp/ipmath/ipmath.h
+++ b/library/cpp/ipmath/ipmath.h
@@ -26,7 +26,7 @@ public:
static TIpAddressRangeBuilder From(const TStringBuf from);
/**
- * Parses a string tormatted in Classless Iter-Domain Routing (CIDR) notation.
+ * Parses a string formatted in Classless Inter-Domain Routing (CIDR) notation.
* @param str a CIDR-formatted string, e.g. "192.168.0.0/16"
* @return a new TIpAddressRange
* @throws TInvalidIpRangeException if the string cannot be parsed.
@@ -35,6 +35,15 @@ public:
static TMaybe<TIpAddressRange> TryFromCidrString(const TStringBuf str);
/**
+ * Parses a string formatted in compact Classless Inter-Domain Routing (CIDR) notation with node address.
+ * @param str a CIDR-formatted string with node address, e.g. "192.168.1.24/16"
+ * @return a new TIpAddressRange
+ * @throws TInvalidIpRangeException if the string cannot be parsed.
+ */
+ static TIpAddressRange FromCompactString(const TStringBuf str);
+ static TMaybe<TIpAddressRange> TryFromCompactString(const TStringBuf str);
+
+ /**
* Parses a string formatted as two dash-separated addresses.
* @param str a CIDR-formatted string, e.g. "192.168.0.0-192.168.0.2"
* @return a new TIpAddressRange
@@ -99,6 +108,8 @@ public:
private:
void Init(TIpv6Address, TIpv6Address);
+ static TMaybe<TIpAddressRange> TryFromCidrStringImpl(const TStringBuf str, bool compact);
+
TIpv6Address Start_;
TIpv6Address End_;
};
@@ -129,8 +140,11 @@ public:
TIpAddressRangeBuilder& To(TIpv6Address);
TIpAddressRangeBuilder& WithPrefix(ui8 len);
+ TIpAddressRangeBuilder& WithMaskedPrefix(ui8 len);
private:
+ TIpAddressRangeBuilder& WithPrefixImpl(ui8 len, bool checkLowerBound);
+
TIpv6Address Start_;
TIpv6Address End_;
};
diff --git a/library/cpp/ipmath/ipmath_ut.cpp b/library/cpp/ipmath/ipmath_ut.cpp
index 179f2325034..8179c1bd672 100644
--- a/library/cpp/ipmath/ipmath_ut.cpp
+++ b/library/cpp/ipmath/ipmath_ut.cpp
@@ -35,6 +35,7 @@ public:
UNIT_TEST(IpRangeFromIpv6);
UNIT_TEST(FullIpRange);
UNIT_TEST(IpRangeFromCidr);
+ UNIT_TEST(IpRangeFromCompact);
UNIT_TEST(IpRangeFromIpv4Builder);
UNIT_TEST(IpRangeFromInvalidIpv4);
UNIT_TEST(IpRangeFromInvalidIpv6);
@@ -145,6 +146,15 @@ public:
ASSERT_THROW(TIpAddressRange::FromCidrString("::/150"), TInvalidIpRangeException);
}
+ void IpRangeFromCompact() {
+ // FromCidrString disallows node addresses
+ EXPECT_THROW(TIpAddressRange::FromCidrString("10.10.36.12/12"), TInvalidIpRangeException);
+
+ // FromCompactString allows to use node address instead of network address (suffix of zeroes is not required)
+ ASSERT_THAT(TIpAddressRange::FromCompactString("10.10.36.12/12"), Eq(TIpAddressRange::FromCidrString("10.0.0.0/12")));
+ ASSERT_THAT(TIpAddressRange::FromCompactString("abcd:ef01:2345::/24"), Eq(TIpAddressRange::FromCidrString("abcd:ef00::/24")));
+ }
+
void RangeFromRangeString() {
{
auto range = TIpAddressRange::FromRangeString("10.0.0.0-10.0.0.3");
diff --git a/library/cpp/protobuf/json/json2proto.cpp b/library/cpp/protobuf/json/json2proto.cpp
index 83b7891b9c0..f0ca3adf42e 100644
--- a/library/cpp/protobuf/json/json2proto.cpp
+++ b/library/cpp/protobuf/json/json2proto.cpp
@@ -367,7 +367,7 @@ Json2RepeatedFieldValue(const NJson::TJsonValue& jsonValue,
const google::protobuf::FieldDescriptor& field,
const NProtobufJson::TJson2ProtoConfig& config,
const google::protobuf::Reflection* reflection,
- const TMaybe<TString>& key = {}) {
+ const TString* key = nullptr) {
using namespace google::protobuf;
switch (field.cpp_type()) {
@@ -392,12 +392,12 @@ Json2RepeatedFieldValue(const NJson::TJsonValue& jsonValue,
case FieldDescriptor::CPPTYPE_MESSAGE: {
Message* innerProto = reflection->AddMessage(&proto, &field);
Y_ASSERT(!!innerProto);
- if (key.Defined()) {
- const FieldDescriptor* keyField = innerProto->GetDescriptor()->FindFieldByName("key");
+ if (key) {
+ const FieldDescriptor* keyField = innerProto->GetDescriptor()->map_key();
Y_ENSURE(keyField, "Map entry key field not found: " << field.name());
SetKey(*innerProto, *keyField, *key);
- const FieldDescriptor* valueField = innerProto->GetDescriptor()->FindFieldByName("value");
+ const FieldDescriptor* valueField = innerProto->GetDescriptor()->map_value();
Y_ENSURE(valueField, "Map entry value field not found.");
Json2SingleField(jsonValue, *innerProto, *valueField, config, /*isMapValue=*/true);
} else {
@@ -457,7 +457,7 @@ Json2RepeatedField(const NJson::TJsonValue& json,
if (config.UnknownFieldsCollector) {
config.UnknownFieldsCollector->OnEnterMapItem(key);
}
- Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection, key);
+ Json2RepeatedFieldValue(jsonValue, proto, field, config, reflection, &key);
if (config.UnknownFieldsCollector) {
config.UnknownFieldsCollector->OnLeaveMapItem();
}
diff --git a/library/cpp/protobuf/json/proto2json_printer.cpp b/library/cpp/protobuf/json/proto2json_printer.cpp
index aa0823de0ed..b2426f395a0 100644
--- a/library/cpp/protobuf/json/proto2json_printer.cpp
+++ b/library/cpp/protobuf/json/proto2json_printer.cpp
@@ -408,10 +408,10 @@ namespace NProtobufJson {
void TProto2JsonPrinter::PrintKeyValue(const NProtoBuf::Message& proto,
IJsonOutput& json) {
- const FieldDescriptor* keyField = proto.GetDescriptor()->FindFieldByName("key");
+ const FieldDescriptor* keyField = proto.GetDescriptor()->map_key();
Y_ABORT_UNLESS(keyField, "Map entry key field not found.");
TString key = MakeKey(proto, *keyField);
- const FieldDescriptor* valueField = proto.GetDescriptor()->FindFieldByName("value");
+ const FieldDescriptor* valueField = proto.GetDescriptor()->map_value();
Y_ABORT_UNLESS(valueField, "Map entry value field not found.");
PrintSingleField(proto, *valueField, json, key, true);
}
diff --git a/library/cpp/sanitizer/include/ya.make b/library/cpp/sanitizer/include/ya.make
index 444a5703335..8fb803a8149 100644
--- a/library/cpp/sanitizer/include/ya.make
+++ b/library/cpp/sanitizer/include/ya.make
@@ -4,7 +4,9 @@ NO_SANITIZE()
NO_RUNTIME()
-ADDINCL(GLOBAL contrib/libs/clang${CLANG_VER}-rt/include)
+IF (USE_ARCADIA_COMPILER_RUNTIME)
+ ADDINCL(GLOBAL contrib/libs/clang${CLANG_VER}-rt/include)
+ENDIF()
END()
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h
index a98175af2dc..db58b3156c9 100644
--- a/library/cpp/threading/future/core/future-inl.h
+++ b/library/cpp/threading/future/core/future-inl.h
@@ -729,16 +729,16 @@ namespace NThreading {
}
template <typename R>
- inline TFuture<R> TFuture<void>::Return(const R& value) const {
- auto promise = NewPromise<R>();
- Subscribe([=](const TFuture<void>& future) mutable {
+ inline TFuture<std::remove_cvref_t<R>> TFuture<void>::Return(R&& value) const {
+ auto promise = NewPromise<std::remove_cvref_t<R>>();
+ Subscribe([promise, value = std::forward<R>(value)](const TFuture<void>& future) mutable {
try {
future.TryRethrow();
} catch (...) {
promise.SetException(std::current_exception());
return;
}
- promise.SetValue(value);
+ promise.SetValue(std::move(value));
});
return promise;
}
diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h
index c803b28b756..598336282a0 100644
--- a/library/cpp/threading/future/core/future.h
+++ b/library/cpp/threading/future/core/future.h
@@ -169,7 +169,7 @@ namespace NThreading {
TFuture<TFutureType<TFutureCallResult<F, void>>> Apply(F&& func) const;
template <typename R>
- TFuture<R> Return(const R& value) const;
+ TFuture<std::remove_cvref_t<R>> Return(R&& value) const;
TFuture<void> IgnoreResult() const {
return *this;
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp
index 05950a568d4..26f8fa9e9c3 100644
--- a/library/cpp/threading/future/future_ut.cpp
+++ b/library/cpp/threading/future/future_ut.cpp
@@ -635,6 +635,28 @@ namespace {
TestApplyLvalueCopyImpl<void>();
TestApplyLvalueCopyImpl<int>();
}
+
+ Y_UNIT_TEST(ReturnForwardingTypeDeduction) {
+ const TString e = TString(80, 'a');
+ TString l = TString(80, 'a');
+
+ TFuture<TString> futureL = MakeFuture().Return(l);
+ UNIT_ASSERT_VALUES_EQUAL(futureL.GetValue(), e);
+ UNIT_ASSERT_VALUES_EQUAL(l, e);
+
+ TFuture<TString> futureR = MakeFuture().Return(std::move(l));
+ UNIT_ASSERT_VALUES_EQUAL(futureR.GetValue(), e);
+ }
+
+ Y_UNIT_TEST(ReturnForwardingCopiesCount) {
+ size_t numCopies = 0;
+ TCopyCounter copyCounter(&numCopies);
+
+ auto returnedCounter = MakeFuture().Return(std::move(copyCounter)).ExtractValueSync();
+ Y_DO_NOT_OPTIMIZE_AWAY(returnedCounter);
+
+ UNIT_ASSERT_VALUES_EQUAL(numCopies, 0);
+ }
}
}
diff --git a/library/cpp/tld/tlds-alpha-by-domain.txt b/library/cpp/tld/tlds-alpha-by-domain.txt
index 361254bc21e..52c974e44ab 100644
--- a/library/cpp/tld/tlds-alpha-by-domain.txt
+++ b/library/cpp/tld/tlds-alpha-by-domain.txt
@@ -1,7 +1,6 @@
-# Version 2022032102, Last Updated Tue Mar 22 07:07:01 2022 UTC
+# Version 2023122500, Last Updated Mon Dec 25 07:07:01 2023 UTC
AAA
AARP
-ABARTH
ABB
ABBOTT
ABBVIE
@@ -17,7 +16,6 @@ ACCOUNTANTS
ACO
ACTOR
AD
-ADAC
ADS
ADULT
AE
@@ -37,7 +35,6 @@ AIRFORCE
AIRTEL
AKDN
AL
-ALFAROMEO
ALIBABA
ALIPAY
ALLFINANZ
@@ -176,7 +173,6 @@ BROTHER
BRUSSELS
BS
BT
-BUGATTI
BUILD
BUILDERS
BUSINESS
@@ -196,7 +192,6 @@ CALVINKLEIN
CAM
CAMERA
CAMP
-CANCERRESEARCH
CANON
CAPETOWN
CAPITAL
@@ -218,7 +213,6 @@ CATHOLIC
CBA
CBN
CBRE
-CBS
CC
CD
CENTER
@@ -247,7 +241,6 @@ CITADEL
CITI
CITIC
CITY
-CITYEATS
CK
CL
CLAIMS
@@ -281,7 +274,6 @@ CONSULTING
CONTACT
CONTRACTORS
COOKING
-COOKINGCHANNEL
COOL
COOP
CORSICA
@@ -387,7 +379,6 @@ ES
ESQ
ESTATE
ET
-ETISALAT
EU
EUROVISION
EUS
@@ -413,7 +404,6 @@ FEEDBACK
FERRARI
FERRERO
FI
-FIAT
FIDELITY
FIDO
FILM
@@ -439,7 +429,6 @@ FM
FO
FOO
FOOD
-FOODNETWORK
FOOTBALL
FORD
FOREX
@@ -452,7 +441,6 @@ FREE
FRESENIUS
FRL
FROGANS
-FRONTDOOR
FRONTIER
FTR
FUJITSU
@@ -545,7 +533,6 @@ HELP
HELSINKI
HERE
HERMES
-HGTV
HIPHOP
HISAMITSU
HITACHI
@@ -567,7 +554,6 @@ HOSPITAL
HOST
HOSTING
HOT
-HOTELES
HOTELS
HOTMAIL
HOUSE
@@ -653,8 +639,8 @@ KG
KH
KI
KIA
+KIDS
KIM
-KINDER
KINDLE
KITCHEN
KIWI
@@ -679,7 +665,6 @@ LACAIXA
LAMBORGHINI
LAMER
LANCASTER
-LANCIA
LAND
LANDROVER
LANXESS
@@ -710,7 +695,6 @@ LILLY
LIMITED
LIMO
LINCOLN
-LINDE
LINK
LIPSY
LIVE
@@ -722,7 +706,6 @@ LOAN
LOANS
LOCKER
LOCUS
-LOFT
LOL
LONDON
LOTTE
@@ -742,7 +725,6 @@ LUXURY
LV
LY
MA
-MACYS
MADRID
MAIF
MAISON
@@ -756,7 +738,6 @@ MARKETING
MARKETS
MARRIOTT
MARSHALLS
-MASERATI
MATTEL
MBA
MC
@@ -816,7 +797,6 @@ MTR
MU
MUSEUM
MUSIC
-MUTUAL
MV
MW
MX
@@ -857,7 +837,6 @@ NISSAY
NL
NO
NOKIA
-NORTHWESTERNMUTUAL
NORTON
NOW
NOWRUZ
@@ -903,7 +882,6 @@ PARS
PARTNERS
PARTS
PARTY
-PASSAGENS
PAY
PCCW
PE
@@ -1004,7 +982,6 @@ RIL
RIO
RIP
RO
-ROCHER
ROCKS
RODEO
ROGERS
@@ -1039,7 +1016,6 @@ SB
SBI
SBS
SC
-SCA
SCB
SCHAEFFLER
SCHMIDT
@@ -1059,7 +1035,6 @@ SEEK
SELECT
SENER
SERVICES
-SES
SEVEN
SEW
SEX
@@ -1078,7 +1053,6 @@ SHOP
SHOPPING
SHOUJI
SHOW
-SHOWTIME
SI
SILK
SINA
@@ -1176,7 +1150,6 @@ THEATRE
TIAA
TICKETS
TIENDA
-TIFFANY
TIPS
TIRES
TIROL
@@ -1206,7 +1179,6 @@ TRADE
TRADING
TRAINING
TRAVEL
-TRAVELCHANNEL
TRAVELERS
TRAVELERSINSURANCE
TRUST
@@ -1261,14 +1233,12 @@ VIVO
VLAANDEREN
VN
VODKA
-VOLKSWAGEN
VOLVO
VOTE
VOTING
VOTO
VOYAGE
VU
-VUELOS
WALES
WALMART
WALTER
@@ -1386,7 +1356,6 @@ XN--J1AEF
XN--J1AMH
XN--J6W193G
XN--JLQ480N2RG
-XN--JLQ61U9W7B
XN--JVR189M
XN--KCRX77D1X4A
XN--KPRW13D
@@ -1398,7 +1367,6 @@ XN--MGB9AWBF
XN--MGBA3A3EJT
XN--MGBA3A4F16A
XN--MGBA7C0BBN0A
-XN--MGBAAKC7DVF
XN--MGBAAM7A8H
XN--MGBAB2BD
XN--MGBAH1A3HJKRD