[LLVMdev] Explicit constructors with more than one argument
Benjamin Kramer
benny.kra at gmail.com
Mon Mar 16 09:26:37 PDT 2015
> On 15.03.2015, at 17:58, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> 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.)
>
> 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.
MSVC 2013 supports braced init, I'm using it in clang already and so far it seems to work.
- Ben
More information about the llvm-dev
mailing list