this repo has no description
at trunk 36 lines 692 B view raw
1/* Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) */ 2#pragma once 3 4#include <initializer_list> 5 6#include "globals.h" 7#include "utils.h" 8 9namespace py { 10 11template <typename T> 12class View { 13 public: 14 constexpr View(const T* data, word length) : data_(data), length_(length) {} 15 16 template <word N> 17 View(const T (&data)[N]) : data_(data), length_(N) {} 18 19 T get(word i) { 20 DCHECK_INDEX(i, length_); 21 return data_[i]; 22 } 23 24 const T* data() { return data_; } 25 26 word length() { return length_; } 27 28 const T* begin() const { return data_; } 29 const T* end() const { return data_ + length_; } 30 31 private: 32 const T* data_; 33 word length_; 34}; 35 36} // namespace py