Given that TreeValueProxy uses a conversion operator returning a const
value of the template type, you simply need to tell the compiler to use
that conversion operator, so that it doesn't try to invoke .first on the
TreeValueProxy class itself.

You should be able to simplify the existing suggestions and avoid redundant
declarations by using a temporary and taking .first of that. I assume the
following are ultimately equivalent:

// cast to invoke specific conversion operator
auto str = static_cast< std::pair<Glib::ustring, Glib::ustring> >(
row[columns.col] ).first;

// call copy ctor to make it deduce the right conversion
auto str = std::pair<Glib::ustring, Glib::ustring>{ row[columns.col]
}.first;



On Fr, 2016-07-01 at 15:14 +0530, Kamalpreet Grewal wrote:
> > I am making a pair as data type of Gtk::TreeModelColumn.
> > Gtk::TreeModelColumn<std::pair<Glib::ustring, Glib::ustring> > col;
> >
> > At some places I wish to get only first string of this pair. So I did
> > something like row[columns.col].first to access it. But I get an
> > error.
> >
> > error: 'class Gtk::TreeValueProxy<std::pair<Glib::ustring,
> > Glib::ustring> >' has no member named 'first'
> >
> > I am accessing it just like one will do with another std::pair. How
> > can this be achieved?
>
> Try putting it in a pair first. For instance:
> std::pair<Glib::ustring, Glib::ustring> thing = row[columns.col];
> auto str = thing.first;
>
> That might also work like this:
>
> const std::pair<Glib::ustring, Glib::ustring>& thing =
> row[columns.col];
> const auto& str = thing.first;
>
> --
> Murray Cumming
> murr...@murrayc.com
> www.murrayc.com
>
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to