1 // Copyright Louis Dionne 2013-2017 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 4 5 #include <boost/hana/bool.hpp> 6 7 #include <iostream> 8 namespace hana = boost::hana; 9 10 11 namespace pure { 12 //! [pure] 13 template <typename X> identity(X x)14auto identity(X x) { return x; } 15 16 auto x = identity(hana::bool_c<true>); 17 static_assert(hana::value(x), ""); 18 //! [pure] 19 } 20 21 namespace impure { 22 //! [impure_identity] 23 template <typename X> identity(X x)24auto identity(X x) { 25 std::cout << "Good luck in evaluating this at compile-time!"; 26 return x; 27 } 28 //! [impure_identity] 29 30 //! [impure] 31 auto x = identity(hana::bool_c<true>); 32 static_assert(hana::value(x), ""); 33 //! [impure] 34 } 35 main()36int main() { } 37