string equality + tweaks
This commit is contained in:
parent
5c0f051eac
commit
850d20093a
|
@ -95,7 +95,7 @@ template<typename T> BinaryNegate<T> not2(const T &fn) {
|
||||||
|
|
||||||
template<typename T> struct ToHash {
|
template<typename T> struct ToHash {
|
||||||
using Argument = const T &;
|
using Argument = const T &;
|
||||||
using Result = typename T::Size;
|
using Result = octa::Size;
|
||||||
|
|
||||||
octa::Size operator()(const T &v) const {
|
octa::Size operator()(const T &v) const {
|
||||||
return v.to_hash();
|
return v.to_hash();
|
||||||
|
|
|
@ -541,6 +541,9 @@ template<typename T> struct Allocator {
|
||||||
|
|
||||||
template<typename U> using Rebind = Allocator<U>;
|
template<typename U> using Rebind = Allocator<U>;
|
||||||
|
|
||||||
|
Allocator() {}
|
||||||
|
template<typename U> Allocator(const Allocator<U> &) {}
|
||||||
|
|
||||||
Pointer address(Reference v) const {
|
Pointer address(Reference v) const {
|
||||||
return address_of(v);
|
return address_of(v);
|
||||||
};
|
};
|
||||||
|
@ -575,6 +578,9 @@ template<typename T> struct Allocator<const T> {
|
||||||
|
|
||||||
template<typename U> using Rebind = Allocator<U>;
|
template<typename U> using Rebind = Allocator<U>;
|
||||||
|
|
||||||
|
Allocator() {}
|
||||||
|
template<typename U> Allocator(const Allocator<U> &) {}
|
||||||
|
|
||||||
ConstPointer address(ConstReference v) const {
|
ConstPointer address(ConstReference v) const {
|
||||||
return address_of(v);
|
return address_of(v);
|
||||||
};
|
};
|
||||||
|
|
|
@ -288,6 +288,14 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compare(const StringBase &s) const {
|
||||||
|
return strcmp(p_buf.data(), s.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
int compare(ConstPointer p) const {
|
||||||
|
return strcmp(p_buf.data(), p);
|
||||||
|
}
|
||||||
|
|
||||||
Range each() {
|
Range each() {
|
||||||
return Range(p_buf.data(), size());
|
return Range(p_buf.data(), size());
|
||||||
}
|
}
|
||||||
|
@ -315,6 +323,26 @@ using String = StringBase<char>;
|
||||||
using StringRange = StringRangeBase<char>;
|
using StringRange = StringRangeBase<char>;
|
||||||
using ConstStringRange = StringRangeBase<const char>;
|
using ConstStringRange = StringRangeBase<const char>;
|
||||||
|
|
||||||
|
static inline bool operator==(const String &lhs, const String &rhs) {
|
||||||
|
return !lhs.compare(rhs);
|
||||||
|
}
|
||||||
|
static inline bool operator==(const String &lhs, const char *rhs) {
|
||||||
|
return !lhs.compare(rhs);
|
||||||
|
}
|
||||||
|
static inline bool operator==(const char *lhs, const String &rhs) {
|
||||||
|
return !rhs.compare(lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool operator!=(const String &lhs, const String &rhs) {
|
||||||
|
return !!lhs.compare(rhs);
|
||||||
|
}
|
||||||
|
static inline bool operator!=(const String &lhs, const char *rhs) {
|
||||||
|
return !!lhs.compare(rhs);
|
||||||
|
}
|
||||||
|
static inline bool operator!=(const char *lhs, const String &rhs) {
|
||||||
|
return !!rhs.compare(lhs);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename F>
|
template<typename T, typename F>
|
||||||
String concat(const T v, const String &sep, F func) {
|
String concat(const T v, const String &sep, F func) {
|
||||||
String ret;
|
String ret;
|
||||||
|
|
|
@ -272,7 +272,7 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct CompressedPair: CompressedPairBase<T, U> {
|
struct CompressedPair: CompressedPairBase<T, U> {
|
||||||
typedef CompressedPairBase<T, U> Base;
|
using Base = CompressedPairBase<T, U>;
|
||||||
|
|
||||||
template<typename TT, typename UU>
|
template<typename TT, typename UU>
|
||||||
CompressedPair(TT &&a, UU &&b): Base(octa::forward<TT>(a),
|
CompressedPair(TT &&a, UU &&b): Base(octa::forward<TT>(a),
|
||||||
|
|
Loading…
Reference in a new issue