[LLVMdev] Explicit constructors with more than one argument

David Blaikie dblaikie at gmail.com
Sun Mar 15 09:58:19 PDT 2015

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

> 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.)
> 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};".

Yeah, my current take on it is: yeah, some 'explicit' on multi-arg ctors is
probably accidental, but it's not pointless so removing it isn't entirely
trivial. But adding explicit to every no-arg ctor you don't want to call
with braced init seems... painfully verbose, so I've not taken a strong
stance that we should do that either.

And I /think/ MSVC still doesn't support braced init, so it's all a bit of
an abstract debate for the LLVM codebase for now anyway.

> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150315/12bb2360/attachment.html>

More information about the llvm-dev mailing list