PageRenderTime 29ms CodeModel.GetById 13ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/libs/geometry/test/point_concept/point_without_dimension.cpp

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