stdcxx-0.7.0.0: src/STD/Vector/Template.hs
{-# LANGUAGE EmptyDataDecls, FlexibleInstances,
MultiParamTypeClasses, TypeFamilies #-}
module STD.Vector.Template where
import Foreign.C.Types
import Foreign.Ptr
import FFICXX.Runtime.Cast
import STD.VectorIterator.Template
data RawVector tp1
newtype Vector tp1 = Vector (Ptr (RawVector tp1))
class () => IVector tp1 where
newVector :: IO (Vector tp1)
begin :: Vector tp1 -> IO (VectorIterator tp1)
end :: Vector tp1 -> IO (VectorIterator tp1)
push_back :: Vector tp1 -> tp1 -> IO ()
pop_back :: Vector tp1 -> IO ()
at :: Vector tp1 -> CInt -> IO tp1
size :: Vector tp1 -> IO CInt
deleteVector :: Vector tp1 -> IO ()
instance () => FPtr (Vector tp1) where
type Raw (Vector tp1) = RawVector tp1
get_fptr (Vector ptr) = ptr
cast_fptr_to_obj = Vector
instance () => Castable (Vector tp1) (Ptr (RawVector tp1)) where
cast x f = f (castPtr (get_fptr x))
uncast x f = f (cast_fptr_to_obj (castPtr x))