[LLVMdev] Explicit constructors with more than one argument

Gabriel Dos Reis gdr at integrable-solutions.net
Sun Mar 15 01:24:13 PDT 2015


On Sat, Mar 14, 2015 at 10:51 PM, Chandler Carruth <chandlerc at google.com>
wrote:

>
> On Sat, Mar 14, 2015 at 10:26 PM, Gabriel Dos Reis <
> gdr at integrable-solutions.net> wrote:
>
>> Hi,
>>
>> Some LLVM classes (e.g. ReturnInst) have explicit constructors with at
>> least two parameters (with no default arguments).   Why is that?  E.g. what
>> are they trying to prevent?
>>
>> -- Gaby
>>
>
> FWIW, I suspect that it is mostly an accident (IE, one of the arguments
> was added without removing the explicit or a default was removed, etc.)
>

OK, that sounds like it; thanks.


>
> However, there are good reasons for this in C++11 -- making constructors
> explicit prevents them from being called in return statements like "return
> {a, b};".
>

Err, if I can have "return T(a, b);", I am curious about what mistakes (in
LLVM codebase) are being prevented by refusing "return { a, b };" -- I tend
to write mostly only the brace these days, so I'm curious about where the
potholes are.


-- Gaby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150315/7b8c8113/attachment.html>


More information about the llvm-dev mailing list