//  (C) Copyright Steve Cleary & John Maddock 2000.
//  Permission to copy, use, modify, sell and
//  distribute this software is granted provided this copyright notice appears
//  in all copies. This software is provided "as is" without express or implied
//  warranty, and with no claim as to its suitability for any purpose.

//  See http://www.boost.org for most recent version including documentation.

/*
  Japanese Translation Copyright (C) 2003 mikari(Mika.N)<mikarim@m18.alpha-net.ne.jp>.
	
	オリジナルの、及びこの著作権表示が全ての複製の中に現れる限り、この文書の
	複製、利用、変更、販売そして配布を認める。このドキュメントは「あるがまま」
	に提供されており、いかなる明示的、暗黙的保証も行わない。また、
	いかなる目的に対しても、その利用が適していることを関知しない。
	
	本ライブラリのドキュメントを含む最新版に関しては、http://www.boost.org を参照せよ。
	日本語版ドキュメントに関しては、http://boost.cppll.jp を参照すること。
*/

#include <boost/static_assert.hpp>

//
// all these tests should succeed.
// some of these tests are rather simplistic (ie useless)
// in order to ensure that they compile on all platforms.
//
/*	これら全てのテストは成功すべきである。
	幾つかのテストは安易で役に立たないものである。
	これらは、ただそれらのテストが全てのプラットフォーム上で
	コンパイル可能なことを確実に確認するためだけのものである。
*/

// Namespace scope
// 名前空間スコープ
BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short));
BOOST_STATIC_ASSERT(sizeof(char) == 1);

// Function (block) scope
// 関数スコープ
void f()
{
  BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short));
  BOOST_STATIC_ASSERT(sizeof(char) == 1);
}

struct Bob
{
  private:  // can be in private, to avoid namespace pollution
  // 名前空間の汚染を避けるために、プライベートにすることが出来る
    BOOST_STATIC_ASSERT(sizeof(int) >= sizeof(short));
    BOOST_STATIC_ASSERT(sizeof(char) == 1);
  public:

  // Member function scope: provides access to member variables
  // メンバー関数スコープ：メンバー変数へのアクセスを提供する
  int x;
  char c;
  int f()
  {
#ifndef _MSC_VER // broken sizeof in VC6
    BOOST_STATIC_ASSERT(sizeof(x) >= sizeof(short));
    BOOST_STATIC_ASSERT(sizeof(c) == 1);
#endif
    return x;
  }
};



// Template class scope
// テンプレートクラススコープ
template <class Int, class Char>
struct Bill
{
  private:  // can be in private, to avoid namespace pollution
  // 名前空間の汚染を避けるために、プライベートにすることが出来る
    BOOST_STATIC_ASSERT(sizeof(Int) > sizeof(char));
  public:

  // Template member function scope: provides access to member variables
  // テンプレートメンバー関数スコープ：メンバー変数へのアクセスを提供する
  Int x;
  Char c;
  template <class Int2, class Char2>
  void f(Int2 , Char2 )
  {
    BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Int2));
    BOOST_STATIC_ASSERT(sizeof(Char) == sizeof(Char2));
  }
};

void test_Bill() // BOOST_CT_ASSERTs are not triggerred until instantiated
// BOOST_CT_ASSERTのテストは、ソースより目的プログラムが生成されるまでは評価されない
{
  Bill<int, char> z;
  //Bill<int, int> bad; // will not compile  // コンパイルできないだろう
  int i = 3;
  char ch = 'a';
  z.f(i, ch);
  //z.f(i, i); // should not compile  // エラーになるべきである
}

int main()
{ 
   test_Bill();
   return 0; 
}




