CGAL::Default

Definition

Default is a tag class to be used in a template parameter list, in order to indicate that the default value is to be considered.

This is shorter and clearer than actually writing the default type, which may sometimes be complicated, and might even change in the future. The C++ language only provides a possibility when no following argument needs to be non-defaulted.

It can also be useful to shorten compiler error messages and mangled symbol names, and also to help define defaults in rare cases that involve circular dependencies, by breaking the cycle in a simple way.

Note that there is no magic : this only works if the template class where Default is plugged-in takes special care for it, so you should refer to the manual of such classes to know whether this possibility is offered.

Beware that, of course, the resulting template type parameterized by Default will not formally be the same type as the one parameterized by the actual documented, expanded, default. This may have consequences.

Is Model for the Concepts

DefaultConstructible, CopyConstructible

Types

In order to help the template class writer, Default provides a convenient way to extract the desired value for an argument which may be defaulted using Default.

template <typename Argument, typename Value>
Default:: struct Get;
This nested template offers a further nested type type which is either equal to Argument if Argument is not Default or Value otherwise.

Example code

File: examples/STL_Extension/Default.cpp
#include <CGAL/Default.h>

struct A {};

template < typename A1_ = A, // we could also write CGAL::Default here instead
           typename A2 = int >
struct B
{
    typedef typename CGAL::Default::Get<A1_, A>::type  A1;
    A1 a1;
};

int main ()
{
    B<CGAL::Default, double> b;

    A a = b.a1; //  It is really of type A.
}