The custom triangle example goes even further and implements a custom ring, where the area calculation algorithm is optimized for a triangle
#include <iostream>
#include <boost/array.hpp>
#include <boost/geometry/io/dsv/write.hpp>
struct triangle : public boost::array<boost::geometry::model::d2::point_xy<double>, 4>
{
    inline void close()
    {
        (*this)[3] = (*this)[0];
    }
};
namespace boost { namespace geometry {
template<>
inline double area<triangle>(const triangle& t)
{
    
    return 0.5 * ((t[1].x() - t[0].x()) * (t[2].y() - t[0].y())
                - (t[2].x() - t[0].x()) * (t[1].y() - t[0].y()));
}
}} 
int main()
{
    triangle t;
    t[0].x(0);
    t[0].y(0);
    t[1].x(5);
    t[1].y(0);
    t[2].x(2.5);
    t[2].y(2.5);
    t.close();
    std::cout << "Triangle: " << boost::geometry::dsv(t) << std::endl;
    std::cout << "Centroid: " << boost::geometry::dsv(c) << std::endl;
    return 0;
}