libshit

Just some random shit
git clone https://git.neptards.moe/neptards/libshit.git
Log | Files | Refs | Submodules | README | LICENSE

iterator (692B)


      1 // -*- c++ -*-
      2 #pragma once
      3 
      4 #include_next <iterator>
      5 
      6 namespace std
      7 {
      8 
      9   template <typename T>
     10   constexpr auto size(const T& t) -> decltype(t.size()) { return t.size(); }
     11 
     12   template <typename T, size_t N>
     13   constexpr size_t size(const T (&ary)[N]) noexcept { return N; }
     14 
     15 
     16   template <typename C>
     17   constexpr auto data(C& c) -> decltype(c.data()) { return c.data(); }
     18 
     19   template <typename C>
     20   constexpr auto data(const C& c) -> decltype(c.data()) { return c.data(); }
     21 
     22   template <typename T, std::size_t N>
     23   constexpr T* data(T (&array)[N]) noexcept { return array; }
     24 
     25   template <typename E>
     26   constexpr const E* data(std::initializer_list<E> il) noexcept
     27   { return il.begin(); }
     28 
     29 }