File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed
meta_program/chapter_1_specializtion_and_deduction/namespace_and_declaration Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include " macro.hpp"
3
+ MXT_NAMESPACE_BEGIN (framework1)
4
+ template<typename T>
5
+ inline bool is_empty(T const & x) {
6
+ std::cout << " framework1::is_empty master template " << std::endl;
7
+ return x.empty ();
8
+ }
9
+
10
+ template <>
11
+ inline bool is_empty (const char * const & x) {
12
+ std::cout << " framework1::is_empty specification" << std::endl;
13
+ return x == 0 || *x == 0 ;
14
+ }
15
+
16
+ MXT_NAMESPACE_END (framework1)
Original file line number Diff line number Diff line change
1
+ #include " framework1.hpp"
2
+
3
+ MXT_NAMESPACE_BEGIN (framework2)
4
+
5
+ using framework1::is_empty;
6
+ template <typename string_t >
7
+ void do_something (string_t const &x) {
8
+ // if (framework1::is_empty(x)) // it causes error in framework3.cpp when call framework2::do_something(s)
9
+ if (!is_empty (x))
10
+ {
11
+ }
12
+ }
13
+ MXT_NAMESPACE_END (framework2)
Original file line number Diff line number Diff line change
1
+ #include " framework2.hpp"
2
+ namespace framework3 {
3
+ class EmptyString
4
+ {
5
+ };
6
+
7
+ bool is_empty (const EmptyString&x) {
8
+ std::cout << " framework3::is_empty" << std::endl;
9
+ return true ;
10
+ }
11
+ }
12
+
13
+ int main (int argc, char ** argv) {
14
+ framework3::EmptyString s;
15
+ framework2::do_something (s);
16
+ }
Original file line number Diff line number Diff line change
1
+ #define MXT_NAMESPACE_BEGIN (self ) namespace self {
2
+ #define MXT_NAMESPACE_END (self ) }
You can’t perform that action at this time.
0 commit comments