#pragma once

#include "../../../core/flags.hpp"
#include <memory>
#include <cassert>

namespace render {

struct data_view {
    data_view() { }
    data_view(const void *ptr, size_t size): ptr(ptr), size(size) { }
    template <typename Container>
    data_view(const Container &c): data_view(c.data(), c.size() * sizeof(typename Container::value_type)) {}

    constexpr bool isUsable() const { return ptr != nullptr && size > 0; }
    explicit operator bool() const { return isUsable(); }

    const void *ptr = nullptr;
    size_t size = 0;
};
struct data_ref {
    data_ref() { }
    data_ref(void *ptr, size_t size): ptr(ptr), size(size) { }
    template<typename Container>
    data_ref(Container &c):
        data_ref(c.data(), c.size() * sizeof(typename Container::value_type)) {}

    constexpr bool isUsable() const { return ptr != nullptr && size > 0; }
    explicit operator bool() const { return isUsable(); }

    void *ptr = nullptr;
    size_t size = 0;
};


}