<div dir="ltr"><div>Hi!<br></div><div><br></div><div>In my compiler I want to give user a list of user defined classes. I tried to use generated bitcode of my own wrapper of std::vector, but there is no possibility to generate bitcode of template, so I finally build it with std::vector<void*>. Do you know about any better solutions how to build such a type with llvm? Maybe there is a llvm built in type that is better choice than external c++ wrapper?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/16 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>Sorry, but I'm not sure I understand what you're trying to do. I guess you want some kind of superclass of some set of classes that are defined in the llvm api(?). In that case, which are specifically the types you could have in this list you're trying to define?</div>
<span class="HOEnZb"><font color="#888888">
                <div><div><br></div><div>-- </div><div>Cristianno Martins</div><div><br></div></div></font></span><div class="HOEnZb"><div class="h5">
                 
                <p style="color:#a0a0a8">On Tuesday, 16 de April de 2013 at 04:22, B B wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
                    <span><div><div><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><br><br><div>2013/4/15 Cristianno Martins <span dir="ltr"><<a href="mailto:cristiannomartins@gmail.com" target="_blank">cristiannomartins@gmail.com</a>></span><br><blockquote type="cite"><div>

                <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>
                  
                <p style="color:#a0a0a8">On Monday, 15 de April de 2013 at 07:13, B B wrote:</p>
                </div></div><blockquote type="cite"><div>
                    <span><div><div><div><div><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>
                  
                  
                  
                  
                </div></blockquote><div>
                    <br>
                </div>
            </div></blockquote></div><br></div>
</div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>
            </div></div></blockquote></div><br></div>