|  | Home | Libraries | People | FAQ | More | 
Metafunction defining a type being either the specified tag, or one of the specified basetags if the type inherits from them.
Tags can inherit each other. A multi_point inherits, for example, both the multi_tag and the pointlike_tag. Often behaviour can be shared between different geometry types. A tag, found by the metafunction tag, can be casted to a more basic tag, and then dispatched by that tag.
template<typename Tag, typename BaseTag, typename BaseTag2, typename BaseTag3, typename BaseTag4, typename BaseTag5, typename BaseTag6, typename BaseTag7> struct tag_cast { // ... };
| Parameter | Default | Description | 
|---|---|---|
| typename Tag | The tag to be casted to one of the base tags | |
| typename BaseTag | First base tag | |
| typename BaseTag2 | void | Optional second base tag | 
| typename BaseTag3 | void | Optional third base tag | 
| typename BaseTag4 | void | Optional fourth base tag | 
| typename BaseTag5 | void | Optional fifth base tag | 
| typename BaseTag6 | void | Optional sixth base tag | 
| typename BaseTag7 | void | Optional seventh base tag | 
Either
          #include <boost/geometry.hpp>
        
Or
          #include <boost/geometry/core/tag_cast.hpp>
        
| ![[Note]](../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| The specified tag list is handled in the specified order: as soon as a tag inheriting the specified tag is found, it is defined as the metafunction typedef type. | 
| ![[Note]](../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| If none of the specified possible base tags is a base class of the specified tag, the tag itself is defined as the type result of the metafunction. | 
Compile time
Check if the polygon_tag can be casted to the areal_tag
#include <iostream> #include <typeinfo> #include <boost/geometry.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/point_xy.hpp> namespace geo = boost::geometry; int main() { typedef geo::model::d2::point_xy<double> point_type; typedef geo::model::polygon<point_type> polygon_type; typedef geo::tag<polygon_type>::type tag; typedef geo::tag_cast<tag, geo::linear_tag, geo::areal_tag>::type base_tag; std::cout << "tag: " << typeid(tag).name() << std::endl << "base tag: " << typeid(base_tag).name() << std::endl; return 0; }
Output (in MSVC):
tag: struct boost::geometry::polygon_tag base tag: struct boost::geometry::areal_tag