OSDN Git Service
(root)
/
gintenlib
/
gintenlib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
be5c252
)
bool_comparable に ADL 対策をした
author
SubaruG
<subaru_g@users.sourceforge.jp>
Thu, 28 Jan 2010 18:07:53 +0000
(
03:07
+0900)
committer
SubaruG
<subaru_g@users.sourceforge.jp>
Thu, 28 Jan 2010 18:07:53 +0000
(
03:07
+0900)
gintenlib/bool_comparable.hpp
patch
|
blob
|
history
diff --git
a/gintenlib/bool_comparable.hpp
b/gintenlib/bool_comparable.hpp
index
e975be1
..
ca3de1c
100644
(file)
--- a/
gintenlib/bool_comparable.hpp
+++ b/
gintenlib/bool_comparable.hpp
@@
-185,17
+185,22
@@
namespace gintenlib
{
namespace gintenlib
{
+ namespace bool_comparable_ // ADL 回避
+ {
// ヘルパ構造体
// ヘルパ構造体
- struct bool_comparable_helper
+ namespace detail_
{
{
- // operator bool_type() の戻り値として使われる値
- void bool_value() const {}
+ struct bool_comparable_helper
+ {
+ // operator bool_type() の戻り値として使われる値
+ void bool_value() const {}
+
+ private:
+ // コンパイルエラーを起こすための private 関数
+ bool this_type_does_not_support_comparisons_();
- private:
- // コンパイルエラーを起こすための private 関数
- bool this_type_does_not_support_comparisons_();
-
- };
+ };
+ }
// 本体
template<typename Derived>
// 本体
template<typename Derived>
@@
-211,6
+216,9
@@
namespace gintenlib
// 他のテンプレートでも derived は使いたいぜ
template<typename U> friend class bool_comparable;
// 他のテンプレートでも derived は使いたいぜ
template<typename U> friend class bool_comparable;
+ // ヘルパ構造体名を適当に短縮
+ typedef detail_::bool_comparable_helper helper;
+
public:
// 本題
operator bool_type() const
public:
// 本題
operator bool_type() const
@@
-281,7
+289,7
@@
namespace gintenlib
static bool_type bool_value_()
{
// 関数を無駄に作らせない工夫。どうせ bool_type の値は使わないし
static bool_type bool_value_()
{
// 関数を無駄に作らせない工夫。どうせ bool_type の値は使わないし
- return reinterpret_cast<bool_type>( &
bool_comparable_
helper::bool_value );
+ return reinterpret_cast<bool_type>( &helper::bool_value );
}
// テスト関数
}
// テスト関数
@@
-309,12
+317,12
@@
namespace gintenlib
// 等値比較
friend bool operator==( const bool_comparable& lhs, const bool_comparable& rhs )
{
// 等値比較
friend bool operator==( const bool_comparable& lhs, const bool_comparable& rhs )
{
- return
bool_comparable_
helper().this_type_does_not_support_comparisons_();
+ return helper().this_type_does_not_support_comparisons_();
}
// 不等値比較
friend bool operator!=( const bool_comparable& lhs, const bool_comparable& rhs )
{
}
// 不等値比較
friend bool operator!=( const bool_comparable& lhs, const bool_comparable& rhs )
{
- return
bool_comparable_
helper().this_type_does_not_support_comparisons_();
+ return helper().this_type_does_not_support_comparisons_();
}
protected:
}
protected:
@@
-323,6
+331,11
@@
namespace gintenlib
~bool_comparable() {}
}; // class bool_comparable<Derived>
~bool_comparable() {}
}; // class bool_comparable<Derived>
+
+ } // namespace bool_comparable_
+
+ // gintenlib 名前空間に引き入れる
+ using namespace bool_comparable_;
} // namespace gintenlib
} // namespace gintenlib