CGAL::Dimension_tag<int dim>


An object of the class Dimension_tag<int dim> is an empty object which can be used for dispatching functions based on the dimension of an object, as provided by the dim parameter. It is useful in cases where it is not more practical to pass the dimension as a template parameter directly.

#include <CGAL/Dimension.h>


static const int value; The value of the dim parameter.


The following code declares two functions constructing two points at the origin, either in 2D or in 3D.

  Point_2<K> get_origin(Dimension_tag<2>) { return Point_2<K>(ORIGIN); }
  Point_3<K> get_origin(Dimension_tag<3>) { return Point_3<K>(ORIGIN); }

  std::cout << get_origin(Dimension_tag<2>())) << std::endl;

See Also

CGAL::Ambient_dimension<T, K>
CGAL::Feature_dimension<T, K>