insert.detail.hpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once


#include <span>


namespace felspar::parse::binary::detail {


    template<typename T>
    void native_insert(
            std::span<std::byte, sizeof(T)> const s, T const t) noexcept {
        auto const input = std::as_bytes(std::span{&t, 1});
        std::copy(input.begin(), input.end(), s.begin());
    }
    template<typename T>
    void non_native_insert(
            std::span<std::byte, sizeof(T)> const s, T const t) noexcept {
        auto const input = std::as_bytes(std::span{&t, 1});
        std::copy(input.rbegin(), input.rend(), s.begin());
    }


}