{"action":"opened","issue":{"url":"https://api.github.com/repos/CGAL/cgal/issues/1080","repository_url":"https://api.github.com/repos/CGAL/cgal","labels_url":"https://api.github.com/repos/CGAL/cgal/issues/1080/labels{/name}","comments_url":"https://api.github.com/repos/CGAL/cgal/issues/1080/comments","events_url":"https://api.github.com/repos/CGAL/cgal/issues/1080/events","html_url":"https://github.com/CGAL/cgal/issues/1080","id":154654395,"number":1080,"title":"Surface_mesh: invalid conversion in properties and Property_selector","user":{"login":"etlapale","id":18539435,"avatar_url":"https://avatars.githubusercontent.com/u/18539435?v=3","gravatar_id":"","url":"https://api.github.com/users/etlapale","html_url":"https://github.com/etlapale","followers_url":"https://api.github.com/users/etlapale/followers","following_url":"https://api.github.com/users/etlapale/following{/other_user}","gists_url":"https://api.github.com/users/etlapale/gists{/gist_id}","starred_url":"https://api.github.com/users/etlapale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etlapale/subscriptions","organizations_url":"https://api.github.com/users/etlapale/orgs","repos_url":"https://api.github.com/users/etlapale/repos","events_url":"https://api.github.com/users/etlapale/events{/privacy}","received_events_url":"https://api.github.com/users/etlapale/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-13T07:57:47Z","updated_at":"2016-05-13T07:57:47Z","closed_at":null,"body":"Dear CGAL,\r\n\r\nI cannot seem to use the ``CGAL::Surface_mesh::properties()`` function.\r\n\r\nHere is a simple test case:\r\n\r\n```cpp\r\n#include <CGAL/Simple_cartesian.h>\r\n#include <CGAL/Surface_mesh.h>\r\n\r\nint main() {\r\n  using Point = CGAL::Simple_cartesian<double>::Point_3;\r\n  using Mesh = CGAL::Surface_mesh<Point>;\r\n\r\n  Mesh mesh;\r\n  auto props = mesh.properties<Mesh::Face_index>();\r\n  \r\n  return 0;\r\n}\r\n```\r\n\r\nThat’s what the compiler tells me:\r\n\r\n```\r\nIn file included from .../cgal-4.8/include/CGAL/Surface_mesh.h:23:0,\r\n                 from tc-sm-properties.cc:2:\r\n.../cgal-4.8/include/CGAL/Surface_mesh/Surface_mesh.h: In instantiation of ‘std::vector<std::basic_string<char> > CGAL::Surface_mesh<K>::properties() const [with I = CGAL::SM_Face_index; P = CGAL::Point_3<CGAL::Simple_cartesian<double> >]’:\r\ntc-sm-properties.cc:9:50:   required from here\r\n.../cgal-4.8/include/CGAL/Surface_mesh/Surface_mesh.h:2366:14: error: invalid conversion from ‘const CGAL::Surface_mesh<CGAL::Point_3<CGAL::Simple_cartesian<double> > >*’ to ‘CGAL::Surface_mesh<CGAL::Point_3<CGAL::Simple_cartesian<double> > >*’ [-fpermissive]\r\n       return Property_selector<I>(this)().properties();\r\n              ^~~~~~~~~~~~~~~~~~~~~~~~~~\r\n.../cgal-4.8/include/CGAL/Surface_mesh/Surface_mesh.h:2287:5: note:   initializing argument 1 of ‘CGAL::Surface_mesh<K>::Property_selector<CGAL::SM_Face_index, dummy>::Property_selector(CGAL::Surface_mesh<K>*) [with bool dummy = true; P = CGAL::Point_3<CGAL::Simple_cartesian<double> >]’\r\n     Property_selector(CGAL::Surface_mesh<P>* m) : m_(m) {}\r\n     ^~~~~~~~~~~~~~~~~\r\n```\r\n\r\nLooking at the ``properties()`` definition, we can see that it is defined as a ``const`` function, which makes sense:\r\n\r\n```cpp\r\ntemplate<class I>\r\nstd::vector<std::string> properties() const\r\n{\r\n  return Property_selector<I>(this)().properties();\r\n}\r\n```\r\n\r\nNow declaring the function as ``const`` makes ``this`` a ``const CGAL::Surface_mesh``. But ``Property_selector`` only defines constructors for non-const instances:\r\n\r\n```cpp\r\ntemplate<bool dummy>\r\nstruct Property_selector<typename CGAL::Surface_mesh<P>::Face_index, dummy> {\r\n  Property_selector(CGAL::Surface_mesh<P>* m) : m_(m) {}\r\n};\r\n```\r\n\r\nAn ugly workaround would be to ``const_cast`` inside ``properties()`` but it won't solve the problem elsewhere, in addition to being ugly.\r\n\r\nBest,"}}