Re: C++11 move constructors
- From: Murray Cumming <murrayc murrayc com>
- To: Reece Dunn <msclrhd googlemail com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: C++11 move constructors
- Date: Wed, 26 Jun 2013 13:16:17 +0200
On Wed, 2013-06-26 at 11:33 +0100, Reece Dunn wrote:
In the server_without_bus example, the type is changed from
`Glib::ustring` to `char *` in:
-static Glib::ustring introspection_xml =
+static auto introspection_xml =
"<node>"
I guess it should be const auto. But otherwise, the change seems good to
me. We don't actually use the ustring API on that.
auto should only be used:
1/ if it is shorter (e.g. std::unordered_map<Glib::ustring,
Glib::ustring>::const_iterator)
2/ if the deduced type matches the variable type
e.g. declaring the `GPid` type `auto` does not buy you anything in
terms of improved readability.
It avoids the person having to think about the actual type name, which
seems useful, though I guess it's a matter of taste. My opinion about
that changes day to day.
Is there any official discouragement from using it in this way?
Is there anything else simple that we could do there?
1. right-angle brackets (`>>` instead of `> >`)
2. static_assert
3. nullptr
4. defaulted/deleted functions (e.g. for nocopy objects)
Thanks.
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]