On e.g. Arrays, I can index with @inbounds to avoid bounds checking. In my 
own custom type, which also implements getindex, what is the correct way of 
leveraging inbounds?

For example, I have code now that looks something like this:

function getindex(A::MyCustomArray, x)
    ix = clamp(round(Int, x), 1, length(A)) # yes, clamp makes sense in this 
case
    ...

but if the caller has specified @inbounds, I want to avoid the clamp and 
just set ix = round(Int, x). What would be the correct way to express that?

// T
​

Reply via email to