if you have a nuclear power plant and wanna compute small magic squares, then let's do it
2 #include <boost/utility.hpp>
8 static const bool value = true;
11 static const bool value = false;
14 // Here are some graph structures. Some of them define the type "OneTag"
15 // to True or False, some does not. Not defining a tag is (or at least
16 // should be) equivalent to defining it to "False".
26 /**************** The first method to use tags ****************/
28 template <typename Graph, typename Enable = void>
33 // specialization for those graphs which defined the tag to be true:
34 template <typename Graph>
35 struct HasOneTag<Graph, typename enable_if<typename Graph::OneTag>::type > {
39 template <typename Graph>
40 int cn1(const Graph &, False) {
44 template <typename Graph>
45 int cn1(const Graph &, True) {
49 template <typename Graph>
50 int cn1(const Graph &g) {
51 return cn1(g, typename HasOneTag<Graph>::TheTag());
54 /**************** The second method ****************/
56 // An artificial type to provoke a conversion to avoid ambuguity...
60 Wrap(const T &t) : value(t) {}
63 template <typename Graph>
64 typename enable_if<typename Graph::OneTag, int>::type
69 template <typename Graph>
70 int _cn2(Wrap<Graph>) {
74 template <typename Graph>
75 int cn2(const Graph& g) {
76 return _cn2<Graph>(g);
85 cout << "The first method:\n";
86 cout << "G1: " << cn1(g1) << endl;
87 cout << "G2: " << cn1(g2) << endl;
88 cout << "G3: " << cn1(g3) << endl;
90 cout << "The second method:\n";
91 cout << "G1: " << cn2(g1) << endl;
92 cout << "G2: " << cn2(g2) << endl;
93 cout << "G3: " << cn2(g3) << endl;