1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2015.
8 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Use, modification and distribution is subject to the Boost Software License,
13 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
14 // http://www.boost.org/LICENSE_1_0.txt)
16 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
17 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
19 #include <boost/geometry/core/exception.hpp>
20 #include <boost/geometry/algorithms/is_empty.hpp>
22 // BSG 2012-02-06: we use this currently only for distance.
23 // For other scalar results area,length,perimeter it is commented on purpose.
24 // Reason is that for distance there is no other choice. distance of two
25 // empty geometries (or one empty) should NOT return any value.
26 // But for area it is no problem to be 0.
27 // Suppose: area(intersection(a,b)). We (probably) don't want a throw there...
29 // So decided that at least for Boost 1.49 this is commented for
30 // scalar results, except distance.
32 #if defined(BOOST_GEOMETRY_EMPTY_INPUT_NO_THROW)
33 #include <boost/core/ignore_unused.hpp>
36 namespace boost { namespace geometry
39 #ifndef DOXYGEN_NO_DETAIL
43 template <typename Geometry>
44 inline void throw_on_empty_input(Geometry const& geometry)
46 #if ! defined(BOOST_GEOMETRY_EMPTY_INPUT_NO_THROW)
47 if (geometry::is_empty(geometry))
49 throw empty_input_exception();
52 boost::ignore_unused(geometry);
57 #endif // DOXYGEN_NO_DETAIL
60 }} // namespace boost::geometry
63 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP