<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="mobile-web-app-capable" content="yes">
    <title>
        LEWG [[nodiscard]] policy - HackMD
    </title>
    <link rel="icon" type="image/png" href="https://hackmd.io/favicon.png">
    <link rel="apple-touch-icon" href="https://hackmd.io/apple-touch-icon.png">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css" integrity="sha256-3iu9jgsy9TpTwXKb7bNQzqWekRX7pPK+2OLj3R922fo=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css" integrity="sha256-QiWfLIsCT02Sdwkogf6YMiQlj4NE84MKkzEMkZnMGdg=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/themes/prism.min.css" integrity="sha256-vtR0hSWRc3Tb26iuN2oZHt3KRUomwTufNIf5/4oeCyg=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@hackmd/emojify.js@2.1.0/dist/css/basic/emojify.min.css" integrity="sha256-UOrvMOsSDSrW6szVLe8ZDZezBxh5IoIfgTwdNDgTjiU=" crossorigin="anonymous" />
    <style>
        @import url(https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i|Source+Code+Pro:300,400,500|Source+Sans+Pro:300,300i,400,400i,600,600i|Source+Serif+Pro&subset=latin-ext);.hljs{background:#fff;color:#333;display:block;overflow-x:auto;padding:.5em}.hljs-comment,.hljs-meta{color:#969896}.hljs-emphasis,.hljs-quote,.hljs-string,.hljs-strong,.hljs-template-variable,.hljs-variable{color:#df5000}.hljs-keyword,.hljs-selector-tag,.hljs-type{color:#a71d5d}.hljs-attribute,.hljs-bullet,.hljs-literal,.hljs-number,.hljs-symbol{color:#0086b3}.hljs-built_in,.hljs-builtin-name{color:#005cc5}.hljs-name,.hljs-section{color:#63a35c}.hljs-tag{color:#333}.hljs-attr,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-title{color:#795da3}.hljs-addition{background-color:#eaffea;color:#55a532}.hljs-deletion{background-color:#ffecec;color:#bd2c00}.hljs-link{text-decoration:underline}.markdown-body{word-wrap:break-word;font-size:16px;line-height:1.5}.markdown-body:after,.markdown-body:before{content:"";display:table}.markdown-body:after{clear:both}.markdown-body>:first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:#c00}.markdown-body .anchor{float:left;line-height:1;margin-left:-20px;padding-right:4px}.markdown-body .anchor:focus{outline:none}.markdown-body blockquote,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul{margin-bottom:16px;margin-top:0}.markdown-body hr{background-color:#e7e7e7;border:0;height:.25em;margin:24px 0;padding:0}.markdown-body blockquote{border-left:.25em solid #ddd;color:#777;font-size:16px;padding:0 1em}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body kbd,.popover kbd{background-color:#fcfcfc;border:1px solid;border-color:#ccc #ccc #bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb;color:#555;display:inline-block;font-size:11px;line-height:10px;padding:3px 5px;vertical-align:middle}.markdown-body .loweralpha{list-style-type:lower-alpha}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{font-weight:600;line-height:1.25;margin-bottom:16px;margin-top:24px}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:#000;vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 code,.markdown-body h1 tt,.markdown-body h2 code,.markdown-body h2 tt,.markdown-body h3 code,.markdown-body h3 tt,.markdown-body h4 code,.markdown-body h4 tt,.markdown-body h5 code,.markdown-body h5 tt,.markdown-body h6 code,.markdown-body h6 tt{font-size:inherit}.markdown-body h1{font-size:2em}.markdown-body h1,.markdown-body h2{border-bottom:1px solid #eee;padding-bottom:.3em}.markdown-body h2{font-size:1.5em}.markdown-body h3{font-size:1.25em}.markdown-body h4{font-size:1em}.markdown-body h5{font-size:.875em}.markdown-body h6{color:#777;font-size:.85em}.markdown-body ol,.markdown-body ul{padding-left:2em}.markdown-body ol.no-list,.markdown-body ul.no-list{list-style-type:none;padding:0}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-bottom:0;margin-top:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{padding-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{font-size:1em;font-style:italic;font-weight:700;margin-top:16px;padding:0}.markdown-body dl dd{margin-bottom:16px;padding:0 16px}.markdown-body table{display:block;overflow:auto;width:100%;word-break:normal;word-break:keep-all}.markdown-body table th{font-weight:700}.markdown-body table td,.markdown-body table th{border:1px solid #ddd;padding:6px 13px}.markdown-body table tr{background-color:#fff;border-top:1px solid #ccc}.markdown-body table tr:nth-child(2n){background-color:#f8f8f8}.markdown-body img{background-color:#fff;box-sizing:initial;max-width:100%}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{background-color:initial;max-width:none;vertical-align:text-top}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{border:1px solid #ddd;display:block;float:left;margin:13px 0 0;overflow:hidden;padding:7px;width:auto}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{clear:both;color:#333;display:block;padding:5px 0 0}.markdown-body span.align-center{clear:both;display:block;overflow:hidden}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{clear:both;display:block;overflow:hidden}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{background-color:#0000000a;border-radius:3px;font-size:85%;margin:0;padding:.2em 0}.markdown-body code:after,.markdown-body code:before,.markdown-body tt:after,.markdown-body tt:before{content:"\00a0";letter-spacing:-.2em}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body pre{word-wrap:normal}.markdown-body pre>code{background:#0000;border:0;font-size:100%;margin:0;padding:0;white-space:pre;word-break:normal}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{border-radius:3px;font-size:85%;line-height:1.45;overflow:auto}.markdown-body:not(.next-editor) pre{background-color:#f7f7f7;padding:16px}.markdown-body pre code,.markdown-body pre tt{word-wrap:normal;background-color:initial;border:0;display:inline;line-height:inherit;margin:0;max-width:auto;overflow:visible;padding:0}.markdown-body pre code:after,.markdown-body pre code:before,.markdown-body pre tt:after,.markdown-body pre tt:before{content:normal}.markdown-body .csv-data td,.markdown-body .csv-data th{font-size:12px;line-height:1;overflow:hidden;padding:5px;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-line-num{background:#fff;border:0;padding:10px 8px 9px;text-align:right}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{background:#f8f8f8;border-top:0;font-weight:700}.news .alert .markdown-body blockquote{border:0;padding:0 0 0 40px}.activity-tab .news .alert .commits,.activity-tab .news .markdown-body blockquote{padding-left:0}.task-list-item{list-style-type:none}.task-list-item label{font-weight:400}.task-list-item.enabled label{cursor:pointer}.task-list-item+.task-list-item{margin-top:3px}.task-list-item-checkbox{cursor:default!important;float:left;margin:.31em 0 .2em -1.3em!important;vertical-align:middle}.markdown-body{max-width:758px;overflow:visible!important;padding-bottom:40px;padding-top:40px;position:relative}.markdown-body.next-editor{overflow-x:hidden!important}.markdown-body .emoji{vertical-align:top}.markdown-body pre{border:inherit!important}.markdown-body code{color:inherit!important}.markdown-body pre code .wrapper{display:-moz-inline-flex;display:-ms-inline-flex;display:-o-inline-flex;display:inline-flex}.markdown-body pre code .gutter{float:left;overflow:hidden;-webkit-user-select:none;user-select:none}.markdown-body pre code .gutter.linenumber{border-right:3px solid #6ce26c!important;box-sizing:initial;color:#afafaf!important;cursor:default;display:inline-block;min-width:20px;padding:0 8px 0 0;position:relative;text-align:right;z-index:4}.markdown-body pre code .gutter.linenumber>span:before{content:attr(data-linenumber)}.markdown-body pre code .code{float:left;margin:0 0 0 16px}.markdown-body .gist .line-numbers{border-bottom:none;border-left:none;border-top:none}.markdown-body .gist .line-data{border:none}.markdown-body .gist table{border-collapse:inherit!important;border-spacing:0}.markdown-body code[data-gist-id]{background:none;padding:0}.markdown-body code[data-gist-id]:after,.markdown-body code[data-gist-id]:before{content:""}.markdown-body code[data-gist-id] .blob-num{border:unset}.markdown-body code[data-gist-id] table{margin-bottom:unset;overflow:unset}.markdown-body code[data-gist-id] table tr{background:unset}.markdown-body[dir=rtl] pre{direction:ltr}.markdown-body[dir=rtl] code{direction:ltr;unicode-bidi:embed}.markdown-body .alert{display:flex;flex-direction:column;gap:16px}.markdown-body .alert>*{margin:0}.markdown-body pre.abc,.markdown-body pre.flow-chart,.markdown-body pre.graphviz,.markdown-body pre.mermaid,.markdown-body pre.sequence-diagram,.markdown-body pre.vega{background-color:inherit;border-radius:0;overflow:visible;text-align:center;white-space:inherit}.markdown-body pre.abc>code,.markdown-body pre.flow-chart>code,.markdown-body pre.graphviz>code,.markdown-body pre.mermaid>code,.markdown-body pre.sequence-diagram>code,.markdown-body pre.vega>code{text-align:left}.markdown-body pre.abc>svg,.markdown-body pre.flow-chart>svg,.markdown-body pre.graphviz>svg,.markdown-body pre.mermaid>svg,.markdown-body pre.sequence-diagram>svg,.markdown-body pre.vega>svg{height:100%;max-width:100%}.markdown-body pre>code.wrap{word-wrap:break-word;white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap}.markdown-body summary{display:list-item}.markdown-body summary:focus{outline:none}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>:not(summary){display:none}.markdown-body figure{margin:1em 40px}.markdown-body .mark,.markdown-body mark{background-color:#fff1a7}.vimeo,.youtube{background-color:#000;background-position:50%;background-repeat:no-repeat;background-size:contain;cursor:pointer;display:table;overflow:hidden;text-align:center}.vimeo,.youtube{position:relative;width:100%}.youtube{padding-bottom:56.25%}.vimeo img{object-fit:contain;width:100%;z-index:0}.youtube img{object-fit:cover;z-index:0}.vimeo iframe,.youtube iframe,.youtube img{height:100%;left:0;position:absolute;top:0;width:100%}.vimeo iframe,.youtube iframe{vertical-align:middle;z-index:1}.vimeo .icon,.youtube .icon{color:#fff;height:auto;left:50%;opacity:.3;position:absolute;top:50%;transform:translate(-50%,-50%);transition:opacity .2s;width:auto;z-index:0}.vimeo:hover .icon,.youtube:hover .icon{opacity:.6;transition:opacity .2s}.slideshare .inner,.speakerdeck .inner{position:relative;width:100%}.slideshare .inner iframe,.speakerdeck .inner iframe{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%}.figma{display:table;padding-bottom:56.25%;position:relative;width:100%}.figma iframe{border:1px solid #eee;bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%}.markmap-container{height:300px}.markmap-container>svg{height:100%;width:100%}.MJX_Assistive_MathML{display:none}#MathJax_Message{z-index:1000!important}.ui-infobar{color:#777;margin:25px auto -25px;max-width:760px;position:relative;z-index:2}.toc .invisable-node{list-style-type:none}.ui-toc{bottom:20px;position:fixed;z-index:998}.ui-toc.both-mode{margin-left:8px}.ui-toc.both-mode .ui-toc-label{border-bottom-left-radius:0;border-top-left-radius:0;height:40px;padding:10px 4px}.ui-toc-label{background-color:#e6e6e6;border:none;color:#868686;transition:opacity .2s}.ui-toc .open .ui-toc-label{color:#fff;opacity:1;transition:opacity .2s}.ui-toc-label:focus{background-color:#ccc;color:#000;opacity:.3}.ui-toc-label:hover{background-color:#ccc;opacity:1;transition:opacity .2s}.ui-toc-dropdown{margin-bottom:20px;margin-top:20px;max-height:70vh;max-width:45vw;overflow:auto;padding-left:10px;padding-right:10px;text-align:inherit;width:25vw}.ui-toc-dropdown>.toc{max-height:calc(70vh - 100px);overflow:auto}.ui-toc-dropdown[dir=rtl] .nav{letter-spacing:.0029em;padding-right:0}.ui-toc-dropdown a{overflow:hidden;text-overflow:ellipsis;white-space:pre}.ui-toc-dropdown .nav>li>a{color:#767676;display:block;font-size:13px;font-weight:500;padding:4px 20px}.ui-toc-dropdown .nav>li:first-child:last-child>ul,.ui-toc-dropdown .toc.expand ul{display:block}.ui-toc-dropdown .nav>li>a:focus,.ui-toc-dropdown .nav>li>a:hover{background-color:initial;border-left:1px solid #000;color:#000;padding-left:19px;text-decoration:none}.ui-toc-dropdown[dir=rtl] .nav>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav>li>a:hover{border-left:none;border-right:1px solid #000;padding-right:19px}.ui-toc-dropdown .nav>.active:focus>a,.ui-toc-dropdown .nav>.active:hover>a,.ui-toc-dropdown .nav>.active>a{background-color:initial;border-left:2px solid #000;color:#000;font-weight:700;padding-left:18px}.ui-toc-dropdown[dir=rtl] .nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav>.active>a{border-left:none;border-right:2px solid #000;padding-right:18px}.ui-toc-dropdown .nav .nav{display:none;padding-bottom:10px}.ui-toc-dropdown .nav>.active>ul{display:block}.ui-toc-dropdown .nav .nav>li>a{font-size:12px;font-weight:400;padding-bottom:1px;padding-left:30px;padding-top:1px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>a{padding-right:30px}.ui-toc-dropdown .nav .nav>li>ul>li>a{font-size:12px;font-weight:400;padding-bottom:1px;padding-left:40px;padding-top:1px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a{padding-right:40px}.ui-toc-dropdown .nav .nav>li>a:focus,.ui-toc-dropdown .nav .nav>li>a:hover{padding-left:29px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav .nav>li>a:hover{padding-right:29px}.ui-toc-dropdown .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown .nav .nav>li>ul>li>a:hover{padding-left:39px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a:hover{padding-right:39px}.ui-toc-dropdown .nav .nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>a{font-weight:500;padding-left:28px}.ui-toc-dropdown[dir=rtl] .nav .nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>a{padding-right:28px}.ui-toc-dropdown .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>a{font-weight:500;padding-left:38px}.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active>a{padding-right:38px}.markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html[lang^=ja] .markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,ＭＳ ゴシック,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html[lang=zh-tw] .markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html[lang=zh-cn] .markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html .markdown-body[lang^=ja]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,ＭＳ ゴシック,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html .markdown-body[lang=zh-tw]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html .markdown-body[lang=zh-cn]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}html[lang^=ja] .ui-toc-dropdown{font-family:Source Sans Pro,Helvetica,Arial,Meiryo UI,MS PGothic,ＭＳ Ｐゴシック,sans-serif}html[lang=zh-tw] .ui-toc-dropdown{font-family:Source Sans Pro,Helvetica,Arial,Microsoft JhengHei UI,微軟正黑UI,sans-serif}html[lang=zh-cn] .ui-toc-dropdown{font-family:Source Sans Pro,Helvetica,Arial,Microsoft YaHei UI,微软雅黑UI,sans-serif}html .ui-toc-dropdown[lang^=ja]{font-family:Source Sans Pro,Helvetica,Arial,Meiryo UI,MS PGothic,ＭＳ Ｐゴシック,sans-serif}html .ui-toc-dropdown[lang=zh-tw]{font-family:Source Sans Pro,Helvetica,Arial,Microsoft JhengHei UI,微軟正黑UI,sans-serif}html .ui-toc-dropdown[lang=zh-cn]{font-family:Source Sans Pro,Helvetica,Arial,Microsoft YaHei UI,微软雅黑UI,sans-serif}.ui-affix-toc{max-height:70vh;max-width:15vw;overflow:auto;position:fixed;top:0}.back-to-top,.expand-toggle,.go-to-bottom{color:#999;display:block;font-size:12px;font-weight:500;margin-left:10px;margin-top:10px;padding:4px 10px}.back-to-top:focus,.back-to-top:hover,.expand-toggle:focus,.expand-toggle:hover,.go-to-bottom:focus,.go-to-bottom:hover{color:#563d7c;text-decoration:none}.back-to-top,.go-to-bottom{margin-top:0}.ui-user-icon{background-position:50%;background-repeat:no-repeat;background-size:cover;border-radius:50%;display:block;height:20px;margin-bottom:2px;margin-right:5px;margin-top:2px;width:20px}.ui-user-icon.small{display:inline-block;height:18px;margin:0 0 .2em;vertical-align:middle;width:18px}.ui-infobar>small>span{line-height:22px}.ui-infobar>small .dropdown{display:inline-block}.ui-infobar>small .dropdown a:focus,.ui-infobar>small .dropdown a:hover{text-decoration:none}.ui-more-info{color:#888;cursor:pointer;vertical-align:middle}.ui-more-info .fa{font-size:16px}.ui-connectedGithub,.ui-published-note{color:#888}.ui-connectedGithub{line-height:23px;white-space:nowrap}.ui-connectedGithub a.file-path{color:#888;padding-left:22px;text-decoration:none}.ui-connectedGithub a.file-path:active,.ui-connectedGithub a.file-path:hover{color:#888;text-decoration:underline}.ui-connectedGithub .fa{font-size:20px}.ui-published-note .fa{font-size:20px;vertical-align:top}.unselectable{-webkit-user-select:none;-o-user-select:none;user-select:none}.selectable{-webkit-user-select:text;-o-user-select:text;user-select:text}.inline-spoiler-section{cursor:pointer}.inline-spoiler-section .spoiler-text{background-color:#333;border-radius:2px}.inline-spoiler-section .spoiler-text>*{opacity:0}.inline-spoiler-section .spoiler-img{filter:blur(10px)}.inline-spoiler-section.raw{background-color:#333;border-radius:2px}.inline-spoiler-section.raw>*{opacity:0}.inline-spoiler-section.unveil{cursor:auto}.inline-spoiler-section.unveil .spoiler-text{background-color:#3333331a}.inline-spoiler-section.unveil .spoiler-text>*{opacity:1}.inline-spoiler-section.unveil .spoiler-img{filter:none}@media print{blockquote,div,img,pre,table{page-break-inside:avoid!important}a[href]:after{font-size:12px!important}}.markdown-body.slides{color:#222;position:relative;z-index:1}.markdown-body.slides:before{background-color:currentColor;bottom:0;box-shadow:0 0 0 50vw;content:"";display:block;left:0;position:absolute;right:0;top:0;z-index:-1}.markdown-body.slides section[data-markdown]{background-color:#fff;margin-bottom:1.5em;position:relative;text-align:center}.markdown-body.slides section[data-markdown] code{text-align:left}.markdown-body.slides section[data-markdown]:before{content:"";display:block;padding-bottom:56.23%}.markdown-body.slides section[data-markdown]>div:first-child{left:1em;max-height:100%;overflow:hidden;position:absolute;right:1em;top:50%;transform:translateY(-50%)}.markdown-body.slides section[data-markdown]>ul{display:inline-block}.markdown-body.slides>section>section+section:after{border:3px solid #777;content:"";height:1.5em;position:absolute;right:1em;top:-1.5em}.site-ui-font{font-family:Source Sans Pro,Helvetica,Arial,sans-serif}html[lang^=ja] .site-ui-font{font-family:Source Sans Pro,Helvetica,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,ＭＳ ゴシック,sans-serif}html[lang=zh-tw] .site-ui-font{font-family:Source Sans Pro,Helvetica,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif}html[lang=zh-cn] .site-ui-font{font-family:Source Sans Pro,Helvetica,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif}body{font-smoothing:subpixel-antialiased!important;-webkit-font-smoothing:subpixel-antialiased!important;-moz-osx-font-smoothing:auto!important;-webkit-overflow-scrolling:touch;font-family:Source Sans Pro,Helvetica,Arial,sans-serif;letter-spacing:.025em}html[lang^=ja] body{font-family:Source Sans Pro,Helvetica,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,ＭＳ ゴシック,sans-serif}html[lang=zh-tw] body{font-family:Source Sans Pro,Helvetica,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif}html[lang=zh-cn] body{font-family:Source Sans Pro,Helvetica,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}abbr[data-original-title],abbr[title]{cursor:help}body.modal-open{overflow-y:auto;padding-right:0!important}svg{text-shadow:none}
    </style>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" integrity="sha256-3Jy/GbSLrg0o9y5Z5n1uw0qxZECH7C6OQpVBgNFYa0g=" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js" integrity="sha256-g6iAfvZp+nDQ2TdTR/VVKJf3bGro4ub5fvWSWVRi2NE=" crossorigin="anonymous"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-shim.min.js" integrity="sha256-8E4Is26QH0bD52WoQpcB+R/tcWQtpzlCojrybUd7Mxo=" crossorigin="anonymous"></script>
    <![endif]-->
</head>

<body>
    <div id="doc" class="markdown-body container-fluid comment-enabled" data-hard-breaks="true" style=""><h1 id="LEWG-nodiscard-policy" data-id="LEWG-nodiscard-policy"><a class="anchor hidden-xs" href="#LEWG-nodiscard-policy" title="LEWG-nodiscard-policy"><span class="octicon octicon-link"></span></a><span>LEWG [[nodiscard]] policy</span></h1><p><strong><span>Document number</span></strong><span>: P3162R0</span><br>
<strong><span>Date</span></strong><span>: 2024-02-22</span><br>
<strong><span>Authors</span></strong><span>: Darius Neațu &lt;</span><a href="mailto:dariusn@adobe.com" target="_blank" rel="noopener"><span>dariusn@adobe.com</span></a><span>&gt;, David Sankel &lt;</span><a href="mailto:dsankel@adobe.com" target="_blank" rel="noopener"><span>dsankel@adobe.com</span></a><span>&gt;</span><br>
<strong><span>Audience</span></strong><span>: Library Evolution</span></p><h2 id="Abstract" data-id="Abstract"><a class="anchor hidden-xs" href="#Abstract" title="Abstract"><span class="octicon octicon-link"></span></a><span>Abstract</span></h2><p data-original-title="" title=""><span>The committee spends substantial time deciding whether or not </span><em><span>[[nodiscard]]</span></em><span> is appropriate for newly introduced standard functions, and the decisions made are often incoherent. We propose a policy that results in minimal syntactic overhead while retaining the detection of the most egregious defects.</span></p><table>
    <tbody><tr><th>Examples illustrating proposed policy</th></tr>
<tr><td>
<pre><code class="cpp hljs"><span class="token comment">// 'empty' is frequently confused with 'clear' by those new to C++.</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">bool</span> <span class="token class-name">map</span><span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token double-colon punctuation">::</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">const</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>

<span class="token comment">// Discarding the return value of 'new' is always a memory leak.</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">void</span><span class="token operator">*</span> <span class="token keyword">operator</span> <span class="token keyword">new</span><span class="token punctuation">(</span>size_t<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// Discarding the return value of 'operator==' is not a frequent bug</span>
<span class="token comment">// nor sufficiently catastrophic to justify [[nodiscard]].</span>
<span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">class</span> <span class="token class-name">T</span><span class="token punctuation">,</span> size_t N<span class="token operator">&gt;</span>
<span class="token keyword">constexpr</span> <span class="token keyword">bool</span> <span class="token keyword">operator</span><span class="token operator">==</span><span class="token punctuation">(</span><span class="token keyword">const</span> array<span class="token operator">&lt;</span>T<span class="token punctuation">,</span> N<span class="token operator">&gt;</span><span class="token operator">&amp;</span> x<span class="token punctuation">,</span> <span class="token keyword">const</span> array<span class="token operator">&lt;</span>T<span class="token punctuation">,</span> N<span class="token operator">&gt;</span><span class="token operator">&amp;</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// Discarding an 'expected' return value hides errors and marking the class</span>
<span class="token comment">// [[nodiscard]] requires little syntactic overhead.</span>
<span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">class</span> <span class="token class-name">T</span><span class="token punctuation">,</span> <span class="token keyword">class</span> <span class="token class-name">E</span><span class="token operator">&gt;</span>
<span class="token keyword">class</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> expected <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre>
</td></tr>
</tbody></table><h2 id="Introduction" data-id="Introduction"><a class="anchor hidden-xs" href="#Introduction" title="Introduction"><span class="octicon octicon-link"></span></a><span>Introduction</span></h2><p><em><span>[[nodiscard]]</span></em><span> was introduced in Andrew Tomazos's </span><a href="https://wg21.link/P0068R0" target="_blank" rel="noopener"><em><span>Proposal of [[unused]], [[nodiscard]] and [[fallthrough]] attributes (P0068R0)</span></em></a><span> as a way to generate compiler warnings when </span><em><span>[[nodiscard]]</span></em><span>-marked functions (or functions with </span><em><span>[[nodiscard]]</span></em><span>-marked return types) are called without handling their return values. The feature was standardized in C++17 with </span><a href="https://wg21.link/P0189R1" target="_blank" rel="noopener"><em><span>Wording for [[nodiscard]] attribute (P0189R1)</span></em></a><span>.</span></p><p><span>As a rule, the standard encourages but does not mandate compiler warnings. </span><em><span>[[nodiscard]]</span></em><span> is no exception. This fact, combined with the as-if rule</span><sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup><span>, implies standard library implementers are not bound at all by where the C++ standard uses </span><em><span>[[nodiscard]]</span></em><span> annotations. Despite this implementor freedom, annotations were added to the standard library in C++17 with Nicolai Josuttis's </span><a href="https://wg21.link/P0600R1" target="_blank" rel="noopener"><em><span>[[nodiscard]] in the Library (P0600R1)</span></em></a><span>. Josuttis proposed </span><em><span>[[nodiscard]]</span></em><span> placement as follows:</span></p><ul>
<li><span>For existing APIs:</span>
<ul>
<li><span>not using the return value always is a “huge mistake” (e.g., always resulting in resource leak)</span></li>
<li><span>not using the return value is a source of trouble and easily can happen (not obvious that something is wrong)</span></li>
</ul>
</li>
<li><span>For new APIs (not been in the C++ standard yet):</span>
<ul>
<li><span>not using the return value is usually an error.</span></li>
</ul>
</li>
</ul><p><span>Following P0600R1's incorporation, the committee has not consistently followed Josuttis's recommendation for new APIs. Without an official policy, each new function's </span><em><span>[[nodiscard]]</span></em><span> annotation was subject to a separate debate, resulting in the present standard's </span><em><span>[[nodiscard]]</span></em><span> incoherence</span><sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup><span> and time-consuming LEWG discussions</span><sup class="footnote-ref"><a href="#fn3" id="fnref3">[3]</a></sup><span>.</span></p><p><span>To resolve inconsistencies and reduce committee debate time, we advocate for the following LEWG policy:</span></p><blockquote>
<ol>
<li><span>Place </span><em><span>[[nodiscard]]</span></em><span> on functions where ignoring a return value is inevitably a severe defect, such as resource leakage.</span></li>
<li><span>Place </span><em><span>[[nodiscard]]</span></em><span> on functions where overlooking the return value is a common mistake, such as function names frequently confused with others.</span></li>
<li><span>Place </span><em><span>[[nodiscard]]</span></em><span> on types designed to communicate errors as function return values.</span></li>
</ol>
</blockquote><p><span>This paper discusses the principles driving this policy, surveys existing practices, considers alternatives, and proposes wording for SD-9.</span></p><h2 id="Principles" data-id="Principles"><a class="anchor hidden-xs" href="#Principles" title="Principles"><span class="octicon octicon-link"></span></a><span>Principles</span></h2><p><span>No </span><em><span>[[nodiscard]]</span></em><span> policy can address all concerns, so we propose guiding principles to aid decision-making: minimize complexity, focus on the 90% use case, and center on outcomes.</span></p><h3 id="Minimize-complexity" data-id="Minimize-complexity"><a class="anchor hidden-xs" href="#Minimize-complexity" title="Minimize-complexity"><span class="octicon octicon-link"></span></a><span>Minimize complexity</span></h3><p><span>Minimizing C++'s complexity makes it more approachable for new users and reduces the maintenance burden of written code, thus improving its longevity. This principle rules out placing </span><em><span>[[nodiscard]]</span></em><span> on almost all functions with non-void return types, even if ignoring these return values is likely a bug.</span></p><h3 id="Focus-on-the-90-use-case" data-id="Focus-on-the-90-use-case"><a class="anchor hidden-xs" href="#Focus-on-the-90-use-case" title="Focus-on-the-90-use-case"><span class="octicon octicon-link"></span></a><span>Focus on the 90% use case</span></h3><p><span>Focusing on the 90% use case recognizes that concentrating on most people's problems rather than all people's problems will generally produce better outcomes, especially when simplicity is at stake. In this case, a handful of </span><em><span>[[nodiscard]]</span></em><span>'s placements is sufficient to generate warnings for the most common and severe bugs.</span></p><p><span>Consider these examples:</span></p><pre><code class="cpp hljs">std<span class="token double-colon punctuation">::</span>vector<span class="token operator">&lt;</span><span class="token keyword">int</span><span class="token operator">&gt;</span> v<span class="token punctuation">{</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
v<span class="token punctuation">.</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>                  <span class="token comment">// Using 'clear' instead of 'empty' is a</span>
                            <span class="token comment">// common bug, especially for those coming from</span>
                            <span class="token comment">// another language.</span>

std<span class="token double-colon punctuation">::</span>unique_ptr<span class="token operator">&lt;</span>X<span class="token operator">&gt;</span> x<span class="token punctuation">{</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
x<span class="token punctuation">.</span><span class="token function">release</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>                <span class="token comment">// Releasing the 'unique_ptr' in this example</span>
                            <span class="token comment">// results in a memory leak.</span>

std<span class="token double-colon punctuation">::</span><span class="token function">async</span><span class="token punctuation">(</span>job_x<span class="token punctuation">,</span> <span class="token operator">&amp;</span>x<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// Accidentally ignoring the return value of</span>
std<span class="token double-colon punctuation">::</span><span class="token function">async</span><span class="token punctuation">(</span>job_y<span class="token punctuation">,</span> <span class="token operator">&amp;</span>y<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// async gives the false impression that jobs</span>
                            <span class="token comment">// are run in parallel.</span>

<span class="token function">calloc</span><span class="token punctuation">(</span>size <span class="token operator">*</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// Ignoring the return value of calloc is</span>
                            <span class="token comment">// a memory leak.</span>
</code></pre><h3 id="Center-on-outcomes" data-id="Center-on-outcomes"><a class="anchor hidden-xs" href="#Center-on-outcomes" title="Center-on-outcomes"><span class="octicon octicon-link"></span></a><span>Center on outcomes</span></h3><p><span>Centering on outcomes is about considering the practical impact of a decision. What impact will a </span><em><span>[[nodiscard]]</span></em><span> policy have? We've identified two:</span></p><ol>
<li><strong><span>Standard library implementations</span></strong><span>. Implementors are not obligated to follow </span><em><span>[[nodiscard]]</span></em><span> guidance. libstdc++ and Visual C++ make their own decisions</span><sup class="footnote-ref"><a href="#fn4" id="fnref4">[4]</a></sup><span>, but libc++ mimics the standard's placement</span><sup class="footnote-ref"><a href="#fn5" id="fnref5">[5]</a></sup><span>. The impact here is minimal.</span></li>
<li><strong><span>Training content</span></strong><span>. Training, books, and websites, including the incredibly popular </span><a href="https://cppreference.com/" target="_blank" rel="noopener"><span>cppreference.com</span></a><span>, frequently reproduce function signatures in the standard library. These signatures, as a result, heavily influence coding style.</span></li>
</ol><p><span>Whether or not the standard is </span><em><span>intended</span></em><span> to impact coding style, </span><em><span>it does</span></em><span> and the committee should pay attention to this impact. Do we want the standard to encourage, by example, a conservative placement of </span><em><span>[[nodiscard]]</span></em><span> annotations, placement of </span><em><span>[[nodiscard]]</span></em><span> almost everywhere, or to avoid using the feature entirely? It is our position that users are best served by the former.</span></p><h2 id="Survey-of-existing-practice" data-id="Survey-of-existing-practice"><a class="anchor hidden-xs" href="#Survey-of-existing-practice" title="Survey-of-existing-practice"><span class="octicon octicon-link"></span></a><span>Survey of existing practice</span></h2><p><span>This section surveys existing </span><em><span>[[nodiscard]]</span></em><span> placement in the standard library, tooling, and the C++ Core guidelines. In short, the standard lacks consistency, tooling tends towards warning on all unused returns, and the C++ Core Guidelines have little to say on the subject. It is no wonder that users are frequently perplexed about what to do with the feature</span><sup class="footnote-ref"><a href="#fn6" id="fnref6">[6]</a></sup><span>.</span></p><h3 id="The-standard-library" data-id="The-standard-library"><a class="anchor hidden-xs" href="#The-standard-library" title="The-standard-library"><span class="octicon octicon-link"></span></a><span>The standard library</span></h3><p><span>The code snippets below show various signatures that either get or do not get the </span><em><span>[[nodiscard]]</span></em><span> attribute in the </span><a href="https://wg21.link/N4971" target="_blank" rel="noopener"><span>December 2023 C++ Working Draft (N4971)</span></a></p><ul>
<li><code>.empty()</code><span> (~30 occurrences)</span></li>
</ul><pre><code class="cpp hljs"><span class="token comment">// containers deque, list, map, ... , unordered_map, unordered_set</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">bool</span> <span class="token class-name">map</span><span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token double-colon punctuation">::</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">const</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
<span class="token comment">// utilities: basic_stacktrace, path, ...</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">bool</span> <span class="token class-name">path</span><span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token double-colon punctuation">::</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">const</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
<span class="token comment">// string types: basic_string_view, basic_string</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">constexpr</span> <span class="token keyword">bool</span> <span class="token class-name">basic_string_view</span><span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token double-colon punctuation">::</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">const</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
</code></pre><p><span>This addresses </span><em><span>.empty()</span></em><span>'s confusion with </span><em><span>.clear()</span></em><span>. All </span><em><span>.empty()</span></em><span> instances were marked as </span><em><span>[[nodiscard]]</span></em><span>.</span></p><ul>
<li><span>Allocation functions (~20 occurrences)</span></li>
</ul><pre><code class="cpp hljs"><span class="token comment">// C++ allocation functions: marked as [[nodiscard]]</span>
<span class="token comment">// * operator new overloads:</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">void</span><span class="token operator">*</span> <span class="token keyword">operator</span> <span class="token keyword">new</span><span class="token punctuation">(</span>size_t<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">void</span><span class="token operator">*</span> <span class="token keyword">operator</span> <span class="token keyword">new</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">(</span>size_t<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// * allocate() overloads</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">constexpr</span> T<span class="token operator">*</span> allocator<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token function">allocate</span><span class="token punctuation">(</span>size_t n<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">void</span><span class="token operator">*</span> pmr<span class="token double-colon punctuation">::</span><span class="token function">allocate</span><span class="token punctuation">(</span>size_t bytes<span class="token punctuation">,</span> size_t alignment <span class="token operator">=</span> max_align<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><p><span>Discarding a value returned by an allocation function is undoubtedly a memory leak.</span></p><ul>
<li><code>async</code><span>(2 occurrences)</span></li>
</ul><pre><code class="cpp hljs"><span class="token comment">// async overloads</span>
<span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">class</span> <span class="token class-name">F</span><span class="token punctuation">,</span> <span class="token keyword">class</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> Args<span class="token operator">&gt;</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> future<span class="token operator">&lt;</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token operator">&gt;</span> <span class="token function">async</span><span class="token punctuation">(</span>F<span class="token operator">&amp;&amp;</span> f<span class="token punctuation">,</span> Args<span class="token operator">&amp;&amp;</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> args<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><p><span>Not capturing the return value for </span><code>async</code><span> results in surprising synchronous execution.</span></p><ul>
<li><span>Standard error types (0 occurrences) -</span></li>
</ul><pre><code class="cpp hljs"><span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">class</span> <span class="token class-name">T</span><span class="token punctuation">,</span> <span class="token keyword">class</span> <span class="token class-name">E</span><span class="token operator">&gt;</span>
<span class="token keyword">class</span> <span class="token class-name">expected</span> <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">class</span> <span class="token class-name">E</span><span class="token operator">&gt;</span>
<span class="token keyword">class</span> <span class="token class-name">unexpected</span> <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token keyword">class</span> <span class="token class-name">error_code</span> <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">class</span> <span class="token class-name">error_condition</span> <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">enum</span> <span class="token keyword">class</span> <span class="token class-name">errc</span> <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre><p><span>None of the standard error types have a </span><em><span>[[nodiscard]]</span></em><span> attribute.</span></p><ul>
<li><span>Inconsistencies</span></li>
</ul><pre><code class="cpp hljs"><span class="token comment">// allocation functions</span>
<span class="token comment">// * default: do have [[nodiscard]]</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">void</span><span class="token operator">*</span> <span class="token keyword">operator</span> <span class="token keyword">new</span><span class="token punctuation">(</span>size_t<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// * exceptions: C allocation functions</span>
<span class="token keyword">void</span><span class="token operator">*</span> <span class="token function">malloc</span><span class="token punctuation">(</span>size_t size<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">void</span><span class="token operator">*</span> <span class="token function">calloc</span><span class="token punctuation">(</span>size_t nmemb<span class="token punctuation">,</span> size_t size<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">void</span><span class="token operator">*</span> <span class="token function">realloc</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token operator">*</span> ptr<span class="token punctuation">,</span> size_t size<span class="token punctuation">)</span><span class="token punctuation">;</span>    

<span class="token comment">// operator==</span>
<span class="token comment">// * default: does not have [[nodiscard]]</span>
<span class="token keyword">constexpr</span> <span class="token keyword">bool</span> <span class="token keyword">operator</span><span class="token operator">==</span><span class="token punctuation">(</span><span class="token keyword">const</span> vector<span class="token operator">&lt;</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token operator">&gt;</span><span class="token operator">&amp;</span> x<span class="token punctuation">,</span> <span class="token keyword">const</span> vector<span class="token operator">&lt;</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token operator">&gt;</span><span class="token operator">&amp;</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">constexpr</span> <span class="token keyword">bool</span> <span class="token keyword">operator</span><span class="token operator">==</span><span class="token punctuation">(</span><span class="token keyword">const</span> basic_string<span class="token operator">&lt;</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token operator">&gt;</span><span class="token operator">&amp;</span> lhs<span class="token punctuation">,</span> <span class="token keyword">const</span> basic_string<span class="token operator">&lt;</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token operator">&gt;</span><span class="token operator">&amp;</span> rhs<span class="token punctuation">)</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
<span class="token comment">// * exceptions: few new APIs</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">friend</span> <span class="token keyword">bool</span> <span class="token keyword">operator</span><span class="token operator">==</span><span class="token punctuation">(</span><span class="token keyword">const</span> stop_token<span class="token operator">&amp;</span> lhs<span class="token punctuation">,</span> <span class="token keyword">const</span> stop_token<span class="token operator">&amp;</span> rhs<span class="token punctuation">)</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token keyword">friend</span> <span class="token keyword">bool</span> <span class="token keyword">operator</span><span class="token operator">==</span><span class="token punctuation">(</span><span class="token keyword">const</span> stop_source<span class="token operator">&amp;</span> lhs<span class="token punctuation">,</span> <span class="token keyword">const</span> stop_source<span class="token operator">&amp;</span> rhs<span class="token punctuation">)</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>

<span class="token comment">// get_id() for threads</span>
<span class="token comment">// * (old) free function API</span>
id this_thread<span class="token double-colon punctuation">::</span><span class="token function">get_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
<span class="token comment">// * (new) member function API</span>
<span class="token punctuation">[</span><span class="token punctuation">[</span>nodiscard<span class="token punctuation">]</span><span class="token punctuation">]</span> id jthread<span class="token double-colon punctuation">::</span><span class="token function">get_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">const</span> <span class="token keyword">noexcept</span><span class="token punctuation">;</span>
</code></pre><h3 id="Tooling-Clang-Tidy" data-id="Tooling-Clang-Tidy"><a class="anchor hidden-xs" href="#Tooling-Clang-Tidy" title="Tooling-Clang-Tidy"><span class="octicon octicon-link"></span></a><span>Tooling: Clang Tidy</span></h3><p><span>Clang Tidy provides the </span><a href="https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-nodiscard.html" target="_blank" rel="noopener"><span>modernize-use-nodiscard</span></a><span> flag, which suggests and automatically applies </span><em><span>[[nodiscard]]</span></em><span> to a codebase in specific scenarios, such as non-void non-template return const member function.</span></p><pre><code class="cpp hljs"><span class="token keyword">bool</span> class_name<span class="token double-colon punctuation">::</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">const</span><span class="token punctuation">;</span>      <span class="token comment">// warning: should be marked [[nodiscard]]</span>
<span class="token keyword">bool</span> class_name<span class="token double-colon punctuation">::</span><span class="token function">check</span><span class="token punctuation">(</span><span class="token keyword">int</span> i<span class="token punctuation">)</span> <span class="token keyword">const</span><span class="token punctuation">;</span> <span class="token comment">// warning: should be marked [[nodiscard]]</span>
</code></pre><p><span>Moreover, the experimental flag </span><a href="https://clang.llvm.org/extra/clang-tidy/checks/bugprone/unused-return-value.html" target="_blank" rel="noopener"><span>bugprone-unused-return-value</span></a><span> generates warnings when a user ignores the return value of specific Standard Library functions. An example is </span><em><span>std::unique_ptr::release()</span></em><span>, which may be confused with </span><em><span>std::unique_ptr::reset()</span></em><span>.</span></p><p><span>Similarly to our proposed policy, this tool warns when standard error type return values are not handled:</span></p><pre><code class="cpp hljs"><span class="token comment">// warning: the value returned by this function should be used</span>
std<span class="token double-colon punctuation">::</span>expected<span class="token operator">&lt;</span><span class="token keyword">int</span><span class="token punctuation">,</span> <span class="token keyword">int</span><span class="token operator">&gt;</span> <span class="token function">foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token punctuation">{</span><span class="token number">1</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>

<span class="token keyword">void</span> <span class="token function">bar</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token function">foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
</code></pre><h3 id="The-C-Core-Guidelines" data-id="The-C-Core-Guidelines"><a class="anchor hidden-xs" href="#The-C-Core-Guidelines" title="The-C-Core-Guidelines"><span class="octicon octicon-link"></span></a><span>The C++ Core Guidelines</span></h3><p><span>A recent GitHub issue in the </span><a href="https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines" target="_blank" rel="noopener"><span>C++ Core Guidelines</span></a><span> repository, </span><a href="https://github.com/isocpp/CppCoreGuidelines/issues/2109" target="_blank" rel="noopener"><span>[[nodiscard]] advice is largely absent</span></a><span>, points out that the C++ Core Guidelines does not mention </span><em><span>[[nodiscard]]</span></em><span> aside from not ignoring results of functions with this attribute. Considering section SL.2 ("</span><a href="https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rsl-sl" target="_blank" rel="noopener"><span>SL.2: Prefer the standard library to other libraries</span></a><span>"), the missing guideline from C++ Core Guidelines should be consistent with a LEWG policy.</span></p><p><span>The dicussion led to multiple possible guidelines that are still under debate:</span></p><blockquote>
<p><span>A: Add [[nodiscard]] when it disambiguates what a function does or discarding the result is a safety issue.</span><br>
<span>B: Add [[nodiscard]] when it is likely to avoid the misuse of a function.</span><br>
<span>C: Add [[nodiscard]] when a function is impossible to use when the caller discards the result.</span><br>
<span>D: Add [[nodiscard]] when discarding the result of a function with side effects is not intended.</span></p>
</blockquote><p><span>The guideline </span><em><span>A</span></em><span> uses the attribute only for critical situations (e.g., </span><em><span>.empty()</span></em><span>). In the opposite direction, the </span><em><span>B</span></em><span> version suggests to put </span><em><span>[[nodiscard]]</span></em><span> almost everywhere (e.g., even on </span><em><span>operator==</span></em><span>). The </span><em><span>C</span></em><span> wording limits the usage to specific cases where code may break (e.g., </span><em><span>std::launder</span></em><span>, </span><em><span>std::async</span></em><span>), while </span><em><span>D</span></em><span> aims to use </span><em><span>[[nodiscard]]</span></em><span> only on functions with side-effects, such </span><em><span>read()</span></em><span>.</span></p><h2 id="Alternatives-considered" data-id="Alternatives-considered"><a class="anchor hidden-xs" href="#Alternatives-considered" title="Alternatives-considered"><span class="octicon octicon-link"></span></a><span>Alternatives considered</span></h2><ol>
<li>
<p><strong><span>Place </span><em><span>[[nodiscard]]</span></em><span> on every function where discarding the result is likely a bug</span></strong><span>. Because this would result in </span><em><span>[[nodiscard]]</span></em><span> placement on almost every non-</span><em><span>void</span></em><span> returning function, it goes against the principle of minimizing complexity.</span></p>
</li>
<li>
<p><strong><span>Do not use </span><em><span>[[nodiscard]]</span></em><span> in the standard library</span></strong><span>. This alternative goes against the principle of centering on outcomes. If people do not see </span><em><span>[[nodiscard]]</span></em><span> used in the standard library or relevant documentation (such as cppreference), then the positive impact the feature can have is diminished.</span></p>
</li>
</ol><h2 id="Wording-for-SD-9" data-id="Wording-for-SD-9"><a class="anchor hidden-xs" href="#Wording-for-SD-9" title="Wording-for-SD-9"><span class="octicon octicon-link"></span></a><span>Wording for SD-9</span></h2><p><span>Append to </span><a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2267r1.html#list-of-standard-library-policies" target="_blank" rel="noopener"><span>List of Standard Library Policies</span></a><span> section of SD-9 (</span><a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2267r1.html" target="_blank" rel="noopener"><span>P2267R1: Library Evolution Policies</span></a><span>):</span></p><blockquote>
<p><span>X. </span><strong><span>[[nodiscard]]</span></strong><span> policy:</span><br>
<span>X.1. (P3162R0) Place </span><em><span>[[nodiscard]]</span></em><span> on functions where ignoring a return value is inevitably a severe defect, such as resource leakage.</span><br>
<span>X.2. (P3162R0) Place </span><em><span>[[nodiscard]]</span></em><span> on functions where overlooking the return value is a common mistake, such as function names frequently confused with others.</span><br>
<span>X.3. (P3162R0) Place </span><em><span>[[nodiscard]]</span></em><span> on types designed to communicate errors as function return values.</span></p>
</blockquote><h2 id="Conclusion" data-id="Conclusion"><a class="anchor hidden-xs" href="#Conclusion" title="Conclusion"><span class="octicon octicon-link"></span></a><span>Conclusion</span></h2><p><span>This paper demonstrated the need for a policy regulating </span><em><span>[[nodiscard]]</span></em><span> use in the standard library and proposed such a policy. It outlined the principles motivating this policy, analyzed existing practices, and considered alternatives.</span></p><h2 id="References" data-id="References"><a class="anchor hidden-xs" href="#References" title="References"><span class="octicon octicon-link"></span></a><span>References</span></h2><ul>
<li><span>Christopher Di Bella. P2377R0: [[nodiscard]] in the Standard Library: Clause 23 Iterators library. </span><a href="https://wg21.link/P2377R0" target="_blank" rel="noopener"><span>https://wg21.link/P2377R0</span></a><span>, 05/2021</span></li>
<li><span>Hana Dusíková. P2351R0: Mark all library static cast wrappers as [[nodiscard]]. </span><a href="https://wg21.link/P2351R0" target="_blank" rel="noopener"><span>https://wg21.link/P2351R0</span></a><span>, 04/2020</span></li>
<li><span>Nicolai Josuttis. P0600R1: [[nodiscard]] in the Library, Rev1.</span><br>
<a href="https://wg21.link/p0600r1" target="_blank" rel="noopener"><span>https://wg21.link/p0600r1</span></a><span>, 11/2017.</span></li>
<li><span>Inbal Levi et al. P2267R1: Library Evolution Policies.</span></li>
<li><span>Andrew Tomazos. P0189R1: Wording for [[nodiscard]] attribute.</span><br>
<a href="https://wg21.link/p0189r1" target="_blank" rel="noopener"><span>https://wg21.link/p0189r1</span></a><span>, 2/2016.</span></li>
<li><span>Andrew Tomazos. P0068R0: Proposal of [[unused]], [[nodiscard]] and [[fallthrough]] attributes. </span><a href="https://wg21.link/p0068r0" target="_blank" rel="noopener"><span>https://wg21.link/p0068r0</span></a><span>, 9/2015.</span></li>
<li><span>Daniel Towner, Ruslan Arutyunyan. P2993R1: Extend </span><code>&lt;bit&gt;</code><span> header function with overloads for </span><code>std::simd</code><span>. </span><a href="https://wg21.link/P2933R1" target="_blank" rel="noopener"><span>https://wg21.link/P2933R1</span></a><span>, 8/2023</span><br>
<a href="https://wg21.link/P2267R1" target="_blank" rel="noopener"><span>https://wg21.link/P2267R1</span></a><span>, 11/2023</span></li>
<li><span>Ville Voutilainen. D2422R0: Remove nodiscard annotations from the standard library specification. </span><a href="https://isocpp.org/files/papers/D2422R0.html" target="_blank" rel="noopener"><span>https://isocpp.org/files/papers/D2422R0.html</span></a><span>, 08/2021.</span></li>
</ul><hr class="footnotes-sep"><section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p><span>For details on the "as-if" rule, see paragraph 1 of [intro.abstract] in the </span><a href="https://wg21.link/N4971" target="_blank" rel="noopener"><span>December 2023 C++ Working Draft (N4971)</span></a><span> and its footnote</span> <a href="#fnref1" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn2" class="footnote-item"><p><span>For a recent example, see the 2023 Kona discussion on </span><em><span>[[nodiscard]]</span></em><span> placement for </span><a href="https://wg21.link/P2993R1" target="_blank" rel="noopener"><em><span>Extend </span>&lt;bit&gt;<span> header function with overloads for std::simd (P2993R1)</span></em></a> <a href="#fnref2" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn3" class="footnote-item"><p><span>LEWG related papers: Christopher Di Bella's </span><a href="https://wg21.link/P2377R0" target="_blank" rel="noopener"><span>P2377R0: [[nodiscard]] in the Standard Library: Clause 23 Iterators library</span></a><span>, Ville Voutilainen's </span><a href="https://isocpp.org/files/papers/D2422R0.html" target="_blank" rel="noopener"><span>D2422R0: Remove nodiscard annotations from the standard library specification</span></a><span>, Hana Dusíková's </span><a href="https://wg21.link/P2351R0" target="_blank" rel="noopener"><span>P2351R0: Mark all library static cast wrappers as nodiscard</span></a><span>.</span> <a href="#fnref3" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn4" class="footnote-item"><p><span>Note </span><a href="https://github.com/gcc-mirror/gcc/blob/3232ebd91ed55b275b9d5a6e8355336382c4afd5/libstdc%2B%2B-v3/include/bits/stl_vector.h#L1073" target="_blank" rel="noopener"><span>libstdc++'s placement</span></a><span> of </span><em><span>[[nodiscard]]</span></em><span> on both </span><em><span>vector::capacity</span></em><span> and </span><em><span>vector::empty</span></em><span> where the standard has placement only on the latter. The same is true for </span><a href="https://github.com/microsoft/STL/blob/c53ac59abae552e50654943f7f80f23376a8039a/stl/inc/vector#L1866" target="_blank" rel="noopener"><span>Visual C++</span></a> <a href="#fnref4" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn5" class="footnote-item"><p><span>See </span><em><span>vector::empty()</span></em><span> and </span><em><span>vector::capacity()</span></em><span> </span><a href="https://github.com/llvm/llvm-project/blob/2167881f5154823dc3183845700add7df15fc856/libcxx/include/vector#L601" target="_blank" rel="noopener"><span>inside libc++</span></a><span>.</span> <a href="#fnref5" class="footnote-backref">↩︎</a></p>
</li>
<li id="fn6" class="footnote-item"><p><span>See this </span><a href="https://softwareengineering.stackexchange.com/questions/363169/whats-the-reason-for-not-using-c17s-nodiscard-almost-everywhere-in-new-c" target="_blank" rel="noopener"><span>stackoverflow discussion</span></a><span> for an example</span> <a href="#fnref6" class="footnote-backref">↩︎</a></p>
</li>
</ol>
</section></div>
    <div class="ui-toc dropup unselectable hidden-print" style="display:none;">
        <div class="pull-right dropdown">
            <a id="tocLabel" class="ui-toc-label btn btn-default" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" title="Table of content">
                <i class="fa fa-bars"></i>
            </a>
            <ul id="ui-toc" class="ui-toc-dropdown dropdown-menu" aria-labelledby="tocLabel">
                <div class="toc"><ul class="nav">
<li><a href="#LEWG-nodiscard-policy" title="LEWG [[nodiscard]] policy">LEWG [[nodiscard]] policy</a><ul class="nav">
<li><a href="#Abstract" title="Abstract">Abstract</a></li>
<li><a href="#Introduction" title="Introduction">Introduction</a></li>
<li><a href="#Principles" title="Principles">Principles</a><ul class="nav">
<li><a href="#Minimize-complexity" title="Minimize complexity">Minimize complexity</a></li>
<li><a href="#Focus-on-the-90-use-case" title="Focus on the 90% use case">Focus on the 90% use case</a></li>
<li><a href="#Center-on-outcomes" title="Center on outcomes">Center on outcomes</a></li>
</ul>
</li>
<li><a href="#Survey-of-existing-practice" title="Survey of existing practice">Survey of existing practice</a><ul class="nav">
<li><a href="#The-standard-library" title="The standard library">The standard library</a></li>
<li><a href="#Tooling-Clang-Tidy" title="Tooling: Clang Tidy">Tooling: Clang Tidy</a></li>
<li><a href="#The-C-Core-Guidelines" title="The C++ Core Guidelines">The C++ Core Guidelines</a></li>
</ul>
</li>
<li><a href="#Alternatives-considered" title="Alternatives considered">Alternatives considered</a></li>
<li><a href="#Wording-for-SD-9" title="Wording for SD-9">Wording for SD-9</a></li>
<li><a href="#Conclusion" title="Conclusion">Conclusion</a></li>
<li><a href="#References" title="References">References</a></li>
</ul>
</li>
</ul>
</div><div class="toc-menu"><a class="expand-toggle" href="#">Expand all</a><a class="back-to-top" href="#">Back to top</a><a class="go-to-bottom" href="#">Go to bottom</a></div>
            </ul>
        </div>
    </div>
    <div id="ui-toc-affix" class="ui-affix-toc ui-toc-dropdown unselectable hidden-print" data-spy="affix" style="top:17px;display:none;" null null>
        <div class="toc"><ul class="nav">
<li><a href="#LEWG-nodiscard-policy" title="LEWG [[nodiscard]] policy">LEWG [[nodiscard]] policy</a><ul class="nav">
<li><a href="#Abstract" title="Abstract">Abstract</a></li>
<li><a href="#Introduction" title="Introduction">Introduction</a></li>
<li><a href="#Principles" title="Principles">Principles</a><ul class="nav">
<li><a href="#Minimize-complexity" title="Minimize complexity">Minimize complexity</a></li>
<li><a href="#Focus-on-the-90-use-case" title="Focus on the 90% use case">Focus on the 90% use case</a></li>
<li><a href="#Center-on-outcomes" title="Center on outcomes">Center on outcomes</a></li>
</ul>
</li>
<li><a href="#Survey-of-existing-practice" title="Survey of existing practice">Survey of existing practice</a><ul class="nav">
<li><a href="#The-standard-library" title="The standard library">The standard library</a></li>
<li><a href="#Tooling-Clang-Tidy" title="Tooling: Clang Tidy">Tooling: Clang Tidy</a></li>
<li><a href="#The-C-Core-Guidelines" title="The C++ Core Guidelines">The C++ Core Guidelines</a></li>
</ul>
</li>
<li><a href="#Alternatives-considered" title="Alternatives considered">Alternatives considered</a></li>
<li><a href="#Wording-for-SD-9" title="Wording for SD-9">Wording for SD-9</a></li>
<li><a href="#Conclusion" title="Conclusion">Conclusion</a></li>
<li><a href="#References" title="References">References</a></li>
</ul>
</li>
</ul>
</div><div class="toc-menu"><a class="expand-toggle" href="#">Expand all</a><a class="back-to-top" href="#">Back to top</a><a class="go-to-bottom" href="#">Go to bottom</a></div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous" defer></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.6.0/gist-embed.min.js" integrity="sha256-KyF2D6xPIJUW5sUDSs93vWyZm+1RzIpKCexxElmxl8g=" crossorigin="anonymous" defer></script>
    <script>
        var markdown = $(".markdown-body");
        //smooth all hash trigger scrolling
        function smoothHashScroll() {
            var hashElements = $("a[href^='#']").toArray();
            for (var i = 0; i < hashElements.length; i++) {
                var element = hashElements[i];
                var $element = $(element);
                var hash = element.hash;
                if (hash) {
                    $element.on('click', function (e) {
                        // store hash
                        var hash = this.hash;
                        if ($(hash).length <= 0) return;
                        // prevent default anchor click behavior
                        e.preventDefault();
                        // animate
                        $('body, html').stop(true, true).animate({
                            scrollTop: $(hash).offset().top
                        }, 100, "linear", function () {
                            // when done, add hash to url
                            // (default click behaviour)
                            window.location.hash = hash;
                        });
                    });
                }
            }
        }

        smoothHashScroll();
        var toc = $('.ui-toc');
        var tocAffix = $('.ui-affix-toc');
        var tocDropdown = $('.ui-toc-dropdown');
        //toc
        tocDropdown.click(function (e) {
            e.stopPropagation();
        });

        var enoughForAffixToc = true;

        function generateScrollspy() {
            $(document.body).scrollspy({
                target: ''
            });
            $(document.body).scrollspy('refresh');
            if (enoughForAffixToc) {
                toc.hide();
                tocAffix.show();
            } else {
                tocAffix.hide();
                toc.show();
            }
            $(document.body).scroll();
        }

        function windowResize() {
            //toc right
            var paddingRight = parseFloat(markdown.css('padding-right'));
            var right = ($(window).width() - (markdown.offset().left + markdown.outerWidth() - paddingRight));
            toc.css('right', right + 'px');
            //affix toc left
            var newbool;
            var rightMargin = (markdown.parent().outerWidth() - markdown.outerWidth()) / 2;
            //for ipad or wider device
            if (rightMargin >= 133) {
                newbool = true;
                var affixLeftMargin = (tocAffix.outerWidth() - tocAffix.width()) / 2;
                var left = markdown.offset().left + markdown.outerWidth() - affixLeftMargin;
                tocAffix.css('left', left + 'px');
            } else {
                newbool = false;
            }
            if (newbool != enoughForAffixToc) {
                enoughForAffixToc = newbool;
                generateScrollspy();
            }
        }
        $(window).resize(function () {
            windowResize();
        });
        $(document).ready(function () {
            windowResize();
            generateScrollspy();
        });

        //remove hash
        function removeHash() {
            window.location.hash = '';
        }

        var backtotop = $('.back-to-top');
        var gotobottom = $('.go-to-bottom');

        backtotop.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            if (scrollToTop)
                scrollToTop();
            removeHash();
        });
        gotobottom.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            if (scrollToBottom)
                scrollToBottom();
            removeHash();
        });

        var toggle = $('.expand-toggle');
        var tocExpand = false;

        checkExpandToggle();
        toggle.click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            tocExpand = !tocExpand;
            checkExpandToggle();
        })

        function checkExpandToggle () {
            var toc = $('.ui-toc-dropdown .toc');
            var toggle = $('.expand-toggle');
            if (!tocExpand) {
                toc.removeClass('expand');
                toggle.text('Expand all');
            } else {
                toc.addClass('expand');
                toggle.text('Collapse all');
            }
        }

        function scrollToTop() {
            $('body, html').stop(true, true).animate({
                scrollTop: 0
            }, 100, "linear");
        }

        function scrollToBottom() {
            $('body, html').stop(true, true).animate({
                scrollTop: $(document.body)[0].scrollHeight
            }, 100, "linear");
        }
    </script>
</body>

</html>
