cpp_test_library.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Copyright 2016 Klemens Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. // For more information, see http://www.boost.org
  7. #include <boost/predef.h>
  8. #if (__cplusplus >= 201402L) || (BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(14,0,0))
  9. #include <boost/dll/config.hpp>
  10. #include <boost/variant.hpp>
  11. BOOST_SYMBOL_EXPORT extern int unscoped_var;
  12. int unscoped_var = 42;
  13. BOOST_SYMBOL_EXPORT extern const double unscoped_c_var;
  14. const double unscoped_c_var = 1.234;
  15. namespace some_space {
  16. BOOST_SYMBOL_EXPORT extern double variable;
  17. double variable = 0.2;
  18. BOOST_SYMBOL_EXPORT const int & scoped_fun()
  19. {
  20. static int x = 0xDEADBEEF;
  21. return x;
  22. }
  23. }
  24. BOOST_SYMBOL_EXPORT void overloaded(const volatile int i)
  25. {
  26. unscoped_var = i;
  27. }
  28. BOOST_SYMBOL_EXPORT void overloaded(const double d)
  29. {
  30. some_space::variable = d;
  31. }
  32. BOOST_SYMBOL_EXPORT void use_variant(boost::variant<int, double> & v)
  33. {
  34. v = 42;
  35. }
  36. BOOST_SYMBOL_EXPORT void use_variant(boost::variant<double, int> & v)
  37. {
  38. v = 3.124;
  39. }
  40. namespace some_space
  41. {
  42. BOOST_SYMBOL_EXPORT extern int father_value;
  43. int father_value = 12;
  44. struct BOOST_SYMBOL_EXPORT some_father
  45. {
  46. some_father() { father_value = 24; };
  47. ~some_father() { father_value = 112; };
  48. };
  49. struct BOOST_SYMBOL_EXPORT some_class : some_father
  50. {
  51. static int value ;
  52. static void set_value(const int &i);
  53. // static some_class* dummy();
  54. virtual double func(double i, double j);
  55. virtual int func(int i, int j);
  56. int func(int i, int j) volatile;
  57. double func(double i, double j) const volatile;
  58. int mem_val;
  59. int get() const ;
  60. void set(int i) ;
  61. some_class();
  62. some_class(some_class &&);
  63. some_class(int i);
  64. some_class& operator=(some_class &&);
  65. virtual ~some_class();
  66. };
  67. some_class::some_class(some_class &&){}
  68. some_class& some_class::operator=(some_class &&ref) {return ref;}
  69. BOOST_SYMBOL_EXPORT extern std::size_t size_of_some_class;
  70. std::size_t size_of_some_class = sizeof(some_space::some_class);
  71. extern "C" BOOST_SYMBOL_EXPORT const volatile some_class* this_;
  72. const volatile some_class * this_ = nullptr;
  73. int some_class::value = -1;
  74. void some_class::set_value(const int &i) {value = i;}
  75. //some_class* some_class::dummy() {return new some_class();}//so it implements an allocating ctor.
  76. double some_class::func(double i, double j) {this_ = this; return i*j;}
  77. int some_class::func(int i, int j) {this_ = this; return i+j;}
  78. int some_class::func(int i, int j) volatile {this_ = this; return i-j;;}
  79. double some_class::func(double i, double j) const volatile {this_ = this; return i/j;}
  80. int some_class::get() const {this_ = this; return mem_val;}
  81. void some_class::set(int i) {this_ = this; mem_val = i;}
  82. some_class::some_class() { this_ = this; value = 23; mem_val = 123;}
  83. some_class::some_class(int i) : mem_val(456) {this_ = this; value = i;}
  84. some_class::~some_class()
  85. {
  86. value = 0;
  87. this_ = this;
  88. }
  89. }
  90. #endif