Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Constructors #35

Open
dbahrdt opened this issue Sep 18, 2020 · 0 comments
Open

Improve Constructors #35

dbahrdt opened this issue Sep 18, 2020 · 0 comments
Assignees

Comments

@dbahrdt
Copy link
Member

dbahrdt commented Sep 18, 2020

All classes should have the follow two constructors:

///Does not consume the data
///Data begins at d[0]
CTOR(UByteArrayAdapter const & d, NoConsumeTag)


///Does consume the data
///Data begins at d[0]
///d is altered such that after completion of CTOR
///d[0] points to one beyond the class data
CTOR(UByteArrayAdapter & d, ConsumeTag)

This makes it possible to write the following code:

CTOR(UByteArrayAdapter & d, ConsumeTag t) :
m_member1(d, t),
m_member2(d, t),
m_member3(d, t)
{
  whatever = d.getUint8();
  d >> whatever2;
  d.shrinktoGetPtr();
}
@dbahrdt dbahrdt self-assigned this Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant