print.cpp 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  1. // Copyright (C) 2016-2018 T. Zachary Laine
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/yap/expression.hpp>
  7. #include <boost/yap/print.hpp>
  8. #include <boost/test/minimal.hpp>
  9. #include <sstream>
  10. #include <regex>
  11. template<typename T>
  12. using term = boost::yap::terminal<boost::yap::expression, T>;
  13. template<typename T>
  14. using ref = boost::yap::expression_ref<boost::yap::expression, T>;
  15. namespace yap = boost::yap;
  16. namespace bh = boost::hana;
  17. template<boost::yap::expr_kind Kind, typename Tuple>
  18. struct user_expr
  19. {
  20. static boost::yap::expr_kind const kind = Kind;
  21. Tuple elements;
  22. };
  23. BOOST_YAP_USER_BINARY_OPERATOR(plus, user_expr, user_expr)
  24. template<typename T>
  25. using user_term = boost::yap::terminal<user_expr, T>;
  26. template<typename T>
  27. using user_ref = boost::yap::expression_ref<user_expr, T>;
  28. struct thing
  29. {};
  30. std::string fix_tti(std::string s)
  31. {
  32. // msvc: remove struct/class prefixes
  33. static const std::regex estruct("(struct|class) ");
  34. s = std::regex_replace(s, estruct, "");
  35. // gcc/clang: strip integral literals suffixes
  36. static const std::regex eint("(\\d)u?l{0,2}");
  37. s = std::regex_replace(s, eint, "$1");
  38. return s;
  39. }
  40. int test_main(int, char * [])
  41. {
  42. {
  43. BOOST_CHECK(
  44. yap::op_string(yap::expr_kind::terminal) == std::string("term"));
  45. BOOST_CHECK(
  46. yap::op_string(yap::expr_kind::unary_plus) == std::string("+"));
  47. BOOST_CHECK(yap::op_string(yap::expr_kind::negate) == std::string("-"));
  48. BOOST_CHECK(
  49. yap::op_string(yap::expr_kind::dereference) == std::string("*"));
  50. BOOST_CHECK(
  51. yap::op_string(yap::expr_kind::complement) == std::string("~"));
  52. BOOST_CHECK(
  53. yap::op_string(yap::expr_kind::address_of) == std::string("&"));
  54. BOOST_CHECK(
  55. yap::op_string(yap::expr_kind::logical_not) == std::string("!"));
  56. BOOST_CHECK(yap::op_string(yap::expr_kind::pre_inc) == std::string("++"));
  57. BOOST_CHECK(yap::op_string(yap::expr_kind::pre_dec) == std::string("--"));
  58. BOOST_CHECK(
  59. yap::op_string(yap::expr_kind::post_inc) == std::string("++(int)"));
  60. BOOST_CHECK(
  61. yap::op_string(yap::expr_kind::post_dec) == std::string("--(int)"));
  62. BOOST_CHECK(
  63. yap::op_string(yap::expr_kind::shift_left) == std::string("<<"));
  64. BOOST_CHECK(
  65. yap::op_string(yap::expr_kind::shift_right) == std::string(">>"));
  66. BOOST_CHECK(
  67. yap::op_string(yap::expr_kind::multiplies) == std::string("*"));
  68. BOOST_CHECK(yap::op_string(yap::expr_kind::divides) == std::string("/"));
  69. BOOST_CHECK(yap::op_string(yap::expr_kind::modulus) == std::string("%"));
  70. BOOST_CHECK(
  71. yap::op_string(yap::expr_kind::multiplies_assign) ==
  72. std::string("*="));
  73. BOOST_CHECK(
  74. yap::op_string(yap::expr_kind::divides_assign) ==
  75. std::string("/="));
  76. BOOST_CHECK(
  77. yap::op_string(yap::expr_kind::modulus_assign) ==
  78. std::string("%="));
  79. BOOST_CHECK(
  80. yap::op_string(yap::expr_kind::plus_assign) == std::string("+="));
  81. BOOST_CHECK(
  82. yap::op_string(yap::expr_kind::minus_assign) == std::string("-="));
  83. BOOST_CHECK(
  84. yap::op_string(yap::expr_kind::bitwise_and_assign) ==
  85. std::string("&="));
  86. BOOST_CHECK(
  87. yap::op_string(yap::expr_kind::bitwise_or_assign) ==
  88. std::string("|="));
  89. BOOST_CHECK(
  90. yap::op_string(yap::expr_kind::bitwise_xor_assign) ==
  91. std::string("^="));
  92. BOOST_CHECK(
  93. yap::op_string(yap::expr_kind::subscript) == std::string("[]"));
  94. BOOST_CHECK(yap::op_string(yap::expr_kind::if_else) == std::string("?:"));
  95. BOOST_CHECK(yap::op_string(yap::expr_kind::call) == std::string("()"));
  96. BOOST_CHECK(
  97. yap::op_string(yap::expr_kind(-1)) ==
  98. std::string("** ERROR: UNKNOWN OPERATOR! **"));
  99. }
  100. {
  101. user_term<double> unity{1.0};
  102. int i_ = 42;
  103. user_term<int &&> i{std::move(i_)};
  104. user_expr<
  105. yap::expr_kind::plus,
  106. bh::tuple<user_ref<user_term<double> &>, user_term<int &&>>>
  107. expr = unity + std::move(i);
  108. user_expr<
  109. yap::expr_kind::plus,
  110. bh::tuple<
  111. user_ref<user_term<double> &>,
  112. user_expr<
  113. yap::expr_kind::plus,
  114. bh::tuple<
  115. user_ref<user_term<double> &>,
  116. user_term<int &&>>>>>
  117. unevaluated_expr = unity + std::move(expr);
  118. {
  119. std::ostringstream oss;
  120. yap::print(oss, unity);
  121. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  122. )");
  123. }
  124. {
  125. std::ostringstream oss;
  126. yap::print(oss, expr);
  127. BOOST_CHECK(oss.str() == R"(expr<+>
  128. term<double>[=1] &
  129. term<int &&>[=42]
  130. )");
  131. }
  132. {
  133. std::ostringstream oss;
  134. yap::print(oss, unevaluated_expr);
  135. BOOST_CHECK(oss.str() == R"(expr<+>
  136. term<double>[=1] &
  137. expr<+>
  138. term<double>[=1] &
  139. term<int &&>[=42]
  140. )");
  141. }
  142. user_term<thing> a_thing{bh::make_tuple(thing{})};
  143. {
  144. std::ostringstream oss;
  145. yap::print(oss, a_thing);
  146. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  147. )");
  148. }
  149. user_term<double> const const_unity{1.0};
  150. user_expr<
  151. yap::expr_kind::plus,
  152. bh::tuple<
  153. user_ref<user_term<double> &>,
  154. user_ref<user_term<double> const &>>>
  155. nonconst_plus_const = unity + const_unity;
  156. {
  157. std::ostringstream oss;
  158. yap::print(oss, nonconst_plus_const);
  159. BOOST_CHECK(oss.str() == R"(expr<+>
  160. term<double>[=1] &
  161. term<double>[=1] const &
  162. )");
  163. }
  164. auto nonconst_plus_nonconst_plus_const = unity + nonconst_plus_const;
  165. {
  166. std::ostringstream oss;
  167. yap::print(oss, nonconst_plus_nonconst_plus_const);
  168. BOOST_CHECK(oss.str() == R"(expr<+>
  169. term<double>[=1] &
  170. expr<+> &
  171. term<double>[=1] &
  172. term<double>[=1] const &
  173. )");
  174. }
  175. auto const const_nonconst_plus_const = nonconst_plus_const;
  176. auto nonconst_plus_nonconst_plus_const_2 =
  177. unity + const_nonconst_plus_const;
  178. {
  179. std::ostringstream oss;
  180. yap::print(oss, nonconst_plus_nonconst_plus_const_2);
  181. BOOST_CHECK(oss.str() == R"(expr<+>
  182. term<double>[=1] &
  183. expr<+> const &
  184. term<double>[=1] &
  185. term<double>[=1] const &
  186. )");
  187. }
  188. }
  189. {
  190. term<double> unity{1.0};
  191. int i_ = 42;
  192. term<int &&> i{std::move(i_)};
  193. yap::expression<
  194. yap::expr_kind::plus,
  195. bh::tuple<ref<term<double> &>, term<int &&>>>
  196. expr = unity + std::move(i);
  197. yap::expression<
  198. yap::expr_kind::plus,
  199. bh::tuple<
  200. ref<term<double> &>,
  201. yap::expression<
  202. yap::expr_kind::plus,
  203. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  204. unevaluated_expr = unity + std::move(expr);
  205. {
  206. std::ostringstream oss;
  207. yap::print(oss, unity);
  208. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  209. )");
  210. }
  211. {
  212. std::ostringstream oss;
  213. yap::print(oss, expr);
  214. BOOST_CHECK(oss.str() == R"(expr<+>
  215. term<double>[=1] &
  216. term<int &&>[=42]
  217. )");
  218. }
  219. {
  220. std::ostringstream oss;
  221. yap::print(oss, unevaluated_expr);
  222. BOOST_CHECK(oss.str() == R"(expr<+>
  223. term<double>[=1] &
  224. expr<+>
  225. term<double>[=1] &
  226. term<int &&>[=42]
  227. )");
  228. }
  229. term<thing> a_thing(thing{});
  230. {
  231. std::ostringstream oss;
  232. yap::print(oss, a_thing);
  233. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  234. )");
  235. }
  236. term<double> const const_unity{1.0};
  237. yap::expression<
  238. yap::expr_kind::plus,
  239. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  240. nonconst_plus_const = unity + const_unity;
  241. {
  242. std::ostringstream oss;
  243. yap::print(oss, nonconst_plus_const);
  244. BOOST_CHECK(oss.str() == R"(expr<+>
  245. term<double>[=1] &
  246. term<double>[=1] const &
  247. )");
  248. }
  249. {
  250. using namespace yap::literals;
  251. std::ostringstream oss;
  252. yap::print(oss, 1_p);
  253. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  254. )");
  255. }
  256. }
  257. {
  258. term<double> unity{1.0};
  259. int i_ = 42;
  260. term<int &&> i{std::move(i_)};
  261. yap::expression<
  262. yap::expr_kind::minus,
  263. bh::tuple<ref<term<double> &>, term<int &&>>>
  264. expr = unity - std::move(i);
  265. yap::expression<
  266. yap::expr_kind::minus,
  267. bh::tuple<
  268. ref<term<double> &>,
  269. yap::expression<
  270. yap::expr_kind::minus,
  271. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  272. unevaluated_expr = unity - std::move(expr);
  273. {
  274. std::ostringstream oss;
  275. yap::print(oss, unity);
  276. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  277. )");
  278. }
  279. {
  280. std::ostringstream oss;
  281. yap::print(oss, expr);
  282. BOOST_CHECK(oss.str() == R"(expr<->
  283. term<double>[=1] &
  284. term<int &&>[=42]
  285. )");
  286. }
  287. {
  288. std::ostringstream oss;
  289. yap::print(oss, unevaluated_expr);
  290. BOOST_CHECK(oss.str() == R"(expr<->
  291. term<double>[=1] &
  292. expr<->
  293. term<double>[=1] &
  294. term<int &&>[=42]
  295. )");
  296. }
  297. term<thing> a_thing(thing{});
  298. {
  299. std::ostringstream oss;
  300. yap::print(oss, a_thing);
  301. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  302. )");
  303. }
  304. term<double> const const_unity{1.0};
  305. yap::expression<
  306. yap::expr_kind::minus,
  307. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  308. nonconst_minus_const = unity - const_unity;
  309. {
  310. std::ostringstream oss;
  311. yap::print(oss, nonconst_minus_const);
  312. BOOST_CHECK(oss.str() == R"(expr<->
  313. term<double>[=1] &
  314. term<double>[=1] const &
  315. )");
  316. }
  317. {
  318. using namespace yap::literals;
  319. std::ostringstream oss;
  320. yap::print(oss, 1_p);
  321. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  322. )");
  323. }
  324. }
  325. {
  326. term<double> unity{1.0};
  327. int i_ = 42;
  328. term<int &&> i{std::move(i_)};
  329. yap::expression<
  330. yap::expr_kind::less,
  331. bh::tuple<ref<term<double> &>, term<int &&>>>
  332. expr = unity < std::move(i);
  333. yap::expression<
  334. yap::expr_kind::less,
  335. bh::tuple<
  336. ref<term<double> &>,
  337. yap::expression<
  338. yap::expr_kind::less,
  339. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  340. unevaluated_expr = unity < std::move(expr);
  341. {
  342. std::ostringstream oss;
  343. yap::print(oss, unity);
  344. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  345. )");
  346. }
  347. {
  348. std::ostringstream oss;
  349. yap::print(oss, expr);
  350. BOOST_CHECK(oss.str() == R"(expr<<>
  351. term<double>[=1] &
  352. term<int &&>[=42]
  353. )");
  354. }
  355. {
  356. std::ostringstream oss;
  357. yap::print(oss, unevaluated_expr);
  358. BOOST_CHECK(oss.str() == R"(expr<<>
  359. term<double>[=1] &
  360. expr<<>
  361. term<double>[=1] &
  362. term<int &&>[=42]
  363. )");
  364. }
  365. term<thing> a_thing(thing{});
  366. {
  367. std::ostringstream oss;
  368. yap::print(oss, a_thing);
  369. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  370. )");
  371. }
  372. term<double> const const_unity{1.0};
  373. yap::expression<
  374. yap::expr_kind::less,
  375. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  376. nonconst_less_const = unity < const_unity;
  377. {
  378. std::ostringstream oss;
  379. yap::print(oss, nonconst_less_const);
  380. BOOST_CHECK(oss.str() == R"(expr<<>
  381. term<double>[=1] &
  382. term<double>[=1] const &
  383. )");
  384. }
  385. {
  386. using namespace yap::literals;
  387. std::ostringstream oss;
  388. yap::print(oss, 1_p);
  389. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  390. )");
  391. }
  392. }
  393. {
  394. term<double> unity{1.0};
  395. int i_ = 42;
  396. term<int &&> i{std::move(i_)};
  397. yap::expression<
  398. yap::expr_kind::greater,
  399. bh::tuple<ref<term<double> &>, term<int &&>>>
  400. expr = unity > std::move(i);
  401. yap::expression<
  402. yap::expr_kind::greater,
  403. bh::tuple<
  404. ref<term<double> &>,
  405. yap::expression<
  406. yap::expr_kind::greater,
  407. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  408. unevaluated_expr = unity > std::move(expr);
  409. {
  410. std::ostringstream oss;
  411. yap::print(oss, unity);
  412. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  413. )");
  414. }
  415. {
  416. std::ostringstream oss;
  417. yap::print(oss, expr);
  418. BOOST_CHECK(oss.str() == R"(expr<>>
  419. term<double>[=1] &
  420. term<int &&>[=42]
  421. )");
  422. }
  423. {
  424. std::ostringstream oss;
  425. yap::print(oss, unevaluated_expr);
  426. BOOST_CHECK(oss.str() == R"(expr<>>
  427. term<double>[=1] &
  428. expr<>>
  429. term<double>[=1] &
  430. term<int &&>[=42]
  431. )");
  432. }
  433. term<thing> a_thing(thing{});
  434. {
  435. std::ostringstream oss;
  436. yap::print(oss, a_thing);
  437. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  438. )");
  439. }
  440. term<double> const const_unity{1.0};
  441. yap::expression<
  442. yap::expr_kind::greater,
  443. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  444. nonconst_greater_const = unity > const_unity;
  445. {
  446. std::ostringstream oss;
  447. yap::print(oss, nonconst_greater_const);
  448. BOOST_CHECK(oss.str() == R"(expr<>>
  449. term<double>[=1] &
  450. term<double>[=1] const &
  451. )");
  452. }
  453. {
  454. using namespace yap::literals;
  455. std::ostringstream oss;
  456. yap::print(oss, 1_p);
  457. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  458. )");
  459. }
  460. }
  461. {
  462. term<double> unity{1.0};
  463. int i_ = 42;
  464. term<int &&> i{std::move(i_)};
  465. yap::expression<
  466. yap::expr_kind::less_equal,
  467. bh::tuple<ref<term<double> &>, term<int &&>>>
  468. expr = unity <= std::move(i);
  469. yap::expression<
  470. yap::expr_kind::less_equal,
  471. bh::tuple<
  472. ref<term<double> &>,
  473. yap::expression<
  474. yap::expr_kind::less_equal,
  475. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  476. unevaluated_expr = unity <= std::move(expr);
  477. {
  478. std::ostringstream oss;
  479. yap::print(oss, unity);
  480. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  481. )");
  482. }
  483. {
  484. std::ostringstream oss;
  485. yap::print(oss, expr);
  486. BOOST_CHECK(oss.str() == R"(expr<<=>
  487. term<double>[=1] &
  488. term<int &&>[=42]
  489. )");
  490. }
  491. {
  492. std::ostringstream oss;
  493. yap::print(oss, unevaluated_expr);
  494. BOOST_CHECK(oss.str() == R"(expr<<=>
  495. term<double>[=1] &
  496. expr<<=>
  497. term<double>[=1] &
  498. term<int &&>[=42]
  499. )");
  500. }
  501. term<thing> a_thing(thing{});
  502. {
  503. std::ostringstream oss;
  504. yap::print(oss, a_thing);
  505. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  506. )");
  507. }
  508. term<double> const const_unity{1.0};
  509. yap::expression<
  510. yap::expr_kind::less_equal,
  511. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  512. nonconst_less_equal_const = unity <= const_unity;
  513. {
  514. std::ostringstream oss;
  515. yap::print(oss, nonconst_less_equal_const);
  516. BOOST_CHECK(oss.str() == R"(expr<<=>
  517. term<double>[=1] &
  518. term<double>[=1] const &
  519. )");
  520. }
  521. {
  522. using namespace yap::literals;
  523. std::ostringstream oss;
  524. yap::print(oss, 1_p);
  525. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  526. )");
  527. }
  528. }
  529. {
  530. term<double> unity{1.0};
  531. int i_ = 42;
  532. term<int &&> i{std::move(i_)};
  533. yap::expression<
  534. yap::expr_kind::greater_equal,
  535. bh::tuple<ref<term<double> &>, term<int &&>>>
  536. expr = unity >= std::move(i);
  537. yap::expression<
  538. yap::expr_kind::greater_equal,
  539. bh::tuple<
  540. ref<term<double> &>,
  541. yap::expression<
  542. yap::expr_kind::greater_equal,
  543. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  544. unevaluated_expr = unity >= std::move(expr);
  545. {
  546. std::ostringstream oss;
  547. yap::print(oss, unity);
  548. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  549. )");
  550. }
  551. {
  552. std::ostringstream oss;
  553. yap::print(oss, expr);
  554. BOOST_CHECK(oss.str() == R"(expr<>=>
  555. term<double>[=1] &
  556. term<int &&>[=42]
  557. )");
  558. }
  559. {
  560. std::ostringstream oss;
  561. yap::print(oss, unevaluated_expr);
  562. BOOST_CHECK(oss.str() == R"(expr<>=>
  563. term<double>[=1] &
  564. expr<>=>
  565. term<double>[=1] &
  566. term<int &&>[=42]
  567. )");
  568. }
  569. term<thing> a_thing(thing{});
  570. {
  571. std::ostringstream oss;
  572. yap::print(oss, a_thing);
  573. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  574. )");
  575. }
  576. term<double> const const_unity{1.0};
  577. yap::expression<
  578. yap::expr_kind::greater_equal,
  579. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  580. nonconst_greater_equal_const = unity >= const_unity;
  581. {
  582. std::ostringstream oss;
  583. yap::print(oss, nonconst_greater_equal_const);
  584. BOOST_CHECK(oss.str() == R"(expr<>=>
  585. term<double>[=1] &
  586. term<double>[=1] const &
  587. )");
  588. }
  589. {
  590. using namespace yap::literals;
  591. std::ostringstream oss;
  592. yap::print(oss, 1_p);
  593. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  594. )");
  595. }
  596. }
  597. {
  598. term<double> unity{1.0};
  599. int i_ = 42;
  600. term<int &&> i{std::move(i_)};
  601. yap::expression<
  602. yap::expr_kind::equal_to,
  603. bh::tuple<ref<term<double> &>, term<int &&>>>
  604. expr = unity == std::move(i);
  605. yap::expression<
  606. yap::expr_kind::equal_to,
  607. bh::tuple<
  608. ref<term<double> &>,
  609. yap::expression<
  610. yap::expr_kind::equal_to,
  611. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  612. unevaluated_expr = unity == std::move(expr);
  613. {
  614. std::ostringstream oss;
  615. yap::print(oss, unity);
  616. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  617. )");
  618. }
  619. {
  620. std::ostringstream oss;
  621. yap::print(oss, expr);
  622. BOOST_CHECK(oss.str() == R"(expr<==>
  623. term<double>[=1] &
  624. term<int &&>[=42]
  625. )");
  626. }
  627. {
  628. std::ostringstream oss;
  629. yap::print(oss, unevaluated_expr);
  630. BOOST_CHECK(oss.str() == R"(expr<==>
  631. term<double>[=1] &
  632. expr<==>
  633. term<double>[=1] &
  634. term<int &&>[=42]
  635. )");
  636. }
  637. term<thing> a_thing(thing{});
  638. {
  639. std::ostringstream oss;
  640. yap::print(oss, a_thing);
  641. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  642. )");
  643. }
  644. term<double> const const_unity{1.0};
  645. yap::expression<
  646. yap::expr_kind::equal_to,
  647. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  648. nonconst_equal_to_const = unity == const_unity;
  649. {
  650. std::ostringstream oss;
  651. yap::print(oss, nonconst_equal_to_const);
  652. BOOST_CHECK(oss.str() == R"(expr<==>
  653. term<double>[=1] &
  654. term<double>[=1] const &
  655. )");
  656. }
  657. {
  658. using namespace yap::literals;
  659. std::ostringstream oss;
  660. yap::print(oss, 1_p);
  661. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  662. )");
  663. }
  664. }
  665. {
  666. term<double> unity{1.0};
  667. int i_ = 42;
  668. term<int &&> i{std::move(i_)};
  669. yap::expression<
  670. yap::expr_kind::not_equal_to,
  671. bh::tuple<ref<term<double> &>, term<int &&>>>
  672. expr = unity != std::move(i);
  673. yap::expression<
  674. yap::expr_kind::not_equal_to,
  675. bh::tuple<
  676. ref<term<double> &>,
  677. yap::expression<
  678. yap::expr_kind::not_equal_to,
  679. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  680. unevaluated_expr = unity != std::move(expr);
  681. {
  682. std::ostringstream oss;
  683. yap::print(oss, unity);
  684. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  685. )");
  686. }
  687. {
  688. std::ostringstream oss;
  689. yap::print(oss, expr);
  690. BOOST_CHECK(oss.str() == R"(expr<!=>
  691. term<double>[=1] &
  692. term<int &&>[=42]
  693. )");
  694. }
  695. {
  696. std::ostringstream oss;
  697. yap::print(oss, unevaluated_expr);
  698. BOOST_CHECK(oss.str() == R"(expr<!=>
  699. term<double>[=1] &
  700. expr<!=>
  701. term<double>[=1] &
  702. term<int &&>[=42]
  703. )");
  704. }
  705. term<thing> a_thing(thing{});
  706. {
  707. std::ostringstream oss;
  708. yap::print(oss, a_thing);
  709. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  710. )");
  711. }
  712. term<double> const const_unity{1.0};
  713. yap::expression<
  714. yap::expr_kind::not_equal_to,
  715. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  716. nonconst_not_equal_to_const = unity != const_unity;
  717. {
  718. std::ostringstream oss;
  719. yap::print(oss, nonconst_not_equal_to_const);
  720. BOOST_CHECK(oss.str() == R"(expr<!=>
  721. term<double>[=1] &
  722. term<double>[=1] const &
  723. )");
  724. }
  725. {
  726. using namespace yap::literals;
  727. std::ostringstream oss;
  728. yap::print(oss, 1_p);
  729. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  730. )");
  731. }
  732. }
  733. {
  734. term<double> unity{1.0};
  735. int i_ = 42;
  736. term<int &&> i{std::move(i_)};
  737. yap::expression<
  738. yap::expr_kind::logical_or,
  739. bh::tuple<ref<term<double> &>, term<int &&>>>
  740. expr = unity || std::move(i);
  741. yap::expression<
  742. yap::expr_kind::logical_or,
  743. bh::tuple<
  744. ref<term<double> &>,
  745. yap::expression<
  746. yap::expr_kind::logical_or,
  747. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  748. unevaluated_expr = unity || std::move(expr);
  749. {
  750. std::ostringstream oss;
  751. yap::print(oss, unity);
  752. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  753. )");
  754. }
  755. {
  756. std::ostringstream oss;
  757. yap::print(oss, expr);
  758. BOOST_CHECK(oss.str() == R"(expr<||>
  759. term<double>[=1] &
  760. term<int &&>[=42]
  761. )");
  762. }
  763. {
  764. std::ostringstream oss;
  765. yap::print(oss, unevaluated_expr);
  766. BOOST_CHECK(oss.str() == R"(expr<||>
  767. term<double>[=1] &
  768. expr<||>
  769. term<double>[=1] &
  770. term<int &&>[=42]
  771. )");
  772. }
  773. term<thing> a_thing(thing{});
  774. {
  775. std::ostringstream oss;
  776. yap::print(oss, a_thing);
  777. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  778. )");
  779. }
  780. term<double> const const_unity{1.0};
  781. yap::expression<
  782. yap::expr_kind::logical_or,
  783. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  784. nonconst_logical_or_const = unity || const_unity;
  785. {
  786. std::ostringstream oss;
  787. yap::print(oss, nonconst_logical_or_const);
  788. BOOST_CHECK(oss.str() == R"(expr<||>
  789. term<double>[=1] &
  790. term<double>[=1] const &
  791. )");
  792. }
  793. {
  794. using namespace yap::literals;
  795. std::ostringstream oss;
  796. yap::print(oss, 1_p);
  797. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  798. )");
  799. }
  800. }
  801. {
  802. term<double> unity{1.0};
  803. int i_ = 42;
  804. term<int &&> i{std::move(i_)};
  805. yap::expression<
  806. yap::expr_kind::logical_and,
  807. bh::tuple<ref<term<double> &>, term<int &&>>>
  808. expr = unity && std::move(i);
  809. yap::expression<
  810. yap::expr_kind::logical_and,
  811. bh::tuple<
  812. ref<term<double> &>,
  813. yap::expression<
  814. yap::expr_kind::logical_and,
  815. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  816. unevaluated_expr = unity && std::move(expr);
  817. {
  818. std::ostringstream oss;
  819. yap::print(oss, unity);
  820. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  821. )");
  822. }
  823. {
  824. std::ostringstream oss;
  825. yap::print(oss, expr);
  826. BOOST_CHECK(oss.str() == R"(expr<&&>
  827. term<double>[=1] &
  828. term<int &&>[=42]
  829. )");
  830. }
  831. {
  832. std::ostringstream oss;
  833. yap::print(oss, unevaluated_expr);
  834. BOOST_CHECK(oss.str() == R"(expr<&&>
  835. term<double>[=1] &
  836. expr<&&>
  837. term<double>[=1] &
  838. term<int &&>[=42]
  839. )");
  840. }
  841. term<thing> a_thing(thing{});
  842. {
  843. std::ostringstream oss;
  844. yap::print(oss, a_thing);
  845. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  846. )");
  847. }
  848. term<double> const const_unity{1.0};
  849. yap::expression<
  850. yap::expr_kind::logical_and,
  851. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  852. nonconst_logical_and_const = unity && const_unity;
  853. {
  854. std::ostringstream oss;
  855. yap::print(oss, nonconst_logical_and_const);
  856. BOOST_CHECK(oss.str() == R"(expr<&&>
  857. term<double>[=1] &
  858. term<double>[=1] const &
  859. )");
  860. }
  861. {
  862. using namespace yap::literals;
  863. std::ostringstream oss;
  864. yap::print(oss, 1_p);
  865. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  866. )");
  867. }
  868. }
  869. {
  870. term<double> unity{1.0};
  871. int i_ = 42;
  872. term<int &&> i{std::move(i_)};
  873. yap::expression<
  874. yap::expr_kind::bitwise_and,
  875. bh::tuple<ref<term<double> &>, term<int &&>>>
  876. expr = unity & std::move(i);
  877. yap::expression<
  878. yap::expr_kind::bitwise_and,
  879. bh::tuple<
  880. ref<term<double> &>,
  881. yap::expression<
  882. yap::expr_kind::bitwise_and,
  883. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  884. unevaluated_expr = unity & std::move(expr);
  885. {
  886. std::ostringstream oss;
  887. yap::print(oss, unity);
  888. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  889. )");
  890. }
  891. {
  892. std::ostringstream oss;
  893. yap::print(oss, expr);
  894. BOOST_CHECK(oss.str() == R"(expr<&>
  895. term<double>[=1] &
  896. term<int &&>[=42]
  897. )");
  898. }
  899. {
  900. std::ostringstream oss;
  901. yap::print(oss, unevaluated_expr);
  902. BOOST_CHECK(oss.str() == R"(expr<&>
  903. term<double>[=1] &
  904. expr<&>
  905. term<double>[=1] &
  906. term<int &&>[=42]
  907. )");
  908. }
  909. term<thing> a_thing(thing{});
  910. {
  911. std::ostringstream oss;
  912. yap::print(oss, a_thing);
  913. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  914. )");
  915. }
  916. term<double> const const_unity{1.0};
  917. yap::expression<
  918. yap::expr_kind::bitwise_and,
  919. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  920. nonconst_bitwise_and_const = unity & const_unity;
  921. {
  922. std::ostringstream oss;
  923. yap::print(oss, nonconst_bitwise_and_const);
  924. BOOST_CHECK(oss.str() == R"(expr<&>
  925. term<double>[=1] &
  926. term<double>[=1] const &
  927. )");
  928. }
  929. {
  930. using namespace yap::literals;
  931. std::ostringstream oss;
  932. yap::print(oss, 1_p);
  933. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  934. )");
  935. }
  936. }
  937. {
  938. term<double> unity{1.0};
  939. int i_ = 42;
  940. term<int &&> i{std::move(i_)};
  941. yap::expression<
  942. yap::expr_kind::bitwise_or,
  943. bh::tuple<ref<term<double> &>, term<int &&>>>
  944. expr = unity | std::move(i);
  945. yap::expression<
  946. yap::expr_kind::bitwise_or,
  947. bh::tuple<
  948. ref<term<double> &>,
  949. yap::expression<
  950. yap::expr_kind::bitwise_or,
  951. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  952. unevaluated_expr = unity | std::move(expr);
  953. {
  954. std::ostringstream oss;
  955. yap::print(oss, unity);
  956. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  957. )");
  958. }
  959. {
  960. std::ostringstream oss;
  961. yap::print(oss, expr);
  962. BOOST_CHECK(oss.str() == R"(expr<|>
  963. term<double>[=1] &
  964. term<int &&>[=42]
  965. )");
  966. }
  967. {
  968. std::ostringstream oss;
  969. yap::print(oss, unevaluated_expr);
  970. BOOST_CHECK(oss.str() == R"(expr<|>
  971. term<double>[=1] &
  972. expr<|>
  973. term<double>[=1] &
  974. term<int &&>[=42]
  975. )");
  976. }
  977. term<thing> a_thing(thing{});
  978. {
  979. std::ostringstream oss;
  980. yap::print(oss, a_thing);
  981. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  982. )");
  983. }
  984. term<double> const const_unity{1.0};
  985. yap::expression<
  986. yap::expr_kind::bitwise_or,
  987. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  988. nonconst_bitwise_or_const = unity | const_unity;
  989. {
  990. std::ostringstream oss;
  991. yap::print(oss, nonconst_bitwise_or_const);
  992. BOOST_CHECK(oss.str() == R"(expr<|>
  993. term<double>[=1] &
  994. term<double>[=1] const &
  995. )");
  996. }
  997. {
  998. using namespace yap::literals;
  999. std::ostringstream oss;
  1000. yap::print(oss, 1_p);
  1001. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1002. )");
  1003. }
  1004. }
  1005. {
  1006. term<double> unity{1.0};
  1007. int i_ = 42;
  1008. term<int &&> i{std::move(i_)};
  1009. yap::expression<
  1010. yap::expr_kind::bitwise_xor,
  1011. bh::tuple<ref<term<double> &>, term<int &&>>>
  1012. expr = unity ^ std::move(i);
  1013. yap::expression<
  1014. yap::expr_kind::bitwise_xor,
  1015. bh::tuple<
  1016. ref<term<double> &>,
  1017. yap::expression<
  1018. yap::expr_kind::bitwise_xor,
  1019. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  1020. unevaluated_expr = unity ^ std::move(expr);
  1021. {
  1022. std::ostringstream oss;
  1023. yap::print(oss, unity);
  1024. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  1025. )");
  1026. }
  1027. {
  1028. std::ostringstream oss;
  1029. yap::print(oss, expr);
  1030. BOOST_CHECK(oss.str() == R"(expr<^>
  1031. term<double>[=1] &
  1032. term<int &&>[=42]
  1033. )");
  1034. }
  1035. {
  1036. std::ostringstream oss;
  1037. yap::print(oss, unevaluated_expr);
  1038. BOOST_CHECK(oss.str() == R"(expr<^>
  1039. term<double>[=1] &
  1040. expr<^>
  1041. term<double>[=1] &
  1042. term<int &&>[=42]
  1043. )");
  1044. }
  1045. term<thing> a_thing(thing{});
  1046. {
  1047. std::ostringstream oss;
  1048. yap::print(oss, a_thing);
  1049. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  1050. )");
  1051. }
  1052. term<double> const const_unity{1.0};
  1053. yap::expression<
  1054. yap::expr_kind::bitwise_xor,
  1055. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  1056. nonconst_bitwise_xor_const = unity ^ const_unity;
  1057. {
  1058. std::ostringstream oss;
  1059. yap::print(oss, nonconst_bitwise_xor_const);
  1060. BOOST_CHECK(oss.str() == R"(expr<^>
  1061. term<double>[=1] &
  1062. term<double>[=1] const &
  1063. )");
  1064. }
  1065. {
  1066. using namespace yap::literals;
  1067. std::ostringstream oss;
  1068. yap::print(oss, 1_p);
  1069. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1070. )");
  1071. }
  1072. }
  1073. {
  1074. term<double> unity{1.0};
  1075. int i_ = 42;
  1076. term<int &&> i{std::move(i_)};
  1077. yap::expression<
  1078. yap::expr_kind::comma,
  1079. bh::tuple<ref<term<double> &>, term<int &&>>>
  1080. expr = (unity, std::move(i));
  1081. yap::expression<
  1082. yap::expr_kind::comma,
  1083. bh::tuple<
  1084. ref<term<double> &>,
  1085. yap::expression<
  1086. yap::expr_kind::comma,
  1087. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  1088. unevaluated_expr = (unity, std::move(expr));
  1089. {
  1090. std::ostringstream oss;
  1091. yap::print(oss, unity);
  1092. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  1093. )");
  1094. }
  1095. {
  1096. std::ostringstream oss;
  1097. yap::print(oss, expr);
  1098. BOOST_CHECK(oss.str() == R"(expr<,>
  1099. term<double>[=1] &
  1100. term<int &&>[=42]
  1101. )");
  1102. }
  1103. {
  1104. std::ostringstream oss;
  1105. yap::print(oss, unevaluated_expr);
  1106. BOOST_CHECK(oss.str() == R"(expr<,>
  1107. term<double>[=1] &
  1108. expr<,>
  1109. term<double>[=1] &
  1110. term<int &&>[=42]
  1111. )");
  1112. }
  1113. term<thing> a_thing(thing{});
  1114. {
  1115. std::ostringstream oss;
  1116. yap::print(oss, a_thing);
  1117. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  1118. )");
  1119. }
  1120. term<double> const const_unity{1.0};
  1121. yap::expression<
  1122. yap::expr_kind::comma,
  1123. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  1124. nonconst_comma_const = (unity, const_unity);
  1125. {
  1126. std::ostringstream oss;
  1127. yap::print(oss, nonconst_comma_const);
  1128. BOOST_CHECK(oss.str() == R"(expr<,>
  1129. term<double>[=1] &
  1130. term<double>[=1] const &
  1131. )");
  1132. }
  1133. {
  1134. using namespace yap::literals;
  1135. std::ostringstream oss;
  1136. yap::print(oss, 1_p);
  1137. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1138. )");
  1139. }
  1140. }
  1141. {
  1142. term<double> unity{1.0};
  1143. int i_ = 42;
  1144. term<int &&> i{std::move(i_)};
  1145. yap::expression<
  1146. yap::expr_kind::mem_ptr,
  1147. bh::tuple<ref<term<double> &>, term<int &&>>>
  1148. expr = unity->*std::move(i);
  1149. yap::expression<
  1150. yap::expr_kind::mem_ptr,
  1151. bh::tuple<
  1152. ref<term<double> &>,
  1153. yap::expression<
  1154. yap::expr_kind::mem_ptr,
  1155. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  1156. unevaluated_expr = unity->*std::move(expr);
  1157. {
  1158. std::ostringstream oss;
  1159. yap::print(oss, unity);
  1160. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  1161. )");
  1162. }
  1163. {
  1164. std::ostringstream oss;
  1165. yap::print(oss, expr);
  1166. BOOST_CHECK(oss.str() == R"(expr<->*>
  1167. term<double>[=1] &
  1168. term<int &&>[=42]
  1169. )");
  1170. }
  1171. {
  1172. std::ostringstream oss;
  1173. yap::print(oss, unevaluated_expr);
  1174. BOOST_CHECK(oss.str() == R"(expr<->*>
  1175. term<double>[=1] &
  1176. expr<->*>
  1177. term<double>[=1] &
  1178. term<int &&>[=42]
  1179. )");
  1180. }
  1181. term<thing> a_thing(thing{});
  1182. {
  1183. std::ostringstream oss;
  1184. yap::print(oss, a_thing);
  1185. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  1186. )");
  1187. }
  1188. term<double> const const_unity{1.0};
  1189. yap::expression<
  1190. yap::expr_kind::mem_ptr,
  1191. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  1192. nonconst_mem_ptr_const = unity->*const_unity;
  1193. {
  1194. std::ostringstream oss;
  1195. yap::print(oss, nonconst_mem_ptr_const);
  1196. BOOST_CHECK(oss.str() == R"(expr<->*>
  1197. term<double>[=1] &
  1198. term<double>[=1] const &
  1199. )");
  1200. }
  1201. {
  1202. using namespace yap::literals;
  1203. std::ostringstream oss;
  1204. yap::print(oss, 1_p);
  1205. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1206. )");
  1207. }
  1208. }
  1209. {
  1210. term<double> unity{1.0};
  1211. int i_ = 42;
  1212. term<int &&> i{std::move(i_)};
  1213. yap::expression<
  1214. yap::expr_kind::assign,
  1215. bh::tuple<ref<term<double> &>, term<int &&>>>
  1216. expr = unity = std::move(i);
  1217. yap::expression<
  1218. yap::expr_kind::assign,
  1219. bh::tuple<
  1220. ref<term<double> &>,
  1221. yap::expression<
  1222. yap::expr_kind::assign,
  1223. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  1224. unevaluated_expr = unity = std::move(expr);
  1225. {
  1226. std::ostringstream oss;
  1227. yap::print(oss, unity);
  1228. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  1229. )");
  1230. }
  1231. {
  1232. std::ostringstream oss;
  1233. yap::print(oss, expr);
  1234. BOOST_CHECK(oss.str() == R"(expr<=>
  1235. term<double>[=1] &
  1236. term<int &&>[=42]
  1237. )");
  1238. }
  1239. {
  1240. std::ostringstream oss;
  1241. yap::print(oss, unevaluated_expr);
  1242. BOOST_CHECK(oss.str() == R"(expr<=>
  1243. term<double>[=1] &
  1244. expr<=>
  1245. term<double>[=1] &
  1246. term<int &&>[=42]
  1247. )");
  1248. }
  1249. term<thing> a_thing(thing{});
  1250. {
  1251. std::ostringstream oss;
  1252. yap::print(oss, a_thing);
  1253. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  1254. )");
  1255. }
  1256. {
  1257. using namespace yap::literals;
  1258. std::ostringstream oss;
  1259. yap::print(oss, 1_p);
  1260. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1261. )");
  1262. }
  1263. }
  1264. {
  1265. term<double> unity{1.0};
  1266. int i_ = 42;
  1267. term<int &&> i{std::move(i_)};
  1268. yap::expression<
  1269. yap::expr_kind::shift_left_assign,
  1270. bh::tuple<ref<term<double> &>, term<int &&>>>
  1271. expr = unity <<= std::move(i);
  1272. yap::expression<
  1273. yap::expr_kind::shift_left_assign,
  1274. bh::tuple<
  1275. ref<term<double> &>,
  1276. yap::expression<
  1277. yap::expr_kind::shift_left_assign,
  1278. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  1279. unevaluated_expr = unity <<= std::move(expr);
  1280. {
  1281. std::ostringstream oss;
  1282. yap::print(oss, unity);
  1283. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  1284. )");
  1285. }
  1286. {
  1287. std::ostringstream oss;
  1288. yap::print(oss, expr);
  1289. BOOST_CHECK(oss.str() == R"(expr<<<=>
  1290. term<double>[=1] &
  1291. term<int &&>[=42]
  1292. )");
  1293. }
  1294. {
  1295. std::ostringstream oss;
  1296. yap::print(oss, unevaluated_expr);
  1297. BOOST_CHECK(oss.str() == R"(expr<<<=>
  1298. term<double>[=1] &
  1299. expr<<<=>
  1300. term<double>[=1] &
  1301. term<int &&>[=42]
  1302. )");
  1303. }
  1304. term<thing> a_thing(thing{});
  1305. {
  1306. std::ostringstream oss;
  1307. yap::print(oss, a_thing);
  1308. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  1309. )");
  1310. }
  1311. term<double> const const_unity{1.0};
  1312. yap::expression<
  1313. yap::expr_kind::shift_left_assign,
  1314. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  1315. nonconst_shift_left_assign_const = unity <<= const_unity;
  1316. {
  1317. std::ostringstream oss;
  1318. yap::print(oss, nonconst_shift_left_assign_const);
  1319. BOOST_CHECK(oss.str() == R"(expr<<<=>
  1320. term<double>[=1] &
  1321. term<double>[=1] const &
  1322. )");
  1323. }
  1324. {
  1325. using namespace yap::literals;
  1326. std::ostringstream oss;
  1327. yap::print(oss, 1_p);
  1328. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1329. )");
  1330. }
  1331. }
  1332. {
  1333. term<double> unity{1.0};
  1334. int i_ = 42;
  1335. term<int &&> i{std::move(i_)};
  1336. yap::expression<
  1337. yap::expr_kind::shift_right_assign,
  1338. bh::tuple<ref<term<double> &>, term<int &&>>>
  1339. expr = unity >>= std::move(i);
  1340. yap::expression<
  1341. yap::expr_kind::shift_right_assign,
  1342. bh::tuple<
  1343. ref<term<double> &>,
  1344. yap::expression<
  1345. yap::expr_kind::shift_right_assign,
  1346. bh::tuple<ref<term<double> &>, term<int &&>>>>>
  1347. unevaluated_expr = unity >>= std::move(expr);
  1348. {
  1349. std::ostringstream oss;
  1350. yap::print(oss, unity);
  1351. BOOST_CHECK(oss.str() == R"(term<double>[=1]
  1352. )");
  1353. }
  1354. {
  1355. std::ostringstream oss;
  1356. yap::print(oss, expr);
  1357. BOOST_CHECK(oss.str() == R"(expr<>>=>
  1358. term<double>[=1] &
  1359. term<int &&>[=42]
  1360. )");
  1361. }
  1362. {
  1363. std::ostringstream oss;
  1364. yap::print(oss, unevaluated_expr);
  1365. BOOST_CHECK(oss.str() == R"(expr<>>=>
  1366. term<double>[=1] &
  1367. expr<>>=>
  1368. term<double>[=1] &
  1369. term<int &&>[=42]
  1370. )");
  1371. }
  1372. term<thing> a_thing(thing{});
  1373. {
  1374. std::ostringstream oss;
  1375. yap::print(oss, a_thing);
  1376. BOOST_CHECK(fix_tti(oss.str()) == R"(term<thing>[=<<unprintable-value>>]
  1377. )");
  1378. }
  1379. term<double> const const_unity{1.0};
  1380. yap::expression<
  1381. yap::expr_kind::shift_right_assign,
  1382. bh::tuple<ref<term<double> &>, ref<term<double> const &>>>
  1383. nonconst_shift_right_assign_const = unity >>= const_unity;
  1384. {
  1385. std::ostringstream oss;
  1386. yap::print(oss, nonconst_shift_right_assign_const);
  1387. BOOST_CHECK(oss.str() == R"(expr<>>=>
  1388. term<double>[=1] &
  1389. term<double>[=1] const &
  1390. )");
  1391. }
  1392. {
  1393. using namespace yap::literals;
  1394. std::ostringstream oss;
  1395. yap::print(oss, 1_p);
  1396. BOOST_CHECK(fix_tti(oss.str()) == R"(term<boost::yap::placeholder<1>>[=1]
  1397. )");
  1398. }
  1399. }
  1400. return 0;
  1401. }