문제

My buddy and I have been recently reading leveldb source code. And we encounter this problem. In leveldb db/skiplist.h file, there is a constructor declaration:

explicit SkipList(Comparator cmp, Arena* arena);

I know explicit constructor with single parameter means no implicit type conversion for constructor parameter. But what does double parameters constructor with explicit keyword mean? Is it new rule of C++11?

Thanks.

도움이 되었습니까?

해결책

With C++11, you can use braced-init-lists in place of some other expressions, and that makes a difference. For instance, you can use them in return statements:

SkipList foo() {
    return {{}, nullptr}; //does not compile with explicit constructor
    return SkipList{{}, nullptr}; //compiles with or without explicit constructor
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top