Ok to provide constructor for behaviorless aggregates (bundle-o-data) in C++?
<p>Please refer to rule #41 of <a href="http://www.gotw.ca/publications/c++cs.htm" rel="nofollow">C++ Coding Standards</a> or Sutter's <a href="http://www.gotw.ca/gotw/070.htm" rel="nofollow">Gotw #70</a>, which states that:</p>

<blockquote>
  <p>Make data members private, except in behaviorless aggregates (C-style structs).</p>
</blockquote>

<p>I often would like to to add a simple constructor to these C-style structs, for the sake of convenience. For example:</p>

<pre><code>struct Position
{
    Position(double lat=0.0, double lon=0.0) : latitude(lat), longitude(lon) {}
    double latitude;
    double longitude;
};

void travelTo(Position pos) {...}

main()
{
    travelTo(Position(12.34, 56.78));
}
</code></pre>

<p>While making it easier to construct a Position on the fly, the constructor also kindly zero-initializes default Position objects for me.</p>

<p>Maybe I can follow std::pair's example and provide a "makePosition" free function? NRVO should make it as fast as the constructor, right?</p>

<pre><code>Position makePosition(double lat, double lon)
{
    Position p;
    p.latitude = lat;
    p.longitude = lon;
    return p;
}

travelTo(makePosition(12.34, 56.78));
</code></pre>

<p>Am I going against the spirit of the "behaviorless aggregate" concept by adding that measly little constructor? </p>

<p><strong>EDIT:</strong></p>

<p>Yes, I was aware of <code>Position p={12.34, 56.78}</code>. But I can't do <code>travelTo({12.34, 56.78})</code> with pure C structs.</p>

<p><strong>EDIT 2:</strong></p>

<p>For those curious about POD types: <a href="http://stackoverflow.com/questions/146452/what-are-pod-types-in-c">http://stackoverflow.com/questions/146452/what-are-pod-types-in-c</a></p>

<p><strong>FOLLOW-UP:</strong>
I've asked a follow-up question <a href="http://stackoverflow.com/questions/2128307/ok-to-provide-constructor-trivial-operators-for-behaviorless-aggregates">here</a> that is closely related to this one.</p>
