Studying alignment issues, etc., I realized that my implementation of g ++ 4.9 (macports OS X) does not support std::align . If I try to compile (with -std=c++11 ) this sample code from http://www.cplusplus.com/reference/memory/align/
// align example #include <iostream> #include <memory> int main() { char buffer[] = "------------------------"; void * pt = buffer; std::size_t space = sizeof(buffer) - 1; while ( std::align(alignof(int), sizeof(char), pt, space) ) { char* temp = static_cast<char*>(pt); *temp = '*'; ++temp; space -= sizeof(char); pt = temp; } std::cout << buffer << '\n'; return 0; }
the compiler gives an error
error: 'align' is not a member of 'std'
This seems strange, since g ++ seems to have implemented alignment support with g ++ 4.8, https://gcc.gnu.org/projects/cxx0x.html (N2341)
The code compiles under clang ++ without any problems.
Is this a well-known g ++ issue that I don't know about? The online compilers I tested (ideone and coliru) also reject the code.
c ++ alignment c ++ 11
vsoftco
source share