C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches
exercise-4-0.hpp
Go to the documentation of this file.
1// ===-- chapter-4/exercise-4-0.hpp ----------------------- -*- C++ -*- --=== //
9#ifndef EXERCISE_4_0
10#define EXERCISE_4_0
11
13
14#include <boost/static_assert.hpp>
15
16#include <boost/mpl/and.hpp>
17#include <boost/mpl/or.hpp>
18
19
33namespace exercise_4_0 {
34using namespace chapter4;
35
36// Check or_<true, fase> short-circuit. If short-circuit doesn't work,
37// undefined_false<false> will be checked; being undefined, this will be a
38// compilation error.
40 (boost::mpl::or_< undefined_false<true>, undefined_false<false> >::value));
41
42// Check and_<false, true> short-circuit. If short-circuit doesn't work,
43// undefined_false<false> will be checked; being undefined, this will be a
44// compilation error.
46 (!boost::mpl::and_< undefined_true<false>, undefined_true<true> >::value));
47
48} // namespace exercise_4_0
49
50#endif // EXERCISE_4_0
Define some booleans that don't compile on either true or false.
Provide utilities availble to all Chapter 4 solutions.
Encapsulate solution for Exercise 4-0.
BOOST_STATIC_ASSERT((boost::mpl::or_< undefined_false< true >, undefined_false< false > >::value))
If the template parameter is false, template instantiation is an error.
If the template parameter is true, template instantiation is an error.