Commit ed3220f3 authored by Max Kellermann's avatar Max Kellermann

util/{Foreign,Static}FifoBuffer: use C++11 initializers

parent 043cbec6
/* /*
* Copyright (C) 2003-2014 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2003-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -57,15 +57,15 @@ public: ...@@ -57,15 +57,15 @@ public:
typedef typename Range::const_pointer_type const_pointer_type; typedef typename Range::const_pointer_type const_pointer_type;
protected: protected:
size_type head, tail, capacity; size_type head = 0, tail = 0, capacity;
T *data; T *data;
public: public:
explicit constexpr ForeignFifoBuffer(std::nullptr_t n) explicit constexpr ForeignFifoBuffer(std::nullptr_t n)
:head(0), tail(0), capacity(0), data(n) {} :capacity(0), data(n) {}
constexpr ForeignFifoBuffer(T *_data, size_type _capacity) constexpr ForeignFifoBuffer(T *_data, size_type _capacity)
:head(0), tail(0), capacity(_capacity), data(_data) {} :capacity(_capacity), data(_data) {}
ForeignFifoBuffer(ForeignFifoBuffer &&src) ForeignFifoBuffer(ForeignFifoBuffer &&src)
:head(src.head), tail(src.tail), :head(src.head), tail(src.tail),
......
/* /*
* Copyright (C) 2003-2014 Max Kellermann <max.kellermann@gmail.com> * Copyright (C) 2003-2017 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -52,13 +52,10 @@ public: ...@@ -52,13 +52,10 @@ public:
typedef WritableBuffer<T> Range; typedef WritableBuffer<T> Range;
protected: protected:
size_type head, tail; size_type head = 0, tail = 0;
T data[size]; T data[size];
public: public:
constexpr
StaticFifoBuffer():head(0), tail(0) {}
void Shift() { void Shift() {
if (head == 0) if (head == 0)
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment