diff --git a/octa/map.h b/octa/map.h index 6ff7f4a..171d9e9 100644 --- a/octa/map.h +++ b/octa/map.h @@ -65,40 +65,47 @@ public: using ConstRange = octa::HashRange>; 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 - 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::value && + octa::IsConvertible, Value>::value, + bool + > = true + ): p_table(size, hf, eqf, alloc) { for (; !range.empty(); range.pop_front()) emplace(range.front()); } template - 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 - 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 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 init, octa::Size size, const A &alloc): - Map(octa::each(init), size, H(), C(), alloc) {} + Map(octa::InitializerList init, octa::Size size, const A &alloc) + : Map(octa::each(init), size, H(), C(), alloc) {} Map(octa::InitializerList 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(); } diff --git a/octa/string.h b/octa/string.h index 49c6fe2..a5ca6fc 100644 --- a/octa/string.h +++ b/octa/string.h @@ -174,8 +174,13 @@ public: StringBase(ConstPointer v, Size n, const A &a = A()): p_buf(ConstRange(v, n), a) {} - template StringBase(R range, const A &a = A()): - p_buf(range, a) { + template StringBase(R range, const A &a = A(), + octa::EnableIf< + octa::IsInputRange::value && + octa::IsConvertible, 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 + octa::EnableIf< + octa::IsInputRange::value && + octa::IsConvertible, Value>::value, + StringBase & + > operator=(const R &r) { p_buf = r; terminate(); return *this; diff --git a/octa/vector.h b/octa/vector.h index c38421f..89231de 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -167,8 +167,13 @@ public: Vector(InitializerList v, const A &a = A()): Vector(v.begin(), v.size(), a) {} - template Vector(R range, const A &a = A()): - Vector(a) { + template Vector(R range, const A &a = A(), + octa::EnableIf< + octa::IsInputRange::value && + octa::IsConvertible, Value>::value, + bool + > = true + ): Vector(a) { ctor_from_range(range); } @@ -224,7 +229,11 @@ public: } template - Vector &operator=(R range) { + octa::EnableIf< + octa::IsInputRange::value && + octa::IsConvertible, Value>::value, + Vector & + > operator=(R range) { clear(); ctor_from_range(range); return *this;