> On Sep 7, 2016, at 4:50 PM, Joerg Sonnenberger via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > On Wed, Sep 07, 2016 at 04:30:01PM -0700, Eugene Zelenko via llvm-dev wrote: >> What should be used for type declarations: typedef or using? typedef >> is there because of historical reasons, but LLVM code based is C++11 >> now. >> >> LLVM Coding Standards are not clear on this matter. > > Can you give some context for the situation you wonder about? They are > both valid in some situation.Are there cases were typedef is (technically) preferable (or needed) compared to using? — Mehdi
Piotr Padlewski via llvm-dev
2016-Sep-08 00:46 UTC
[llvm-dev] typedef or using in C++ code
2016-09-07 17:40 GMT-07:00 Mehdi Amini via llvm-dev <llvm-dev at lists.llvm.org>:> > > On Sep 7, 2016, at 4:50 PM, Joerg Sonnenberger via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > > > On Wed, Sep 07, 2016 at 04:30:01PM -0700, Eugene Zelenko via llvm-dev > wrote: > >> What should be used for type declarations: typedef or using? typedef > >> is there because of historical reasons, but LLVM code based is C++11 > >> now. > >> > >> LLVM Coding Standards are not clear on this matter. > > > > Can you give some context for the situation you wonder about? They are > > both valid in some situation. > > Are there cases were typedef is (technically) preferable (or needed) > compared to using? > > You cant writetemplate <typename T> using myVector = vector<T>; with typedef. But this case is very rare. I prefer to use using always because IMHO it is cleaner which part is the alias and which is aliasee (if there is word like this). Piotr -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160907/ec25f284/attachment.html>
> On Sep 7, 2016, at 5:46 PM, Piotr Padlewski <piotr.padlewski at gmail.com> wrote: > > > > 2016-09-07 17:40 GMT-07:00 Mehdi Amini via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>>: > > > On Sep 7, 2016, at 4:50 PM, Joerg Sonnenberger via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > > > > On Wed, Sep 07, 2016 at 04:30:01PM -0700, Eugene Zelenko via llvm-dev wrote: > >> What should be used for type declarations: typedef or using? typedef > >> is there because of historical reasons, but LLVM code based is C++11 > >> now. > >> > >> LLVM Coding Standards are not clear on this matter. > > > > Can you give some context for the situation you wonder about? They are > > both valid in some situation. > > Are there cases were typedef is (technically) preferable (or needed) compared to using? > > You cant writeThe question is the opposite: what are the cases where *typedef* is preferable to using? (I don’t know any, that’s why I ask.) — Mehdi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160907/685f2a9b/attachment.html>
Mehdi Amini via llvm-dev <llvm-dev at lists.llvm.org> writes:>> On Sep 7, 2016, at 4:50 PM, Joerg Sonnenberger via llvm-dev >> <llvm-dev at lists.llvm.org> wrote: >> >> On Wed, Sep 07, 2016 at 04:30:01PM -0700, Eugene Zelenko via llvm-dev wrote: >>> What should be used for type declarations: typedef or using? typedef >>> is there because of historical reasons, but LLVM code based is C++11 >>> now. >>> >>> LLVM Coding Standards are not clear on this matter. >> >> Can you give some context for the situation you wonder about? They are >> both valid in some situation. > > Are there cases were typedef is (technically) preferable (or needed) > compared to using?There's `extern "C"`. Other than that the `using` syntax provides a struct superset of the functionality. It would be perfectly reasonable to prefer `using` in new code.
Justin Bogner <mail at justinbogner.com> writes:> Mehdi Amini via llvm-dev <llvm-dev at lists.llvm.org> writes: >>> On Sep 7, 2016, at 4:50 PM, Joerg Sonnenberger via llvm-dev >>> <llvm-dev at lists.llvm.org> wrote: >>> >>> On Wed, Sep 07, 2016 at 04:30:01PM -0700, Eugene Zelenko via llvm-dev wrote: >>>> What should be used for type declarations: typedef or using? typedef >>>> is there because of historical reasons, but LLVM code based is C++11 >>>> now. >>>> >>>> LLVM Coding Standards are not clear on this matter. >>> >>> Can you give some context for the situation you wonder about? They are >>> both valid in some situation. >> >> Are there cases were typedef is (technically) preferable (or needed) >> compared to using? > > There's `extern "C"`. Other than that the `using` syntax provides a > struct superset of the functionality. It would be perfectly reasonableTypo. s/struct/strict/> to prefer `using` in new code.