jbandela jbandela

Niner since 2012


  • Stephan T. Lavavej - Core C++, 6 of n


    Great video. I am having a problem with uniform initialization. When I try to call an explicit constructor with uniform initialization, I get the following error.


    error C2440: 'initializing' : cannot convert from 'initializer-list' to 'S'


    Below is s small example


    struct S{
        explicit S(int){}
    int main(){
        S s{10};


    I originally got this error when using the brace initialization with ifstream which has a explicit constructor.


    The error resolves with either using parentheses instead of braces, or making the constructor not explicit.


    Is this a compiler bug, or is there something I am not understanding about uniform initialization