Skip to content

Commit bc8a64d

Browse files
committed
mark conversions as explicitly implicit
Signed-off-by: TymianekPL <[email protected]>
1 parent 3a2e6a9 commit bc8a64d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Test/Test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ int main()
55
{
66
cppjson::Object object{};
77
std::println("{}", object);
8-
object["test"] = "Hello World";
8+
object["test1"] = "Hello World";
9+
object["test2"] = 123.0;
910
std::println("{}", object);
1011
}

cppjson/include/cppjson/object.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ namespace cppjson
6868
explicit ObjectProxy(JsonObject& object) : _object(std::ref(object)) {}
6969

7070
template <typename T>
71-
operator T&()
71+
explicit(false) operator T&()
7272
{
7373
return this->_object.get().As<T>();
7474
}
7575

7676
template <typename T>
77-
operator const T&() const
77+
explicit(false) operator const T&() const
7878
{
7979
return this->_object.get().As<T>();
8080
}
@@ -100,7 +100,7 @@ namespace cppjson
100100
public:
101101
explicit ConstObjectProxy(const JsonObject& object) : _object(std::ref(object)) {}
102102
template <typename T>
103-
operator const T&() const
103+
explicit(false) operator const T&() const
104104
{
105105
return this->_object.get().As<T>();
106106
}

0 commit comments

Comments
 (0)