ulfben icon

span

ulfben | PRO | 02/12/20 07:20:36 AM UTC | 0 ⭐ | 1060 👁️ | Never ⏰ | []
C++ |

750 B

|

None

|

0 👍

/

0 👎

#include <cstdint>
 
template<typename T>
class span {
   T* ptr_;
   std::size_t len_;
public:
   using value_type = std::remove_cv_t<T>; //primarily needed if used with templates
 
   span(T* ptr, std::size_t len) noexcept : ptr_{ptr}, len_{len} {}
 
   T& operator[](int i) noexcept { return *ptr_[i]; }
   T const& operator[](int i) const noexcept { return *ptr_[i]; }
 
   bool empty() const noexcept { return len_ == 0; }
   auto size() const noexcept { return len_; }
 
   auto begin() noexcept { return ptr_; }   
   auto begin() const noexcept { return ptr_; }
   auto end() noexcept { return ptr_ + len_; }  
   auto end() const noexcept { return ptr_ + len_; }
};
static_assert(_MSVC_LANG <= 201703L, "Remember to switch to std::span");

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Yuizcko icon
    05/18/26 01:02:03 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400