I have two versions of a class named 'vertex', one that uses direct accessors for the coordinates:
struct vertex
{
    // Coordinates
    std::array<double, 3> coords;
    // Direct accessors
    double & x;
    double & y;
    double & z;
    // Constructor
    template<typename... T> vertex(T &&... coordinates) :
        coords{{ std::forward<T>(coordinates)... }},
        x( coords[0] ), y( coords[1] ), z( coords[2] )
    { }
};
and other that uses access functions:
struct vertex
{
    // Coordinates
    std::array<double, 3> coords;
    // Access functions
    double & x() { return coords[0]; }
    double & y() { return coords[1]; }
    double & z() { return coords[2]; }
    // Constructor
    template<typename... T> vertex(T &&... coordinates) :
        coords{{ std::forward<T>(coordinates)... }}
    { }
};
Which approach is better for this specific case? I would appreciate any other suggestions. Thanks!
 
     
     
     
     
     
    