:first-child { margin-top: 0px; }
.markdown-preview:not([data-use-github-style]) h1, .markdown-preview:not([data-use-github-style]) h2, .markdown-preview:not([data-use-github-style]) h3, .markdown-preview:not([data-use-github-style]) h4, .markdown-preview:not([data-use-github-style]) h5, .markdown-preview:not([data-use-github-style]) h6 { line-height: 1.2; margin-top: 1.5em; margin-bottom: 0.5em; color: rgb(255, 255, 255); }
.markdown-preview:not([data-use-github-style]) h1 { font-size: 2.4em; font-weight: 300; }
.markdown-preview:not([data-use-github-style]) h2 { font-size: 1.8em; font-weight: 400; }
.markdown-preview:not([data-use-github-style]) h3 { font-size: 1.5em; font-weight: 500; }
.markdown-preview:not([data-use-github-style]) h4 { font-size: 1.2em; font-weight: 600; }
.markdown-preview:not([data-use-github-style]) h5 { font-size: 1.1em; font-weight: 600; }
.markdown-preview:not([data-use-github-style]) h6 { font-size: 1em; font-weight: 600; }
.markdown-preview:not([data-use-github-style]) strong { color: rgb(255, 255, 255); }
.markdown-preview:not([data-use-github-style]) del { color: rgb(124, 135, 156); }
.markdown-preview:not([data-use-github-style]) a, .markdown-preview:not([data-use-github-style]) a code { color: rgb(82, 139, 255); }
.markdown-preview:not([data-use-github-style]) img { max-width: 100%; }
.markdown-preview:not([data-use-github-style]) > p { margin-top: 0px; margin-bottom: 1.5em; }
.markdown-preview:not([data-use-github-style]) > ul, .markdown-preview:not([data-use-github-style]) > ol { margin-bottom: 1.5em; }
.markdown-preview:not([data-use-github-style]) blockquote { margin: 1.5em 0px; font-size: inherit; color: rgb(124, 135, 156); border-color: rgb(75, 83, 98); border-width: 4px; }
.markdown-preview:not([data-use-github-style]) hr { margin: 3em 0px; border-top: 2px dashed rgb(75, 83, 98); background: none; }
.markdown-preview:not([data-use-github-style]) table { margin: 1.5em 0px; }
.markdown-preview:not([data-use-github-style]) th { color: rgb(255, 255, 255); }
.markdown-preview:not([data-use-github-style]) th, .markdown-preview:not([data-use-github-style]) td { padding: 0.66em 1em; border: 1px solid rgb(75, 83, 98); }
.markdown-preview:not([data-use-github-style]) code { color: rgb(255, 255, 255); background-color: rgb(58, 63, 75); }
.markdown-preview:not([data-use-github-style]) pre.editor-colors { margin: 1.5em 0px; padding: 1em; font-size: 0.92em; border-radius: 3px; background-color: rgb(49, 54, 63); }
.markdown-preview:not([data-use-github-style]) kbd { color: rgb(255, 255, 255); border-width: 1px 1px 2px; border-style: solid; border-color: rgb(75, 83, 98) rgb(75, 83, 98) rgb(62, 68, 81); border-image: initial; background-color: rgb(58, 63, 75); }
.markdown-preview[data-use-github-style] { font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; line-height: 1.6; word-wrap: break-word; padding: 30px; font-size: 16px; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); overflow: scroll; }
.markdown-preview[data-use-github-style] > :first-child { margin-top: 0px !important; }
.markdown-preview[data-use-github-style] > :last-child { margin-bottom: 0px !important; }
.markdown-preview[data-use-github-style] a:not([href]) { color: inherit; text-decoration: none; }
.markdown-preview[data-use-github-style] .absent { color: rgb(204, 0, 0); }
.markdown-preview[data-use-github-style] .anchor { position: absolute; top: 0px; left: 0px; display: block; padding-right: 6px; padding-left: 30px; margin-left: -30px; }
.markdown-preview[data-use-github-style] .anchor:focus { outline: none; }
.markdown-preview[data-use-github-style] h1, .markdown-preview[data-use-github-style] h2, .markdown-preview[data-use-github-style] h3, .markdown-preview[data-use-github-style] h4, .markdown-preview[data-use-github-style] h5, .markdown-preview[data-use-github-style] h6 { position: relative; margin-top: 1em; margin-bottom: 16px; font-weight: bold; line-height: 1.4; }
.markdown-preview[data-use-github-style] h1 .octicon-link, .markdown-preview[data-use-github-style] h2 .octicon-link, .markdown-preview[data-use-github-style] h3 .octicon-link, .markdown-preview[data-use-github-style] h4 .octicon-link, .markdown-preview[data-use-github-style] h5 .octicon-link, .markdown-preview[data-use-github-style] h6 .octicon-link { display: none; color: rgb(0, 0, 0); vertical-align: middle; }
.markdown-preview[data-use-github-style] h1:hover .anchor, .markdown-preview[data-use-github-style] h2:hover .anchor, .markdown-preview[data-use-github-style] h3:hover .anchor, .markdown-preview[data-use-github-style] h4:hover .anchor, .markdown-preview[data-use-github-style] h5:hover .anchor, .markdown-preview[data-use-github-style] h6:hover .anchor { padding-left: 8px; margin-left: -30px; text-decoration: none; }
.markdown-preview[data-use-github-style] h1:hover .anchor .octicon-link, .markdown-preview[data-use-github-style] h2:hover .anchor .octicon-link, .markdown-preview[data-use-github-style] h3:hover .anchor .octicon-link, .markdown-preview[data-use-github-style] h4:hover .anchor .octicon-link, .markdown-preview[data-use-github-style] h5:hover .anchor .octicon-link, .markdown-preview[data-use-github-style] h6:hover .anchor .octicon-link { display: inline-block; }
.markdown-preview[data-use-github-style] h1 tt, .markdown-preview[data-use-github-style] h2 tt, .markdown-preview[data-use-github-style] h3 tt, .markdown-preview[data-use-github-style] h4 tt, .markdown-preview[data-use-github-style] h5 tt, .markdown-preview[data-use-github-style] h6 tt, .markdown-preview[data-use-github-style] h1 code, .markdown-preview[data-use-github-style] h2 code, .markdown-preview[data-use-github-style] h3 code, .markdown-preview[data-use-github-style] h4 code, .markdown-preview[data-use-github-style] h5 code, .markdown-preview[data-use-github-style] h6 code { font-size: inherit; }
.markdown-preview[data-use-github-style] h1 { padding-bottom: 0.3em; font-size: 2.25em; line-height: 1.2; border-bottom: 1px solid rgb(238, 238, 238); }
.markdown-preview[data-use-github-style] h1 .anchor { line-height: 1; }
.markdown-preview[data-use-github-style] h2 { padding-bottom: 0.3em; font-size: 1.75em; line-height: 1.225; border-bottom: 1px solid rgb(238, 238, 238); }
.markdown-preview[data-use-github-style] h2 .anchor { line-height: 1; }
.markdown-preview[data-use-github-style] h3 { font-size: 1.5em; line-height: 1.43; }
.markdown-preview[data-use-github-style] h3 .anchor { line-height: 1.2; }
.markdown-preview[data-use-github-style] h4 { font-size: 1.25em; }
.markdown-preview[data-use-github-style] h4 .anchor { line-height: 1.2; }
.markdown-preview[data-use-github-style] h5 { font-size: 1em; }
.markdown-preview[data-use-github-style] h5 .anchor { line-height: 1.1; }
.markdown-preview[data-use-github-style] h6 { font-size: 1em; color: rgb(119, 119, 119); }
.markdown-preview[data-use-github-style] h6 .anchor { line-height: 1.1; }
.markdown-preview[data-use-github-style] p, .markdown-preview[data-use-github-style] blockquote, .markdown-preview[data-use-github-style] ul, .markdown-preview[data-use-github-style] ol, .markdown-preview[data-use-github-style] dl, .markdown-preview[data-use-github-style] table, .markdown-preview[data-use-github-style] pre { margin-top: 0px; margin-bottom: 16px; }
.markdown-preview[data-use-github-style] hr { height: 4px; padding: 0px; margin: 16px 0px; background-color: rgb(231, 231, 231); border: 0px none; }
.markdown-preview[data-use-github-style] ul, .markdown-preview[data-use-github-style] ol { padding-left: 2em; }
.markdown-preview[data-use-github-style] ul.no-list, .markdown-preview[data-use-github-style] ol.no-list { padding: 0px; list-style-type: none; }
.markdown-preview[data-use-github-style] ul ul, .markdown-preview[data-use-github-style] ul ol, .markdown-preview[data-use-github-style] ol ol, .markdown-preview[data-use-github-style] ol ul { margin-top: 0px; margin-bottom: 0px; }
.markdown-preview[data-use-github-style] li > p { margin-top: 16px; }
.markdown-preview[data-use-github-style] dl { padding: 0px; }
.markdown-preview[data-use-github-style] dl dt { padding: 0px; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: bold; }
.markdown-preview[data-use-github-style] dl dd { padding: 0px 16px; margin-bottom: 16px; }
.markdown-preview[data-use-github-style] blockquote { padding: 0px 15px; color: rgb(119, 119, 119); border-left: 4px solid rgb(221, 221, 221); }
.markdown-preview[data-use-github-style] blockquote > :first-child { margin-top: 0px; }
.markdown-preview[data-use-github-style] blockquote > :last-child { margin-bottom: 0px; }
.markdown-preview[data-use-github-style] table { display: block; width: 100%; overflow: auto; word-break: keep-all; }
.markdown-preview[data-use-github-style] table th { font-weight: bold; }
.markdown-preview[data-use-github-style] table th, .markdown-preview[data-use-github-style] table td { padding: 6px 13px; border: 1px solid rgb(221, 221, 221); }
.markdown-preview[data-use-github-style] table tr { background-color: rgb(255, 255, 255); border-top: 1px solid rgb(204, 204, 204); }
.markdown-preview[data-use-github-style] table tr:nth-child(2n) { background-color: rgb(248, 248, 248); }
.markdown-preview[data-use-github-style] img { max-width: 100%; box-sizing: border-box; }
.markdown-preview[data-use-github-style] .emoji { max-width: none; }
.markdown-preview[data-use-github-style] span.frame { display: block; overflow: hidden; }
.markdown-preview[data-use-github-style] span.frame > span { display: block; float: left; width: auto; padding: 7px; margin: 13px 0px 0px; overflow: hidden; border: 1px solid rgb(221, 221, 221); }
.markdown-preview[data-use-github-style] span.frame span img { display: block; float: left; }
.markdown-preview[data-use-github-style] span.frame span span { display: block; padding: 5px 0px 0px; clear: both; color: rgb(51, 51, 51); }
.markdown-preview[data-use-github-style] span.align-center { display: block; overflow: hidden; clear: both; }
.markdown-preview[data-use-github-style] span.align-center > span { display: block; margin: 13px auto 0px; overflow: hidden; text-align: center; }
.markdown-preview[data-use-github-style] span.align-center span img { margin: 0px auto; text-align: center; }
.markdown-preview[data-use-github-style] span.align-right { display: block; overflow: hidden; clear: both; }
.markdown-preview[data-use-github-style] span.align-right > span { display: block; margin: 13px 0px 0px; overflow: hidden; text-align: right; }
.markdown-preview[data-use-github-style] span.align-right span img { margin: 0px; text-align: right; }
.markdown-preview[data-use-github-style] span.float-left { display: block; float: left; margin-right: 13px; overflow: hidden; }
.markdown-preview[data-use-github-style] span.float-left span { margin: 13px 0px 0px; }
.markdown-preview[data-use-github-style] span.float-right { display: block; float: right; margin-left: 13px; overflow: hidden; }
.markdown-preview[data-use-github-style] span.float-right > span { display: block; margin: 13px auto 0px; overflow: hidden; text-align: right; }
.markdown-preview[data-use-github-style] code, .markdown-preview[data-use-github-style] tt { padding: 0.2em 0px; margin: 0px; font-size: 85%; background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; }
.markdown-preview[data-use-github-style] code::before, .markdown-preview[data-use-github-style] tt::before, .markdown-preview[data-use-github-style] code::after, .markdown-preview[data-use-github-style] tt::after { letter-spacing: -0.2em; content: " "; }
.markdown-preview[data-use-github-style] code br, .markdown-preview[data-use-github-style] tt br { display: none; }
.markdown-preview[data-use-github-style] del code { text-decoration: inherit; }
.markdown-preview[data-use-github-style] pre > code { padding: 0px; margin: 0px; font-size: 100%; word-break: normal; white-space: pre; background: transparent; border: 0px; }
.markdown-preview[data-use-github-style] .highlight { margin-bottom: 16px; }
.markdown-preview[data-use-github-style] .highlight pre, .markdown-preview[data-use-github-style] pre { padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: rgb(247, 247, 247); border-radius: 3px; }
.markdown-preview[data-use-github-style] .highlight pre { margin-bottom: 0px; word-break: normal; }
.markdown-preview[data-use-github-style] pre { word-wrap: normal; }
.markdown-preview[data-use-github-style] pre code, .markdown-preview[data-use-github-style] pre tt { display: inline; max-width: initial; padding: 0px; margin: 0px; overflow: initial; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0px; }
.markdown-preview[data-use-github-style] pre code::before, .markdown-preview[data-use-github-style] pre tt::before, .markdown-preview[data-use-github-style] pre code::after, .markdown-preview[data-use-github-style] pre tt::after { content: normal; }
.markdown-preview[data-use-github-style] kbd { display: inline-block; padding: 3px 5px; font-size: 11px; line-height: 10px; color: rgb(85, 85, 85); vertical-align: middle; background-color: rgb(252, 252, 252); border-width: 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(204, 204, 204) rgb(187, 187, 187); border-image: initial; border-radius: 3px; box-shadow: rgb(187, 187, 187) 0px -1px 0px inset; }
.markdown-preview[data-use-github-style] a { color: rgb(51, 122, 183); }
.markdown-preview[data-use-github-style] code { color: inherit; }
.markdown-preview[data-use-github-style] pre.editor-colors { padding: 0.8em 1em; margin-bottom: 1em; font-size: 0.85em; border-radius: 4px; overflow: auto; }
.scrollbars-visible-always .markdown-preview pre.editor-colors .vertical-scrollbar, .scrollbars-visible-always .markdown-preview pre.editor-colors .horizontal-scrollbar { visibility: hidden; }
.scrollbars-visible-always .markdown-preview pre.editor-colors:hover .vertical-scrollbar, .scrollbars-visible-always .markdown-preview pre.editor-colors:hover .horizontal-scrollbar { visibility: visible; }
.markdown-preview .task-list-item-checkbox { position: absolute; margin: 0.25em 0px 0px -1.4em; }
.bracket-matcher .region {
border-bottom: 1px dotted lime;
position: absolute;
}

.spell-check-misspelling .region {
border-bottom: 2px dotted rgba(255, 51, 51, 0.75);
}
.spell-check-corrections {
width: 25em !important;
}

pre.editor-colors {
background-color: #282c34;
color: #abb2bf;
}
pre.editor-colors .line.cursor-line {
background-color: rgba(153, 187, 255, 0.04);
}
pre.editor-colors .invisible {
color: #abb2bf;
}
pre.editor-colors .cursor {
border-left: 2px solid #528bff;
}
pre.editor-colors .selection .region {
background-color: #3e4451;
}
pre.editor-colors .bracket-matcher .region {
border-bottom: 1px solid #528bff;
box-sizing: border-box;
}
pre.editor-colors .invisible-character {
color: rgba(171, 178, 191, 0.15);
}
pre.editor-colors .indent-guide {
color: rgba(171, 178, 191, 0.15);
}
pre.editor-colors .wrap-guide {
background-color: rgba(171, 178, 191, 0.15);
}
pre.editor-colors .find-result .region.region.region,
pre.editor-colors .current-result .region.region.region {
border-radius: 2px;
background-color: rgba(82, 139, 255, 0.24);
transition: border-color 0.4s;
}
pre.editor-colors .find-result .region.region.region {
border: 2px solid transparent;
}
pre.editor-colors .current-result .region.region.region {
border: 2px solid #528bff;
transition-duration: .1s;
}
pre.editor-colors .gutter .line-number {
color: #636d83;
-webkit-font-smoothing: antialiased;
}
pre.editor-colors .gutter .line-number.cursor-line {
color: #abb2bf;
background-color: #2c313a;
}
pre.editor-colors .gutter .line-number.cursor-line-no-selection {
background-color: transparent;
}
pre.editor-colors .gutter .line-number .icon-right {
color: #abb2bf;
}
pre.editor-colors .gutter:not(.git-diff-icon) .line-number.git-line-removed.git-line-removed::before {
bottom: -3px;
}
pre.editor-colors .gutter:not(.git-diff-icon) .line-number.git-line-removed::after {
content: "";
position: absolute;
left: 0px;
bottom: 0px;
width: 25px;
border-bottom: 1px dotted rgba(224, 82, 82, 0.5);
pointer-events: none;
}
pre.editor-colors .gutter .line-number.folded,
pre.editor-colors .gutter .line-number:after,
pre.editor-colors .fold-marker:after {
color: #abb2bf;
}
.syntax--comment {
color: #5c6370;
font-style: italic;
}
.syntax--comment .syntax--markup.syntax--link {
color: #5c6370;
}
.syntax--entity.syntax--name.syntax--type {
color: #e5c07b;
}
.syntax--entity.syntax--other.syntax--inherited-class {
color: #98c379;
}
.syntax--keyword {
color: #c678dd;
}
.syntax--keyword.syntax--control {
color: #c678dd;
}
.syntax--keyword.syntax--operator {
color: #abb2bf;
}
.syntax--keyword.syntax--other.syntax--special-method {
color: #61afef;
}
.syntax--keyword.syntax--other.syntax--unit {
color: #d19a66;
}
.syntax--storage {
color: #c678dd;
}
.syntax--storage.syntax--type.syntax--annotation,
.syntax--storage.syntax--type.syntax--primitive {
color: #c678dd;
}
.syntax--storage.syntax--modifier.syntax--package,
.syntax--storage.syntax--modifier.syntax--import {
color: #abb2bf;
}
.syntax--constant {
color: #d19a66;
}
.syntax--constant.syntax--variable {
color: #d19a66;
}
.syntax--constant.syntax--character.syntax--escape {
color: #56b6c2;
}
.syntax--constant.syntax--numeric {
color: #d19a66;
}
.syntax--constant.syntax--other.syntax--color {
color: #56b6c2;
}
.syntax--constant.syntax--other.syntax--symbol {
color: #56b6c2;
}
.syntax--variable {
color: #e06c75;
}
.syntax--variable.syntax--interpolation {
color: #be5046;
}
.syntax--variable.syntax--parameter {
color: #abb2bf;
}
.syntax--string {
color: #98c379;
}
.syntax--string.syntax--regexp {
color: #56b6c2;
}
.syntax--string.syntax--regexp .syntax--source.syntax--ruby.syntax--embedded {
color: #e5c07b;
}
.syntax--string.syntax--other.syntax--link {
color: #e06c75;
}
.syntax--punctuation.syntax--definition.syntax--comment {
color: #5c6370;
}
.syntax--punctuation.syntax--definition.syntax--method-parameters,
.syntax--punctuation.syntax--definition.syntax--function-parameters,
.syntax--punctuation.syntax--definition.syntax--parameters,
.syntax--punctuation.syntax--definition.syntax--separator,
.syntax--punctuation.syntax--definition.syntax--seperator,
.syntax--punctuation.syntax--definition.syntax--array {
color: #abb2bf;
}
.syntax--punctuation.syntax--definition.syntax--heading,
.syntax--punctuation.syntax--definition.syntax--identity {
color: #61afef;
}
.syntax--punctuation.syntax--definition.syntax--bold {
color: #e5c07b;
font-weight: bold;
}
.syntax--punctuation.syntax--definition.syntax--italic {
color: #c678dd;
font-style: italic;
}
.syntax--punctuation.syntax--section.syntax--embedded {
color: #be5046;
}
.syntax--punctuation.syntax--section.syntax--method,
.syntax--punctuation.syntax--section.syntax--class,
.syntax--punctuation.syntax--section.syntax--inner-class {
color: #abb2bf;
}
.syntax--support.syntax--class {
color: #e5c07b;
}
.syntax--support.syntax--type {
color: #56b6c2;
}
.syntax--support.syntax--function {
color: #56b6c2;
}
.syntax--support.syntax--function.syntax--any-method {
color: #61afef;
}
.syntax--entity.syntax--name.syntax--function {
color: #61afef;
}
.syntax--entity.syntax--name.syntax--class,
.syntax--entity.syntax--name.syntax--type.syntax--class {
color: #e5c07b;
}
.syntax--entity.syntax--name.syntax--section {
color: #61afef;
}
.syntax--entity.syntax--name.syntax--tag {
color: #e06c75;
}
.syntax--entity.syntax--other.syntax--attribute-name {
color: #d19a66;
}
.syntax--entity.syntax--other.syntax--attribute-name.syntax--id {
color: #61afef;
}
.syntax--meta.syntax--class {
color: #e5c07b;
}
.syntax--meta.syntax--class.syntax--body {
color: #abb2bf;
}
.syntax--meta.syntax--method-call,
.syntax--meta.syntax--method {
color: #abb2bf;
}
.syntax--meta.syntax--definition.syntax--variable {
color: #e06c75;
}
.syntax--meta.syntax--link {
color: #d19a66;
}
.syntax--meta.syntax--require {
color: #61afef;
}
.syntax--meta.syntax--selector {
color: #c678dd;
}
.syntax--meta.syntax--separator {
background-color: #373b41;
color: #abb2bf;
}
.syntax--meta.syntax--tag {
color: #abb2bf;
}
.syntax--underline {
text-decoration: underline;
}
.syntax--none {
color: #abb2bf;
}
.syntax--invalid.syntax--deprecated {
color: #523d14 !important;
background-color: #e0c285 !important;
}
.syntax--invalid.syntax--illegal {
color: white !important;
background-color: #e05252 !important;
}
.syntax--markup.syntax--bold {
color: #d19a66;
font-weight: bold;
}
.syntax--markup.syntax--changed {
color: #c678dd;
}
.syntax--markup.syntax--deleted {
color: #e06c75;
}
.syntax--markup.syntax--italic {
color: #c678dd;
font-style: italic;
}
.syntax--markup.syntax--heading {
color: #e06c75;
}
.syntax--markup.syntax--heading .syntax--punctuation.syntax--definition.syntax--heading {
color: #61afef;
}
.syntax--markup.syntax--link {
color: #56b6c2;
}
.syntax--markup.syntax--inserted {
color: #98c379;
}
.syntax--markup.syntax--quote {
color: #d19a66;
}
.syntax--markup.syntax--raw {
color: #98c379;
}
.syntax--source.syntax--c .syntax--keyword.syntax--operator {
color: #c678dd;
}
.syntax--source.syntax--cpp .syntax--keyword.syntax--operator {
color: #c678dd;
}
.syntax--source.syntax--cs .syntax--keyword.syntax--operator {
color: #c678dd;
}
.syntax--source.syntax--css .syntax--property-name,
.syntax--source.syntax--css .syntax--property-value {
color: #828997;
}
.syntax--source.syntax--css .syntax--property-name.syntax--support,
.syntax--source.syntax--css .syntax--property-value.syntax--support {
color: #abb2bf;
}
.syntax--source.syntax--elixir .syntax--source.syntax--embedded.syntax--source {
color: #abb2bf;
}
.syntax--source.syntax--elixir .syntax--constant.syntax--language,
.syntax--source.syntax--elixir .syntax--constant.syntax--numeric,
.syntax--source.syntax--elixir .syntax--constant.syntax--definition {
color: #61afef;
}
.syntax--source.syntax--elixir .syntax--variable.syntax--definition,
.syntax--source.syntax--elixir .syntax--variable.syntax--anonymous {
color: #c678dd;
}
.syntax--source.syntax--elixir .syntax--quoted {
color: #98c379;
}
.syntax--source.syntax--elixir .syntax--keyword.syntax--special-method,
.syntax--source.syntax--elixir .syntax--embedded.syntax--section,
.syntax--source.syntax--elixir .syntax--embedded.syntax--source.syntax--empty {
color: #e06c75;
}
.syntax--source.syntax--elixir .syntax--readwrite.syntax--module .syntax--punctuation {
color: #e06c75;
}
.syntax--source.syntax--elixir .syntax--regexp.syntax--section,
.syntax--source.syntax--elixir .syntax--regexp.syntax--string {
color: #be5046;
}
.syntax--source.syntax--elixir .syntax--separator,
.syntax--source.syntax--elixir .syntax--keyword.syntax--operator {
color: #d19a66;
}
.syntax--source.syntax--elixir .syntax--variable.syntax--constant {
color: #e5c07b;
}
.syntax--source.syntax--elixir .syntax--array,
.syntax--source.syntax--elixir .syntax--scope,
.syntax--source.syntax--elixir .syntax--section {
color: #828997;
}
.syntax--source.syntax--gfm .syntax--markup {
-webkit-font-smoothing: auto;
}
.syntax--source.syntax--gfm .syntax--link .syntax--entity {
color: #61afef;
}
.syntax--source.syntax--go .syntax--storage.syntax--type.syntax--string {
color: #c678dd;
}
.syntax--source.syntax--ini .syntax--keyword.syntax--other.syntax--definition.syntax--ini {
color: #e06c75;
}
.syntax--source.syntax--java .syntax--storage.syntax--modifier.syntax--import {
color: #e5c07b;
}
.syntax--source.syntax--java .syntax--storage.syntax--type {
color: #e5c07b;
}
.syntax--source.syntax--java .syntax--keyword.syntax--operator.syntax--instanceof {
color: #c678dd;
}
.syntax--source.syntax--java-properties .syntax--meta.syntax--key-pair {
color: #e06c75;
}
.syntax--source.syntax--java-properties .syntax--meta.syntax--key-pair > .syntax--punctuation {
color: #abb2bf;
}
.syntax--source.syntax--js .syntax--keyword.syntax--operator {
color: #56b6c2;
}
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--delete,
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--in,
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--of,
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--instanceof,
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--new,
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--typeof,
.syntax--source.syntax--js .syntax--keyword.syntax--operator.syntax--void {
color: #c678dd;
}
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--dictionary.syntax--json > .syntax--string.syntax--quoted.syntax--json {
color: #e06c75;
}
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--dictionary.syntax--json > .syntax--string.syntax--quoted.syntax--json > .syntax--punctuation.syntax--string {
color: #e06c75;
}
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--dictionary.syntax--json > .syntax--value.syntax--json > .syntax--string.syntax--quoted.syntax--json,
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--array.syntax--json > .syntax--value.syntax--json > .syntax--string.syntax--quoted.syntax--json,
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--dictionary.syntax--json > .syntax--value.syntax--json > .syntax--string.syntax--quoted.syntax--json > .syntax--punctuation,
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--array.syntax--json > .syntax--value.syntax--json > .syntax--string.syntax--quoted.syntax--json > .syntax--punctuation {
color: #98c379;
}
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--dictionary.syntax--json > .syntax--constant.syntax--language.syntax--json,
.syntax--source.syntax--json .syntax--meta.syntax--structure.syntax--array.syntax--json > .syntax--constant.syntax--language.syntax--json {
color: #56b6c2;
}
.syntax--source.syntax--ruby .syntax--constant.syntax--other.syntax--symbol > .syntax--punctuation {
color: inherit;
}
.syntax--source.syntax--python .syntax--keyword.syntax--operator.syntax--logical.syntax--python {
color: #c678dd;
}
.syntax--source.syntax--python .syntax--variable.syntax--parameter {
color: #d19a66;
}
-->

1 optional的用法

optional类位于#include <boost/optional.hpp>中,包装了“可能阐释无效值”的对象,实现了“未初始化”的概念。函数并不能总是返回有意义的结果,有时候函数可能返回“无意义”的值,一般来说我们通常使用一个不再正常解空间的一个哨兵来表示无意义的概念,如NULL,-1,end()或者EOF.然后对于不同的应用场合,这些哨兵并不是通用的,而且有时候可能不存在这种解空间之外的哨兵。optional很像一个仅能存放一个元素的容器,它实现了"未初始化"的概念:如果元素未初始化,那么容器就是空的,否则,容器内就是有效的,已经初始化的值。optional的真实接口很复杂,因为它要能包装任何的类型。

2 操作方法

在具体的介绍之前,我们先看一个optional的一个使用示例。通过这个示例我们先对optional的使用有一个大体的认识:

#include <boost/optional.hpp>
#include <iostream>
#include <vector>
 
int main()
{
    boost::optional<int> op0;        //一个未初始化的optional对象
    boost::optional<int> op1(boost::none);        //同上,使用none赋予未初始化值
    assert(!op0);        //允许隐式类型转换为bool,用来判断是否为有效的值
    assert(op0==op1);    //未初始化的对象都是相同的
    assert(op1.get_value_or(253) == 253);        //获取可选值
 
    boost::optional<std::string> ops("test");        //使用test进行初始化
    std::string str = *ops;            //使用解引用操作获取赋予的值
    std::cout<<str<<std::endl;
 
    std::vector<int> v(10);
    boost::optional<std::vector<int>&> opv(v);        //容纳一个容器的引用
    assert(opv);            //已经使用v进行初始化了
    opv->push_back(5);        //使用箭头操作符操作其保存的容器
    assert(opv->size() == 11);
    opv = boost::none;        //重新是容器变为未初始化的
    assert(!opv);
    system("pause");        //程序暂停
    return 0;
}

从这个使用示例中,我们应该对optional的使用方式有一个大概的了解了。下面来对其构造函数和成员函数进行介绍。

2.1 构造函数

optional的构造函数用很多种:

  1. 无参的optional()或者optional(boost::none)构造一个未初始化optional对象,参数boost::none是一个类似空指针的none_t类型常量,表示未初始化。如上例中op0,op1的构造过程。
  2. optional(v)构造一个已初始化的optional对象,其值为v的拷贝(上例中ops的构造过程)。如果模板类型为T&,那么optional内部持有对引用的包装(上例中opv的构造过程)。
  3. optional(condition,v)根据条件condition来构造optional对象,如果条件成立(true)则初始化为v,否则为未初始化状态。
  4. optional还支持复制和赋值操作,可以从另外一个optional对象构造。当想让一个optional对象重新恢复到未初始化状态时,可以对该对象赋值为boost::none

2.2 成员函数

optional采用了指针语义来访问其保存的内部元素,因此我们可以将未初始化的optional对象的行为看作空指针。它重载了operator*operator->以实现与指针相同的语义。get()get_ptr()成员函数可以分别获取其保存的元素的引用和指针。成员函数get_value_or(default)是一个特别的访问函数,可以保证返回一个有效的值,如果optional已初始化,那么返回内部的元素,否则返回default(如上面示例所示,返回了默认值253)。
optional还定义了到bool的隐式类型转换,方便对其进行测试来判断一个optional对象是否为空。
optional还全面支持比较运算,包括==,!=,<,>,>=。与普通指针比较的“浅比较”(仅比较指针指)不同,optional的比较是""深比较",同时加入了对未初始化情况的判断。
关于optional的接口使用也简单明了,把它认为是一个大小为1并且行为类似指针的容器就可以。下面这个示例演示了如何使用optional对象作为函数的返回值来表示返回值是否有效的概念:

#include <boost/optional.hpp>
#include <iostream>
#include <cmath>
 
typedef boost::optional<double> optD;
 
optD Calc(int x)    //计算倒数
{
    return optD(x != 0,1.0/x);        //使用条件构造函数
}
 
optD SqrtOp(double x)    //计算实数的平方根
{
    return optD(x>0,sqrt(x));        //条件构造函数
}
 
int main()
{
    optD d = Calc(10);
    if(d)
        std::cout<<*d<<std::endl;
    d = SqrtOp(-10);
    if(!d)
        std::cout<<"no result"<<std::endl;
    system("pause");        //程序暂停
    return 0;
}

3 自动推导数据类型

在上面的示例中,optional保存的对象数据类型都比较简单而且我们事先都知道(如int,string).有时候我们可能很难知道optional到底要保存的对象的数据类型具体是什么,这时候如果能自动的推到出其保存对象的函数对象那么就十分方便了,optional提供了make_optional来实现了这种自动推到的机制,其函数声明如下:

optional<T> make_optional(T const& v);
optional<T> make_optional(bool condition,T const& v);

不过需要注意的是,make_optional()无法推到出T引用类型的optional对象(如本文第一个例子中vector引用对象),因此如果需要一个optional<T&>的对象,就不能使用make_optional函数。下面是其使用示例:

#include <boost/optional.hpp>
#include <iostream>
#include <boost/typeof/typeof.hpp>        //提供BOOST_AUTO
 
int main()
{
    BOOST_AUTO(x,boost::make_optional(5));        //BOOST_AUTO实现了标准库中auto的概念
    assert(*x = 5);
    BOOST_AUTO(y,boost::make_optional(*x>10,1.0));
    //BOOST_AUTO(y, make_optional<double>((*x > 10), 1.0));        //也可以这样手动指定数据类型
    assert(!y);
    system("pause");        //程序暂停
    return 0;
}

4 就地创建

optional要求类型T具有拷贝语义,因为它内部会保存值的拷贝,但很多时候复杂对象的拷贝代价很高,而且这个值仅仅作为拷贝的临时用途,是一种浪费。因此optional库提供了"就地创建"的概念,可以不要求类型具有拷贝语义,直接用构造函数所需的参数创建对象,这导致发展出了另一个boost库——in_place_factory.

#include <boost/optional.hpp>
#include <iostream>
#include <vector>
#include <boost/utility/in_place_factory.hpp>        
 
int main()
{
    //就地创建string对象,不需要临时对象string("..")
    boost::optional<std::string> ops(boost::in_place("test in_place_factory"));
    std::cout<<*ops<<std::endl;
    //就地创建std::vector对象,不需要临时对象vector(10,3)
    boost::optional<std::vector<int>> opp(boost::in_place(10,3));
    assert(opp->size()==10);
    assert((*opp)[0] == 3);
    system("pause");        //程序暂停
    return 0;
}

上面的实例中vector作为容器元素创建时并没有使用引用的方式。optional的模板类型使用引用(T&)在很多方面与原始类型T有不同,比如无法使用上面的就地创建,就地赋值。与c++语言内置的引用类型不同的是,它可以声明是不指定初值,并且在赋值时转移包装的对象,而不是对源包装对象赋值。

参考文章:

boost optional

最新文章

  1. Leetcode 416. Partition Equal Subset Sum
  2. JS-Array数组对象
  3. 最万能的解决mysql数据库的各种问题的办法
  4. springMVC 上传文件
  5. Linux centOS7 下安装mysql5.7.10
  6. Python 练习册--生成唯一激活码(邀请码)
  7. C# Socket Server 收不到数据
  8. 【阿里云产品公测】云引擎ACE新手实战基于Wordpress
  9. 织梦DeDeCms列表分页和内容页分页错位解决办法
  10. The initialize list of C++ Class
  11. Gradle安装步骤
  12. [Swift]LeetCode844. 比较含退格的字符串 | Backspace String Compare
  13. 微信小程序下拉刷新和上拉加载的实现
  14. python之面向对象初识
  15. SqlServer查询某个表的列名称、说明、备注、类型等
  16. 使用jQuery+huandlebars遍历数组嵌套数组
  17. DOM.getBoundingClientRect()
  18. Python 操作 mysql数据库的一个小小的基础案例,小白新手,以备后用~~
  19. 01: docker 基本使用
  20. 加强对HEAD 请求的处理(转贴)

热门文章

  1. rabbitmq支持.net framwork 3.5的最后版本
  2. k8s 命令补全
  3. springboot学习一:快速搭建springboot项目
  4. webpack代理解决跨域问题
  5. Url的拦截问题
  6. nginx问题集锦
  7. swift 加载 本地html 和 网络路径
  8. 富文本编辑器 kindeditor
  9. 把http网站变成https网站
  10. 《Dare To Dream》第七次作业:团队项目设计完善&amp;编码测试