<div dir="ltr"><div>Thank you for your answer!<br></div><div><br></div><div>You are right, but I still don't know how to build such a list dynamically using LLVM API with user type inside (I don't know this type yet ofc). </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/15 Cristianno Martins <span dir="ltr"><<a href="mailto:cristiannomartins@gmail.com" target="_blank">cristiannomartins@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

                <div>Hi,</div><div><br></div><div>
                    I guess you could use a template with a std::vector: you don't need to define right away the type, if you create a template of it.
                </div><div><br></div><div>It should look something like that:</div><div><br></div><div>template<class B> class List {</div><div>std::vector<B> myList;</div><div>void insert (int pos, B elem);</div>
<div>}</div><div><br></div><div>template <class B> </div><div>void List::add (int pos, B elem) { </div><div>  myList.insert(myList.begin()+pos, elem);</div><div>}</div>
                <div><div><br></div><div>Then, wherever you'll use this class, you should define for which class B your class List should match (such as "List<int> intList;" or "List< std::vector<long> > longVectors;").</div>
<div><br></div><div>-- </div><div>Cristianno Martins</div></div><div><div class="h5">
                 
                <p style="color:#a0a0a8">On Monday, 15 de April de 2013 at 07:13, B B wrote:</p>
                </div></div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
                    <span><div><div><div><div class="h5"><div>Hi!</div><div>I want to implement a list (which operates like ArrayList in Java).</div><div><br></div><div>I can use ArrayType from llvm, but at creation time I have to specify</div>
<div>size so there is a problem when I want to extend it (I can reallocate</div><div>it ofc). Moreover I need to implement all the operations (inserting,</div><div>removing etc.) manually.</div><div><br></div><div>I though that maybe I can use std::vector, but there is another</div>
<div>problem - std::vector is a template class, so I have to specify type</div><div>before compiling it to llvm bytecode. Is there some solution to</div><div>specify that type dynamically?</div><div><br></div><div>What is the best method to implement such things in llvm?</div>
<div><br></div><div>I would be grateful for any solutions or tips.</div></div></div><div>_______________________________________________</div><div>LLVM Developers mailing list</div><div><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a></div>
<div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>
            </blockquote></div><br></div>