prevent vector/string/map range constructors to be used when the input arg is not a range (prevent conflicts with other ctors)
parent
7cdac42c4a
commit
e15bb6adf3
37
octa/map.h
37
octa/map.h
|
@ -65,40 +65,47 @@ public:
|
|||
using ConstRange = octa::HashRange<const octa::Pair<const K, T>>;
|
||||
using Allocator = A;
|
||||
|
||||
explicit Map(octa::Size size, const H &hf = H(), const C &eqf = C(),
|
||||
const A &alloc = A()): p_table(size, hf, eqf, alloc) {}
|
||||
explicit Map(octa::Size size, const H &hf = H(),
|
||||
const C &eqf = C(), const A &alloc = A()
|
||||
): p_table(size, hf, eqf, alloc) {}
|
||||
|
||||
Map(): Map(octa::Size(1 << 10)) {}
|
||||
explicit Map(const A &alloc): Map(octa::Size(1 << 10), H(), C(), alloc) {}
|
||||
|
||||
Map(octa::Size size, const A &alloc): Map(size, H(), C(), alloc) {}
|
||||
Map(octa::Size size, const H &hf, const A &alloc): Map(size, hf, C(),
|
||||
alloc) {}
|
||||
Map(octa::Size size, const H &hf, const A &alloc): Map(size, hf, C(), alloc) {}
|
||||
|
||||
template<typename R>
|
||||
Map(R range, octa::Size size = 1 << 10, const H &hf = H(), const C &eqf = C(),
|
||||
const A &alloc = A()): p_table(size, hf, eqf, alloc) {
|
||||
Map(R range, octa::Size size = 1 << 10, const H &hf = H(),
|
||||
const C &eqf = C(), const A &alloc = A(),
|
||||
octa::EnableIf<
|
||||
octa::IsInputRange<R>::value &&
|
||||
octa::IsConvertible<RangeReference<R>, Value>::value,
|
||||
bool
|
||||
> = true
|
||||
): p_table(size, hf, eqf, alloc) {
|
||||
for (; !range.empty(); range.pop_front())
|
||||
emplace(range.front());
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
Map(R range, octa::Size size, const A &alloc): Map(range, size, H(), C(),
|
||||
alloc) {}
|
||||
Map(R range, octa::Size size, const A &alloc)
|
||||
: Map(range, size, H(), C(), alloc) {}
|
||||
|
||||
template<typename R>
|
||||
Map(R range, octa::Size size, const H &hf, const A &alloc):
|
||||
Map(range, size, hf, C(), alloc) {}
|
||||
Map(R range, octa::Size size, const H &hf, const A &alloc)
|
||||
: Map(range, size, hf, C(), alloc) {}
|
||||
|
||||
Map(octa::InitializerList<Value> init, octa::Size size = 1 << 10,
|
||||
const H &hf = H(), const C &eqf = C(), const A &alloc = A()):
|
||||
Map(octa::each(init), size, hf, eqf, alloc) {}
|
||||
const H &hf = H(), const C &eqf = C(), const A &alloc = A()
|
||||
): Map(octa::each(init), size, hf, eqf, alloc) {}
|
||||
|
||||
Map(octa::InitializerList<Value> init, octa::Size size, const A &alloc):
|
||||
Map(octa::each(init), size, H(), C(), alloc) {}
|
||||
Map(octa::InitializerList<Value> init, octa::Size size, const A &alloc)
|
||||
: Map(octa::each(init), size, H(), C(), alloc) {}
|
||||
|
||||
Map(octa::InitializerList<Value> init, octa::Size size, const H &hf,
|
||||
const A &alloc): Map(octa::each(init), size, hf, C(), alloc) {}
|
||||
const A &alloc
|
||||
): Map(octa::each(init), size, hf, C(), alloc) {}
|
||||
|
||||
bool empty() const { return p_table.empty(); }
|
||||
octa::Size size() const { return p_table.size(); }
|
||||
|
|
|
@ -174,8 +174,13 @@ public:
|
|||
StringBase(ConstPointer v, Size n, const A &a = A()):
|
||||
p_buf(ConstRange(v, n), a) {}
|
||||
|
||||
template<typename R> StringBase(R range, const A &a = A()):
|
||||
p_buf(range, a) {
|
||||
template<typename R> StringBase(R range, const A &a = A(),
|
||||
octa::EnableIf<
|
||||
octa::IsInputRange<R>::value &&
|
||||
octa::IsConvertible<RangeReference<R>, Value>::value,
|
||||
bool
|
||||
> = true
|
||||
): p_buf(range, a) {
|
||||
terminate();
|
||||
}
|
||||
|
||||
|
@ -193,7 +198,12 @@ public:
|
|||
p_buf = ConstRange(v, strlen(v) + 1);
|
||||
return *this;
|
||||
}
|
||||
StringBase &operator=(const Range &r) {
|
||||
template<typename R>
|
||||
octa::EnableIf<
|
||||
octa::IsInputRange<R>::value &&
|
||||
octa::IsConvertible<RangeReference<R>, Value>::value,
|
||||
StringBase &
|
||||
> operator=(const R &r) {
|
||||
p_buf = r;
|
||||
terminate();
|
||||
return *this;
|
||||
|
|
|
@ -167,8 +167,13 @@ public:
|
|||
Vector(InitializerList<T> v, const A &a = A()):
|
||||
Vector(v.begin(), v.size(), a) {}
|
||||
|
||||
template<typename R> Vector(R range, const A &a = A()):
|
||||
Vector(a) {
|
||||
template<typename R> Vector(R range, const A &a = A(),
|
||||
octa::EnableIf<
|
||||
octa::IsInputRange<R>::value &&
|
||||
octa::IsConvertible<RangeReference<R>, Value>::value,
|
||||
bool
|
||||
> = true
|
||||
): Vector(a) {
|
||||
ctor_from_range(range);
|
||||
}
|
||||
|
||||
|
@ -224,7 +229,11 @@ public:
|
|||
}
|
||||
|
||||
template<typename R>
|
||||
Vector &operator=(R range) {
|
||||
octa::EnableIf<
|
||||
octa::IsInputRange<R>::value &&
|
||||
octa::IsConvertible<RangeReference<R>, Value>::value,
|
||||
Vector &
|
||||
> operator=(R range) {
|
||||
clear();
|
||||
ctor_from_range(range);
|
||||
return *this;
|
||||
|
|
Loading…
Reference in New Issue