check.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #include <boost/geometry/core/cs.hpp>
  12. #include <boost/geometry/geometries/concepts/check.hpp>
  13. struct ro_point
  14. {
  15. float x, y;
  16. };
  17. struct rw_point
  18. {
  19. float x, y;
  20. };
  21. namespace boost { namespace geometry { namespace traits {
  22. template <> struct tag<ro_point> { typedef point_tag type; };
  23. template <> struct coordinate_type<ro_point> { typedef float type; };
  24. template <> struct coordinate_system<ro_point> { typedef bg::cs::cartesian type; };
  25. template <> struct dimension<ro_point> { enum { value = 2 }; };
  26. template <> struct access<ro_point, 0>
  27. {
  28. static float get(ro_point const& p) { return p.x; }
  29. };
  30. template <> struct access<ro_point, 1>
  31. {
  32. static float get(ro_point const& p) { return p.y; }
  33. };
  34. template <> struct tag<rw_point> { typedef point_tag type; };
  35. template <> struct coordinate_type<rw_point> { typedef float type; };
  36. template <> struct coordinate_system<rw_point> { typedef bg::cs::cartesian type; };
  37. template <> struct dimension<rw_point> { enum { value = 2 }; };
  38. template <> struct access<rw_point, 0>
  39. {
  40. static float get(rw_point const& p) { return p.x; }
  41. static void set(rw_point& p, float value) { p.x = value; }
  42. };
  43. template <> struct access<rw_point, 1>
  44. {
  45. static float get(rw_point const& p) { return p.y; }
  46. static void set(rw_point& p, float value) { p.y = value; }
  47. };
  48. }}} // namespace bg::traits
  49. int main()
  50. {
  51. bg::concepts::check<const ro_point>();
  52. bg::concepts::check<rw_point>();
  53. }