2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-01 20:42:13 +00:00
Files
hana/example/tutorial/constant_side_effects.cpp
Louis Dionne 08f66d47c1 [IntegralConstant] Suffix variable templates with _c, and clean up type names
Along with PR #166, this closes #122 because names have now been
cleaned up and are now consistent basically everywhere.
2015-09-01 16:34:04 -04:00

39 lines
738 B
C++

/*
@copyright Louis Dionne 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/bool.hpp>
#include <iostream>
namespace hana = boost::hana;
namespace pure {
//! [pure]
template <typename X>
auto identity(X x) { return x; }
auto x = identity(hana::bool_c<true>);
static_assert(hana::value(x), "");
//! [pure]
}
namespace impure {
//! [impure_identity]
template <typename X>
auto identity(X x) {
std::cout << "Good luck in evaluating this at compile-time!";
return x;
}
//! [impure_identity]
//! [impure]
auto x = identity(hana::bool_c<true>);
static_assert(hana::value(x), "");
//! [impure]
}
int main() { }