# Wrap a POD type in arrays Efficiently

**URL:** <https://discourse.julialang.org/t/wrap-a-pod-type-in-arrays-efficiently/16833>\
**Category:** General Usage\
**Created:** [October 26, 2018, 6:42pm UTC](https://discourse.julialang.org/t/wrap-a-pod-type-in-arrays-efficiently/16833 "2018-10-26T18:42:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [October 26, 2018, 6:42pm UTC](https://discourse.julialang.org/t/wrap-a-pod-type-in-arrays-efficiently/16833/1 "2018-10-26T18:42:03Z")

</div>

I’m trying to add a tag to an Integer which is either `0` or `1` (it will used for indexing, so I’m not using Booleans), which will looks like:

```julia
struct Bit{T <: Integer}
    value::T
end

```

However, this approach will suffer when trying to use an array for indexing, e.g

```julia
S = Bit{Int}[Bit(1), Bit(0)]

```

And then I will need to convert a array of `Array{Bit{Int}}` to `Array{Int}` which will allocates another array, is it possible to directly `reinterpret` the array rather than doing the conversion? like in C++ there is a `reinterpret_cast`, is there anything similar? Or there is better approach in this?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 26, 2018, 6:45pm UTC](https://discourse.julialang.org/t/wrap-a-pod-type-in-arrays-efficiently/16833/2 "2018-10-26T18:45:30Z")

</div>

Why is `reinterpret(Int, S)` and then working with the reinterpreted array good enough?
