cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Check all Has_foo_bar traits classes

Open lrineau opened this issue 3 years ago • 0 comments

Issue Details

[lrineau@fernand]~% ack 'static const bool value.*sizeof' Git/cgal-master/^build*   
Git/cgal-master/BGL/include/CGAL/boost/graph/internal/Has_member_clear.h
28:  static const bool value = (sizeof(f<T>(0)) == sizeof(char));

Git/cgal-master/BGL/include/CGAL/boost/graph/internal/Has_member_id.h
28:    static const bool value = (sizeof(char) == sizeof(check<Type>(0)));

Git/cgal-master/BGL/include/CGAL/boost/graph/split_graph_into_polylines.h
56:  static const bool value = (sizeof(f<T>(0)) == sizeof(char));

Git/cgal-master/Box_intersection_d/include/CGAL/Box_intersection_d/segment_tree.h
325:  static const bool value = (sizeof(f<T>(0)) == sizeof(char));

Git/cgal-master/Filtered_kernel/include/CGAL/Lazy_kernel.h
61:  static const bool value = sizeof(test<T>(0)) == 1;

Git/cgal-master/Triangulation_2/include/CGAL/Constrained_triangulation_2.h
1853:    static const bool value = (sizeof(char) == sizeof(check<Type>(0)));
  • The implementation using expression-SFINAE, like in BGL/include/CGAL/boost/graph/internal/Has_member_id.h, is the best.
  • The check functions should not use char and int, because they might have the same sizeof.
  • Ideally, the two typedefs of different sizes should be named Yes and No, for readability.

lrineau avatar Jun 01 '22 14:06 lrineau