mirror of
https://github.com/aantron/better-enums.git
synced 2025-12-07 01:06:42 +08:00
129 lines
3.6 KiB
HTML
129 lines
3.6 KiB
HTML
<!-- Generated automatically - edit the templates! -->
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
<head>
|
|
|
|
<title>Hello, World! - Better Enums</title>
|
|
|
|
<link rel="canonical" href="http://aantron.github.io/better-enums/tutorial/HelloWorld.html" />
|
|
<meta name="description" content="Introductory Better Enums tutorial - a simple, but complete,
|
|
Hello World program." />
|
|
<meta name="author" content="Anton Bachin" />
|
|
|
|
<meta name="viewport" content="width=device-width" />
|
|
|
|
<link rel="stylesheet" href="../better-enums.css" />
|
|
|
|
<script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-62962513-1', 'auto');
|
|
ga('send', 'pageview');
|
|
|
|
</script>
|
|
|
|
</head>
|
|
<body class="">
|
|
|
|
<nav>
|
|
<div class="container">
|
|
<a class="first" href="https://raw.githubusercontent.com/aantron/better-enums/0.11.3/enum.h"
|
|
download>Download</a>
|
|
<a href="https://github.com/aantron/better-enums">GitHub</a>
|
|
<a href="../index.html">Home</a>
|
|
<a href="../tutorial/HelloWorld.html">Tutorial</a>
|
|
<a href="../ApiReference.html">Reference</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="spacer"> </div>
|
|
|
|
<header>
|
|
<div class="container">
|
|
<section>
|
|
<h1><a href="../index.html">Better Enums</a></h1>
|
|
<h2>Reflective compile-time enums for <span class="cpp">C++</span></h2>
|
|
<h3>Open-source under the BSD license</h3>
|
|
</section>
|
|
|
|
<section class="notes">
|
|
<p>Version 0.11.3</p>
|
|
<p>To install, just add <code>enum.h</code> to your project.</p>
|
|
<p>
|
|
Visit the GitHub repo for issues, feedback, and the latest development.
|
|
</p>
|
|
</section>
|
|
|
|
<section class="buttons">
|
|
<a href="https://raw.githubusercontent.com/aantron/better-enums/0.11.3/enum.h"
|
|
download>Download <code>enum.h</code></a>
|
|
<a href="https://github.com/aantron/better-enums">GitHub</a>
|
|
</section>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="main">
|
|
<div class="container">
|
|
|
|
|
|
<p>
|
|
Welcome to the Better Enums tutorials! The code in this tutorial forms a
|
|
valid program, which you can <a href="https://github.com/aantron/better-enums/blob/0.11.3/example/1-hello-world.cc">download</a> and play with. The
|
|
program runs as part of the automated test suite.
|
|
</p>
|
|
|
|
<h2>Hello, World!</h2>
|
|
<p>Download <a href="https://raw.githubusercontent.com/aantron/better-enums/0.11.3/enum.h"
|
|
download><code>enum.h</code></a>, then compile this program:</p>
|
|
<pre>#include <iostream>
|
|
<em>#include "enum.h"</em>
|
|
|
|
<em>BETTER_ENUM</em>(<em>Word</em>, <em>int</em>, <em>Hello</em>, <em>World</em>)
|
|
|
|
int main()
|
|
{
|
|
std::cout << <em>(+Word::Hello)._to_string()</em> << ", "
|
|
<< <em>(+Word::World)._to_string()</em> << "!"
|
|
<< std::endl;
|
|
|
|
return 0;
|
|
}</pre><p>Run it, and you should see the output "Hello, World!"</p>
|
|
<p>Congratulations, you have just created your first Better Enum!</p>
|
|
|
|
|
|
<section class="tutorial-footer">
|
|
<p class="next">
|
|
Continue to the next tutorial: <a href="../tutorial/Conversions.html">Conversions</a>
|
|
</p>
|
|
|
|
<p class="up">
|
|
Or, return to the
|
|
<a href="../index.html#Tutorial">tutorial index</a>.
|
|
</p>
|
|
</section>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<footer>
|
|
<div class="container">
|
|
Copyright © 2015-2019 Anton Bachin. Released under the BSD 2-clause
|
|
license. See
|
|
<a href="https://github.com/aantron/better-enums/blob/0.11.3/doc/LICENSE">
|
|
LICENSE</a>.
|
|
<br />
|
|
This page is part of the documentation for Better Enums 0.11.3.
|
|
</div>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|
|
|