123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- /*
- * cxxomfort example: complex helpers
- *
- */
- #include <cxxomfort/base.hpp>
- #include <cxxomfort/complex.hpp>
- //#include <cxxomfort/library/complex.hpp>
- #include <cxxomfort/ostream.hpp>
- #include <cxxomfort/library/type_name.hpp>
- #include <iostream>
- using cxxomfort::type_name;
- void test_std_literals ();
- void test_user_literals ();
- int main () {
- using namespace std;
- cxxomfort::output_info(stdout); cout<< endl;
-
- cout<< "Feature macro: "<< CXXO_IF_MACRO(__cpp_lib_complex_udls,'_')<< endl;
- cout<< "\n\n";
- cout<< "_i literal built-in:"<< endl;
- {
- using namespace cxxomfort::fix::complex_helpers;
- cout<< type_name< CXXO_TYPEOF(3.1-i_c(2.2)) >()<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1f-if_c(2.2)) >()<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1L-il_c(2.2)) >()<< endl;
- }
-
- cout<< "\n----\n"<< endl;
- test_std_literals();
- test_user_literals();
- }
- void test_std_literals () {
- using namespace std;
- cout<< "std user-defined literals (\" \"i):"<< endl;
- #if (!defined(__cpp_lib_complex_udls))
- cout<< "unsupported in this compilation mode"<< endl;
- #else
- using namespace std::literals::complex_literals;
- cout<< type_name< CXXO_TYPEOF(3.1-2.2i) >()<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1f-2.2if) >()<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1L-2.2il) >()<< endl;
- #endif
- }
- void test_user_literals () {
- #if (CXXO_COMPILER_SUPPORT_user_defined_literals > 0)
- using namespace std;
- using namespace cxxomfort::fix::complex_literals;
- cout<< "cxxomfort::fix user-defined literals (\" \"_i):"<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1-2.2_i) >()<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1f-2.2_if) >()<< endl;
- cout<< type_name< CXXO_TYPEOF(3.1L-2.2_il) >()<< endl;
- #else
- std::cout<< "Not supported"<< std::endl;
- #endif
- }
|