In the code shown below, i want to align buffer to a 64 byte boundary
#include <vector>
#include <iostream>
int main()
{
using Buffer = alignas(64) std::vector<char>;
Buffer buffer;
buffer.push_back('a');
buffer.push_back('b');
buffer.push_back('c');
for (auto& i : buffer)
std::cout << i << "\n";
}
When i compile the code, i get the following warning.
warning: ignoring attributes applied to class type βstd::vector<char>β outside of definition [-Wattributes]
using Buffer = alignas(64) std::vector<char>;
^~~~~~~~~~~~
What am i doing wrong here? How to define a vector that is aligned to a 64 byte boundary?
EDIT: I want to align the underlying data that the vector owns. Is it possible to align that to a 64 byte boundary when using std::vector?