billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
640 stars 93 forks source link

Should Class::name() return const Id& rather than IdRef? #60

Closed Weeena closed 7 years ago

Weeena commented 7 years ago

I had the following problem: I wanted to write something like this

THROW("Unexpected type: " + class.name());

Alas, that did not compile because name() returns a string_view and string_view does not support the required operator+. As a workaround, I can write

THROW("Unexpected type: " + std::string(class.name()));

but, to be honest, I dont like that very much (and I guess it causes an extra copy).

Since internally, Class stores its name as an Id (which is identical to std::string), I suggest to replace the current

IdRef name() const;

with

const Id& name() const;

Advantage: No unnecessary restrictions are caused.

billyquith commented 7 years ago

That makes sense.

billyquith commented 7 years ago

In master.