<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/2030/1/7/_/styles/combined.css?spaceKey=TOP&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/TOP/Style+Guide?focusedCommentId=9568794#comment-9568794">Style Guide</a></h2>
        <h4>Page
        <b>comment added</b> by              <a href="https://wiki.asterisk.org/wiki/display/~kpfleming">Kevin P. Fleming</a>
    </h4>
    <br/>
    <div class="notificationGreySide">
       <p>Umm... yeah. Of course. I'll remove that.</p>
    </div>

                <div style="border-bottom: 1px solid #ddd; padding: 10px 20px 7px 20px;">
        <strong>In reply to a comment by <a href="/wiki/display/~dlee"
                          class="url fn confluence-userlink" data-username="dlee"
                   >David M. Lee</a>:</strong><br/>
        <blockquote><p>constructors that accept only a const std::string should not be marked explicit, otherwise a constant static string (which is of type const char *) could not be passed as an argument to the constructor.</p></blockquote>

<p>Not quite.  An explicit ctor on <tt>Foo</tt> would disallow conversion from <tt>std::string</tt> to <tt>Foo</tt>, not <tt>char*</tt> to <tt>std::string</tt>.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: cpp; gutter: false"><![CDATA[
#include &lt;iostream&gt;

class Foo
{
public:
    explicit Foo(const std::string&amp; name) {}
};

int main()
{
    Foo allowed("allowed");        // no error
    Foo disallowed = std::string("disallowed"); // error: conversion from ‘std::string’ to non-scalar type ‘Foo’ requested
}
]]></script>
</div></div>
        </div>
    
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://wiki.asterisk.org/wiki/display/TOP/Style+Guide?focusedCommentId=9568794#comment-9568794">View Online</a>
              |
       <a id="reply-9568794" href="https://wiki.asterisk.org/wiki/display/TOP/Style+Guide?replyToComment=9568794#comment-9568794">Reply To This</a>
           </div>

</div>
</div>
</div>
</div>
</body>
</html>