Antoine Chavasse wrote:
> 
>> For instance, say you need to impliment a GUI, so you have yourself a
>> rectangle struct which consists of four floating point values (the origin
>> and difference between the opposite corner) ...Now you want those four
>> values, but you also have a 2D vector struct.
> 
> Here is a portable alternative to achieve this:
> 
> struct Rectangle
> {
>   private:
>     Vector2D m_Position;
>     Vector2D m_Size;
> 
>   public:
>     Vector2D& position() { return m_Position; }
>     const Vector2D& position() const { return m_Position; }
> 
>     Vector2D& size() { return m_Size; }
>     const Vector2D& size() const { return m_Size; }
> 
>     float& left() { return m_Position.x; }
>     float left() const { return m_Position.x; }
> 
>     float& top() { return m_Position.y; }
>     float top() const { return m_Position.y; }
> 
>     float& width() { return m_Size.x; }
>     float width() const { return m_Size.x; }
> 
>     float& height() { return m_Size.y; }
>     float height() const { return m_Size.y; }
> };
> 
> Then you can access the members like this:
> 
> Rect somerectangle;
> 
> Rect.position().x = 45;
> Rect.left() = 45;
> 
> 

I pointed this out as the obvious portable solution somewhere in the thread.
I just firmly believe this is an unnecessarily back breaking way of going
about it (and physically backbreaking for whoever would have to change all
of the code) 

It would be a blessing were intelligible code somewhat higher up on the
rungs of c++ priorities (being the ever ubiquitous mainstay systems
programming language it has become and will likely remain)

-- 
View this message in context: 
http://www.nabble.com/I%27m-sorry%2C-but-this-is-unacceptable-%28union-members-and-ctors%29-tf3930964.html#a11337133
Sent from the gcc - Dev mailing list archive at Nabble.com.

Reply via email to