Skip to content

Quesiton with state to state10.  #2

@Elektro93

Description

@Elektro93

Hello, I am coming from embedded C, I just started learning C++, so maybe this question is going far ahead or even sound stupid to veteran C++ devs. I know that the purpose of the checkbox is to see the progress of the weekly episodes so it is a pretty simple solution to do that but, if we would like to optimize the solution, does the following make sense:
If I understand properly the bool type is taking up a byte in the memory.
If we would like to optimize from the side of memory, would it be better to use bit fields(i am not sure if this is the way to go with C++20), or bitsets/dynamic_bitsets. But yes this would have to be casted into a bool.
Example:
typedef struct t
{
uint16_t State:1;
uint16_t State1:1;
uint16_t State2:1;
uint16_t State3:1;
uint16_t State4:1;
uint16_t State5:1;
uint16_t State6:1;
uint16_t State7:1;
uint16_t State8:1;
uint16_t State9:1;
uint16_t State10:1;
}CheckBox_Status;

Thank you for doing this tutorial series.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions