util/Macros: replace with std::size() (C++17)

This commit is contained in:
Max Kellermann
2019-08-03 13:10:49 +02:00
parent d305f187d5
commit cde6c46d2f
27 changed files with 84 additions and 115 deletions

View File

@@ -24,10 +24,10 @@
#include "system/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Domain.hxx"
#include "util/Macros.hxx"
#include "util/ByteOrder.hxx"
#include "Log.hxx"
#include <iterator>
#include <stdexcept>
#include <sys/stat.h>
@@ -168,7 +168,7 @@ static const char *const default_devices[] = { "/dev/sound/dsp", "/dev/dsp" };
static bool
oss_output_test_default_device() noexcept
{
for (int i = ARRAY_SIZE(default_devices); --i >= 0; ) {
for (int i = std::size(default_devices); --i >= 0; ) {
UniqueFileDescriptor fd;
if (fd.Open(default_devices[i], O_WRONLY, 0))
return true;
@@ -184,16 +184,16 @@ oss_output_test_default_device() noexcept
static OssOutput *
oss_open_default()
{
int err[ARRAY_SIZE(default_devices)];
enum oss_stat ret[ARRAY_SIZE(default_devices)];
int err[std::size(default_devices)];
enum oss_stat ret[std::size(default_devices)];
for (int i = ARRAY_SIZE(default_devices); --i >= 0; ) {
for (int i = std::size(default_devices); --i >= 0; ) {
ret[i] = oss_stat_device(default_devices[i], &err[i]);
if (ret[i] == OSS_STAT_NO_ERROR)
return new OssOutput(default_devices[i]);
}
for (int i = ARRAY_SIZE(default_devices); --i >= 0; ) {
for (int i = std::size(default_devices); --i >= 0; ) {
const char *dev = default_devices[i];
switch(ret[i]) {
case OSS_STAT_NO_ERROR:

View File

@@ -23,10 +23,10 @@
#include "mixer/MixerList.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/RuntimeError.hxx"
#include "util/Macros.hxx"
#include "util/StringCompare.hxx"
#include <array>
#include <iterator>
#include <stdlib.h>
#include <string.h>
@@ -86,7 +86,7 @@ MakeWaveOutError(MMRESULT result, const char *prefix)
{
char buffer[256];
if (waveOutGetErrorTextA(result, buffer,
ARRAY_SIZE(buffer)) == MMSYSERR_NOERROR)
std::size(buffer)) == MMSYSERR_NOERROR)
return FormatRuntimeError("%s: %s", prefix, buffer);
else
return std::runtime_error(prefix);

View File

@@ -22,7 +22,8 @@
#include "util/FormatString.hxx"
#include "util/AllocatedString.hxx"
#include "util/TruncateString.hxx"
#include "util/Macros.hxx"
#include <iterator>
#include <string.h>
@@ -97,7 +98,7 @@ icy_server_metadata_page(const Tag &tag, const TagType *types) noexcept
// Length + Metadata - "StreamTitle='';StreamUrl='';" = 4081 - 28
char stream_title[(1 + 255 - 28) * 16];
char *p = stream_title, *const end = stream_title + ARRAY_SIZE(stream_title);
char *p = stream_title, *const end = stream_title + std::size(stream_title);
stream_title[0] = '\0';
while (p < end && item <= last_item) {

View File

@@ -25,7 +25,6 @@
#include "../../OutputAPI.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "util/Macros.hxx"
#include "util/Domain.hxx"
#include "util/ByteOrder.hxx"
#include "Log.hxx"
@@ -33,6 +32,7 @@
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
#include <iterator>
#include <stdexcept>
class SlesOutput final : AudioOutput {
@@ -212,7 +212,7 @@ SlesOutput::Open(AudioFormat &audio_format)
};
result = engine.CreateAudioPlayer(&_object, &audioSrc, &audioSnk,
ARRAY_SIZE(ids2), ids2, req2);
std::size(ids2), ids2, req2);
if (result != SL_RESULT_SUCCESS) {
mix_object.Destroy();
engine_object.Destroy();