I'm trying to port some C++ code from Windows to OS X (using Xcode).
The following code:
writePosition %= std::size(bufferL);
is generating an error:
No member named 'size' in namespace 'std'
How do I fix this?
I'm trying to port some C++ code from Windows to OS X (using Xcode).
The following code:
writePosition %= std::size(bufferL);
is generating an error:
No member named 'size' in namespace 'std'
How do I fix this?
std::size()
is available starting from C++17. Try enabling -std=c++17
for your compiler.
Also, double check that the source files contain #include <iterator>
, either directly, or indirectly by #include
'ing any of the following headers:
<array>
<deque>
<forward_list>
<list>
<map>
<regex>
<set>
<string>
<string_view>
<unordered_map>
<unordered_set>
<vector>
Taking the info from cppreference i see that std::size
accepts two kinds of parameters: containers that have a method called size()
(from the stl or user defined) and fixed size arrays.
You should check if bufferL
is one of these.
Also you have to include the iterator
header file if bufferL
is a fixed size array and you haven't included any headers containing containers from the stl.
To be able to use std::size
you would have to ensure to include #include <iterator>
. The other thing you would have to check is the compiler supports C++17. This functionality is only available for compiler which are compliant with C++17 standard.
Change the compiler setting in your IDE to C++17 supported compiler.