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

Correct array initialisation #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ngraziano
Copy link

std::array<int,5> test={ 1 };
should fill element 1 to 4 with 0;

In other library the member data element is public
to allow compiler to fill it directly.
Use same principle.

A code example that test this:

#ifdef ARDUINO
#include <ArduinoSTL.h>
#endif

#include <array>
#include <iostream>

std::array<int16_t, 8> test_array;

void test()
{
  test_array = {0, 1, 2, 3, 4, 5, 6, 7};
  std::cout << "Value shoud be 0 1 2 3 4 5 6 7  : ";
  for (auto values : test_array)
  {
    std::cout << values << " ";
  }
  std::cout << std::endl;

  test_array = {5, 5};

  std::cout << "Value shoud be 5 5 0 0 0 0 0 0  : ";
  for (auto values : test_array)
  {
    std::cout << values << " ";
  }
  std::cout << std::endl;
}

#ifdef ARDUINO
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  test();
}
#else
int main(int argc, char **args)
{
  while(true)
    test();
}
#endif

std::array<int,5> test={ 1 };
should fill element 1 to 4 with 0;

In other library the member data element is public
to allow compiler to fill it directly.
Use same principle.

# Conflicts:
#	src/array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant