Advertisement
Guest User

Untitled

a guest
Jul 11th, 2019
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.54 KB | None | 0 0
  1. /** \file
  2. *
  3. */
  4. #ifndef MESHPP_CORE_SHARED_STRING_H_2A0F6174_39EA_40FE_B526_9293C36939D7
  5. #define MESHPP_CORE_SHARED_STRING_H_2A0F6174_39EA_40FE_B526_9293C36939D7
  6. #pragma once
  7.  
  8. #include <string>
  9. #include <memory>
  10. #include <utility>
  11. #include <string_view>
  12.  
  13. namespace meshpp::core
  14. {
  15.  
  16. //-----------------------------------------------------------------------------
  17. // Declaration of BasicSharedString
  18. //-----------------------------------------------------------------------------
  19.  
  20. template<typename CHAR_T>
  21. class BasicSharedString
  22. {
  23. public:
  24. using traits_type = typename std::basic_string_view<CHAR_T>::traits_type;
  25. using value_type = typename std::basic_string_view<CHAR_T>::value_type;
  26. using allocator_type = typename std::basic_string_view<CHAR_T>::allocator_type;
  27. using size_type = typename std::basic_string_view<CHAR_T>::size_type;
  28. using difference_type = typename std::basic_string_view<CHAR_T>::difference_type;
  29. using reference = typename std::basic_string_view<CHAR_T>::reference;
  30. using const_reference = typename std::basic_string_view<CHAR_T>::const_reference;
  31. using pointer = typename std::basic_string_view<CHAR_T>::pointer;
  32. using const_pointer = typename std::basic_string_view<CHAR_T>::const_pointer;
  33. using iterator = typename std::basic_string_view<CHAR_T>::iterator;
  34. using const_iterator = typename std::basic_string_view<CHAR_T>::const_iterator;
  35. using reverse_iterator = typename std::basic_string_view<CHAR_T>::reverse_iterator;
  36. using const_reverse_iterator = typename std::basic_string_view<CHAR_T>::const_reverse_iterator;
  37.  
  38. static const size_type npos = std::basic_string<CHAR_T>::npos;
  39.  
  40. using StringView_t = std::basic_string_view<value_type, traits_type>;
  41.  
  42. BasicSharedString(void);
  43. BasicSharedString(BasicSharedString &&);
  44. BasicSharedString(BasicSharedString const&);
  45. BasicSharedString& operator=(BasicSharedString &&);
  46. BasicSharedString& operator=(BasicSharedString const&);
  47.  
  48. template<typename ... ARGS_T>
  49. BasicSharedString(ARGS_T && ... args);
  50.  
  51. const_reference at(size_type pos) const;
  52. const_reference operator[](size_type pos) const;
  53. const_reference front(void) const;
  54. const_reference back(void) const;
  55. const_pointer data(void) const;
  56. const_pointer c_str(void) const;
  57.  
  58. operator StringView_t(void) const noexcept;
  59.  
  60. const_iterator begin(void) const;
  61. const_iterator cbegin(void) const;
  62.  
  63. const_iterator end(void) const;
  64. const_iterator cend(void) const;
  65.  
  66. const_reverse_iterator rbegin(void) const;
  67. const_reverse_iterator crbegin(void) const;
  68.  
  69. const_reverse_iterator rend(void) const;
  70. const_reverse_iterator crend(void) const;
  71.  
  72. [[nodiscard]] bool empty(void) const;
  73.  
  74. size_type size(void) const noexcept;
  75. size_type length(void) const noexcept;
  76. size_type max_size(void) const;
  77.  
  78. size_type capacity(void) const;
  79.  
  80. template<typename ... ARGS_T>
  81. int compare(ARGS_T && ... args) const;
  82. int compare(BasicSharedString const& other) const;
  83.  
  84. template<typename ... ARGS_T>
  85. bool starts_with(ARGS_T && ... args) const;
  86.  
  87. template<typename ... ARGS_T>
  88. bool ends_with(ARGS_T && ... args) const;
  89.  
  90. BasicSharedString substr(size_type pos = 0, size_type count = npos) const;
  91. size_type copy(pointer dest, size_type count, size_type pos = 0) const;
  92.  
  93. void swap(BasicSharedString& other) noexcept(noexcept(std::declval<BasicSharedString>().m_pStrData.swap(other.m_pStrData)));
  94.  
  95. template<typename ... ARGS_T>
  96. bool find(ARGS_T && ... args) const;
  97.  
  98. template<typename ... ARGS_T>
  99. bool rfind(ARGS_T && ... args) const;
  100.  
  101. template<typename ... ARGS_T>
  102. bool find_first_of(ARGS_T && ... args) const;
  103.  
  104. template<typename ... ARGS_T>
  105. bool find_first_not_of(ARGS_T && ... args) const;
  106.  
  107. template<typename ... ARGS_T>
  108. bool find_last_of(ARGS_T && ... args) const;
  109.  
  110. template<typename ... ARGS_T>
  111. bool find_last_not_of(ARGS_T && ... args) const;
  112.  
  113. private:
  114.  
  115. /*
  116. * For use by functions that aren't allowed to throw an exception or
  117. * have well specified values to be returned when certain errors happen.
  118. */
  119. static constexpr value_type nullchar = traits_type::to_char_type(0);
  120.  
  121. static constexpr auto smc_exceptionText = "This Basic Shared String has no string.";
  122.  
  123. size_t m_size;
  124. std::shared_ptr<const CHAR_T[]> m_pStrData;
  125. }; // class BasicSharedString
  126.  
  127. /**
  128. * The default implementation of a BasicSharedString.
  129. */
  130. using SharedString = BasicSharedString<char>;
  131.  
  132. template<typename CHAR_T>
  133. bool operator==(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs);
  134. template<typename CHAR_T>
  135. bool operator!=(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs);
  136. template<typename CHAR_T>
  137. bool operator<(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs);
  138. template<typename CHAR_T>
  139. bool operator<=(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs);
  140. template<typename CHAR_T>
  141. bool operator>(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs);
  142. template<typename CHAR_T>
  143. bool operator>=(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs);
  144.  
  145. template<typename CHAR_T, typename OTHER_T>
  146. bool operator==(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs);
  147. template<typename CHAR_T, typename OTHER_T>
  148. bool operator!=(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs);
  149. template<typename CHAR_T, typename OTHER_T>
  150. bool operator<(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs);
  151. template<typename CHAR_T, typename OTHER_T>
  152. bool operator<=(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs);
  153. template<typename CHAR_T, typename OTHER_T>
  154. bool operator>(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs);
  155. template<typename CHAR_T, typename OTHER_T>
  156. bool operator>=(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs);
  157.  
  158. template<typename OTHER_T, typename CHAR_T>
  159. bool operator==(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs);
  160. template<typename OTHER_T, typename CHAR_T>
  161. bool operator!=(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs);
  162. template<typename OTHER_T, typename CHAR_T>
  163. bool operator<(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs);
  164. template<typename OTHER_T, typename CHAR_T>
  165. bool operator<=(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs);
  166. template<typename OTHER_T, typename CHAR_T>
  167. bool operator>(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs);
  168. template<typename OTHER_T, typename CHAR_T>
  169. bool operator>=(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs);
  170.  
  171. //-----------------------------------------------------------------------------
  172. // Implementation of BasicSharedString
  173. //-----------------------------------------------------------------------------
  174.  
  175. template<typename CHAR_T>
  176. BasicSharedString<CHAR_T>::BasicSharedString(void) = default;
  177.  
  178. template<typename CHAR_T>
  179. BasicSharedString<CHAR_T>::BasicSharedString(BasicSharedString &&) = default;
  180.  
  181. template<typename CHAR_T>
  182. BasicSharedString<CHAR_T>::BasicSharedString(BasicSharedString const&) = default;
  183.  
  184. template<typename CHAR_T>
  185. auto BasicSharedString<CHAR_T>::operator=(BasicSharedString &&) -> BasicSharedString& = default;
  186.  
  187. template<typename CHAR_T>
  188. auto BasicSharedString<CHAR_T>::operator=(BasicSharedString const&) -> BasicSharedString& = default;
  189.  
  190. template<typename CHAR_T>
  191. template<typename ... ARGS_T>
  192. BasicSharedString<CHAR_T>::BasicSharedString(ARGS_T && ... args)
  193. : m_pStrData(std::make_shared<std::basic_string<CHAR_T>>(std::forward<ARGS_T>(args)...))
  194. { }
  195.  
  196. template<typename CHAR_T>
  197. auto BasicSharedString<CHAR_T>::at(size_type pos) const -> const_reference
  198. {
  199. if( ! m_pStrData)
  200. {
  201. throw std::out_of_range(smc_exceptionText);
  202. }
  203. return std::string_view(m_pStrData.get(), m_size)->at(pos);
  204. }
  205.  
  206. template<typename CHAR_T>
  207. auto BasicSharedString<CHAR_T>::operator[]( size_type pos ) const -> const_reference
  208. {
  209. if( ! m_pStrData)
  210. {
  211. throw std::out_of_range(smc_exceptionText);
  212. }
  213. return std::string_view(m_pStrData.get(), m_size)->operator[](pos);
  214. }
  215.  
  216. template<typename CHAR_T>
  217. auto BasicSharedString<CHAR_T>::front(void) const -> const_reference
  218. {
  219. if( ! m_pStrData)
  220. {
  221. throw std::out_of_range(smc_exceptionText);
  222. }
  223. return std::string_view(m_pStrData.get(), m_size)->front();
  224. }
  225.  
  226. template<typename CHAR_T>
  227. auto BasicSharedString<CHAR_T>::back(void) const -> const_reference
  228. {
  229. if( ! m_pStrData)
  230. {
  231. throw std::out_of_range(smc_exceptionText);
  232. }
  233. return std::string_view(m_pStrData.get(), m_size)->back();
  234. }
  235.  
  236. template<typename CHAR_T>
  237. auto BasicSharedString<CHAR_T>::data(void) const -> const_pointer
  238. {
  239. if( ! m_pStrData)
  240. {
  241. // https://en.cppreference.com/w/cpp/string/basic_string/data
  242. // If empty() returns true, the pointer points to a single null character.
  243. return &nullchar;
  244. }
  245. return std::string_view(m_pStrData.get(), m_size)->data();
  246. }
  247.  
  248. template<typename CHAR_T>
  249. auto BasicSharedString<CHAR_T>::c_str(void) const -> const_pointer
  250. {
  251. // https://en.cppreference.com/w/cpp/string/basic_string/c_str
  252. // c_str() and data() perform the same function.
  253. return data();
  254. }
  255.  
  256. template<typename CHAR_T>
  257. BasicSharedString<CHAR_T>::operator StringView_t() const noexcept
  258. {
  259. if( ! m_pStrData)
  260. {
  261. return StringView_t();
  262. }
  263. return std::string_view(m_pStrData.get(), m_size)->operator StringView_t();
  264. }
  265.  
  266. template<typename CHAR_T>
  267. auto BasicSharedString<CHAR_T>::begin(void) const -> const_iterator
  268. {
  269. if( ! m_pStrData)
  270. {
  271. return const_iterator(&nullchar);
  272. }
  273. return std::string_view(m_pStrData.get(), m_size)->begin();
  274. }
  275.  
  276. template<typename CHAR_T>
  277. auto BasicSharedString<CHAR_T>::cbegin(void) const -> const_iterator
  278. {
  279. if( ! m_pStrData)
  280. {
  281. return const_iterator(&nullchar);
  282. }
  283. return std::string_view(m_pStrData.get(), m_size)->cbegin();
  284. }
  285.  
  286. template<typename CHAR_T>
  287. auto BasicSharedString<CHAR_T>::end(void) const -> const_iterator
  288. {
  289. if( ! m_pStrData)
  290. {
  291. return const_iterator(&nullchar);
  292. }
  293. return std::string_view(m_pStrData.get(), m_size)->end();
  294. }
  295.  
  296. template<typename CHAR_T>
  297. auto BasicSharedString<CHAR_T>::cend(void) const -> const_iterator
  298. {
  299. if( ! m_pStrData)
  300. {
  301. return const_iterator(&nullchar);
  302. }
  303. return std::string_view(m_pStrData.get(), m_size)->cend();
  304. }
  305.  
  306. template<typename CHAR_T>
  307. auto BasicSharedString<CHAR_T>::rbegin(void) const -> const_reverse_iterator
  308. {
  309. if( ! m_pStrData)
  310. {
  311. return const_reverse_iterator(&nullchar);
  312. }
  313. return std::string_view(m_pStrData.get(), m_size)->rbegin();
  314. }
  315.  
  316. template<typename CHAR_T>
  317. auto BasicSharedString<CHAR_T>::crbegin(void) const -> const_reverse_iterator
  318. {
  319. if( ! m_pStrData)
  320. {
  321. return const_reverse_iterator(&nullchar);
  322. }
  323. return std::string_view(m_pStrData.get(), m_size)->crbegin();
  324. }
  325.  
  326. template<typename CHAR_T>
  327. auto BasicSharedString<CHAR_T>::rend(void) const -> const_reverse_iterator
  328. {
  329. if( ! m_pStrData)
  330. {
  331. return const_reverse_iterator(&nullchar);
  332. }
  333. return std::string_view(m_pStrData.get(), m_size)->rend();
  334. }
  335.  
  336. template<typename CHAR_T>
  337. auto BasicSharedString<CHAR_T>::crend(void) const -> const_reverse_iterator
  338. {
  339. if( ! m_pStrData)
  340. {
  341. return const_reverse_iterator(&nullchar);
  342. }
  343. return std::string_view(m_pStrData.get(), m_size)->crend();
  344. }
  345.  
  346. template<typename CHAR_T>
  347. bool BasicSharedString<CHAR_T>::empty(void) const
  348. {
  349. return ! m_pStrData || m_size == 0;
  350. }
  351.  
  352. template<typename CHAR_T>
  353. auto BasicSharedString<CHAR_T>::size(void) const noexcept -> size_type
  354. {
  355. if( ! m_pStrData)
  356. {
  357. return 0;
  358. }
  359. return m_size;
  360. }
  361.  
  362. template<typename CHAR_T>
  363. auto BasicSharedString<CHAR_T>::length(void) const noexcept -> size_type
  364. {
  365. if( ! m_pStrData)
  366. {
  367. return 0;
  368. }
  369. return m_size;
  370. }
  371.  
  372. template<typename CHAR_T>
  373. auto BasicSharedString<CHAR_T>::max_size(void) const -> size_type
  374. {
  375. if( ! m_pStrData)
  376. {
  377. return 0;
  378. }
  379. return m_size;
  380. }
  381.  
  382. template<typename CHAR_T>
  383. auto BasicSharedString<CHAR_T>::capacity(void) const -> size_type
  384. {
  385. if( ! m_pStrData)
  386. {
  387. return 0;
  388. }
  389. return m_size;
  390. }
  391.  
  392. template<typename CHAR_T>
  393. template<typename ... ARGS_T>
  394. int BasicSharedString<CHAR_T>::compare(ARGS_T && ... args) const
  395. {
  396. if( ! m_pStrData)
  397. {
  398. throw std::out_of_range(smc_exceptionText);
  399. }
  400. return std::string_view(m_pStrData.get(), m_size)->compare(std::forward<ARGS_T>(args)...);
  401. }
  402.  
  403. template<typename CHAR_T>
  404. int BasicSharedString<CHAR_T>::compare(BasicSharedString const& other) const
  405. {
  406. if(size() != other.size())
  407. {
  408. return size() - other.size();
  409. }
  410. else
  411. {
  412. return traits_type::compare(data(), other.data(), size());
  413. }
  414. }
  415.  
  416. template<typename CHAR_T>
  417. template<typename ... ARGS_T>
  418. bool BasicSharedString<CHAR_T>::starts_with(ARGS_T && ... args) const
  419. {
  420. if( ! m_pStrData)
  421. {
  422. throw std::out_of_range(smc_exceptionText);
  423. }
  424. return std::string_view(m_pStrData.get(), m_size)->starts_with(std::forward<ARGS_T>(args)...);
  425. }
  426.  
  427. template<typename CHAR_T>
  428. template<typename ... ARGS_T>
  429. bool BasicSharedString<CHAR_T>::ends_with(ARGS_T && ... args) const
  430. {
  431. if( ! m_pStrData)
  432. {
  433. throw std::out_of_range(smc_exceptionText);
  434. }
  435. return std::string_view(m_pStrData.get(), m_size)->ends_with(std::forward<ARGS_T>(args)...);
  436. }
  437.  
  438. template<typename CHAR_T>
  439. auto BasicSharedString<CHAR_T>::substr(const size_type pos, const size_type count) const -> BasicSharedString
  440. {
  441. if( ! m_pStrData)
  442. {
  443. return BasicSharedString();
  444. }
  445. // TODO: Probably not worth supporting
  446. //return BasicSharedString(m_pStrData->substr(pos, count));
  447. }
  448.  
  449. template<typename CHAR_T>
  450. auto BasicSharedString<CHAR_T>::copy(pointer dest, size_type count, size_type pos) const -> size_type
  451. {
  452. if( ! m_pStrData)
  453. {
  454. throw std::out_of_range(smc_exceptionText);
  455. }
  456. return std::string_view(m_pStrData.get(), m_size)->copy(dest, count, pos);
  457. }
  458.  
  459. template<typename CHAR_T>
  460. void BasicSharedString<CHAR_T>::swap(BasicSharedString& other) noexcept(noexcept(std::declval<BasicSharedString>().m_pStrData.swap(other.m_pStrData)))
  461. {
  462. if(m_pStrData)
  463. {
  464. m_pStrData.swap(other.m_pStrData);
  465. }
  466. }
  467.  
  468. template<typename CHAR_T>
  469. template<typename ... ARGS_T>
  470. bool BasicSharedString<CHAR_T>::find(ARGS_T && ... args) const
  471. {
  472. if( ! m_pStrData)
  473. {
  474. throw std::out_of_range(smc_exceptionText);
  475. }
  476. return std::string_view(m_pStrData.get(), m_size)->find(std::forward<ARGS_T>(args)...);
  477. }
  478.  
  479. template<typename CHAR_T>
  480. template<typename ... ARGS_T>
  481. bool BasicSharedString<CHAR_T>::rfind(ARGS_T && ... args) const
  482. {
  483. if( ! m_pStrData)
  484. {
  485. throw std::out_of_range(smc_exceptionText);
  486. }
  487. return std::string_view(m_pStrData.get(), m_size)->rfind(std::forward<ARGS_T>(args)...);
  488. }
  489.  
  490. template<typename CHAR_T>
  491. template<typename ... ARGS_T>
  492. bool BasicSharedString<CHAR_T>::find_first_of(ARGS_T && ... args) const
  493. {
  494. if( ! m_pStrData)
  495. {
  496. throw std::out_of_range(smc_exceptionText);
  497. }
  498. return std::string_view(m_pStrData.get(), m_size)->find_first_of(std::forward<ARGS_T>(args)...);
  499. }
  500.  
  501. template<typename CHAR_T>
  502. template<typename ... ARGS_T>
  503. bool BasicSharedString<CHAR_T>::find_first_not_of(ARGS_T && ... args) const
  504. {
  505. if( ! m_pStrData)
  506. {
  507. throw std::out_of_range(smc_exceptionText);
  508. }
  509. return std::string_view(m_pStrData.get(), m_size)->find_first_not_of(std::forward<ARGS_T>(args)...);
  510. }
  511.  
  512. template<typename CHAR_T>
  513. template<typename ... ARGS_T>
  514. bool BasicSharedString<CHAR_T>::find_last_of(ARGS_T && ... args) const
  515. {
  516. if( ! m_pStrData)
  517. {
  518. throw std::out_of_range(smc_exceptionText);
  519. }
  520. return std::string_view(m_pStrData.get(), m_size)->find_last_of(std::forward<ARGS_T>(args)...);
  521. }
  522.  
  523. template<typename CHAR_T>
  524. template<typename ... ARGS_T>
  525. bool BasicSharedString<CHAR_T>::find_last_not_of(ARGS_T && ... args) const
  526. {
  527. if( ! m_pStrData)
  528. {
  529. throw std::out_of_range(smc_exceptionText);
  530. }
  531. return std::string_view(m_pStrData.get(), m_size)->find_last_not_of(std::forward<ARGS_T>(args)...);
  532. }
  533.  
  534. template<typename CHAR_T>
  535. bool operator==(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs)
  536. {
  537. return 0 == lhs.compare(rhs);
  538. }
  539.  
  540. template<typename CHAR_T>
  541. bool operator!=(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs)
  542. {
  543. return 0 != lhs.compare(rhs);
  544. }
  545.  
  546. template<typename CHAR_T>
  547. bool operator<(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs)
  548. {
  549. return 0 < lhs.compare(rhs);
  550. }
  551.  
  552. template<typename CHAR_T>
  553. bool operator<=(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs)
  554. {
  555. return 0 <= lhs.compare(rhs);
  556. }
  557.  
  558. template<typename CHAR_T>
  559. bool operator>(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs)
  560. {
  561. return 0 > lhs.compare(rhs);
  562. }
  563.  
  564. template<typename CHAR_T>
  565. bool operator>=(BasicSharedString<CHAR_T> const& lhs, BasicSharedString<CHAR_T> const& rhs)
  566. {
  567. return 0 >= lhs.compare(rhs);
  568. }
  569.  
  570. template<typename CHAR_T, typename OTHER_T>
  571. bool operator==(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs)
  572. {
  573. return 0 == lhs.compare(rhs);
  574. }
  575.  
  576. template<typename CHAR_T, typename OTHER_T>
  577. bool operator!=(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs)
  578. {
  579. return 0 != lhs.compare(rhs);
  580. }
  581.  
  582. template<typename CHAR_T, typename OTHER_T>
  583. bool operator<(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs)
  584. {
  585. return 0 < lhs.compare(rhs);
  586. }
  587.  
  588. template<typename CHAR_T, typename OTHER_T>
  589. bool operator<=(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs)
  590. {
  591. return 0 <= lhs.compare(rhs);
  592. }
  593.  
  594. template<typename CHAR_T, typename OTHER_T>
  595. bool operator>(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs)
  596. {
  597. return 0 > lhs.compare(rhs);
  598. }
  599.  
  600. template<typename CHAR_T, typename OTHER_T>
  601. bool operator>=(BasicSharedString<CHAR_T> const& lhs, OTHER_T const& rhs)
  602. {
  603. return 0 >= lhs.compare(rhs);
  604. }
  605.  
  606. template<typename OTHER_T, typename CHAR_T>
  607. bool operator==(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs)
  608. {
  609. return 0 == lhs.compare(rhs);
  610. }
  611.  
  612. template<typename OTHER_T, typename CHAR_T>
  613. bool operator!=(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs)
  614. {
  615. return 0 != lhs.compare(rhs);
  616. }
  617.  
  618. template<typename OTHER_T, typename CHAR_T>
  619. bool operator<(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs)
  620. {
  621. return 0 > lhs.compare(rhs);
  622. }
  623.  
  624. template<typename OTHER_T, typename CHAR_T>
  625. bool operator<=(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs)
  626. {
  627. return 0 >= lhs.compare(rhs);
  628. }
  629.  
  630. template<typename OTHER_T, typename CHAR_T>
  631. bool operator>(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs)
  632. {
  633. return 0 < lhs.compare(rhs);
  634. }
  635.  
  636. template<typename OTHER_T, typename CHAR_T>
  637. bool operator>=(OTHER_T const& lhs, BasicSharedString<CHAR_T> const& rhs)
  638. {
  639. return 0 <= lhs.compare(rhs);
  640. }
  641.  
  642. } // namespace meshpp::core
  643.  
  644. #endif // MESHPP_CORE_SHARED_STRING_H_2A0F6174_39EA_40FE_B526_9293C36939D7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement