Changeset 614b07e in mainline
- Timestamp:
- 2018-07-05T21:41:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bdc981b
- Parents:
- c866a83
- git-author:
- Dzejrou <dzejrou@…> (2018-05-05 17:19:00)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
- Location:
- uspace/lib/cpp/include
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/iterator.hpp
rc866a83 r614b07e 32 32 #include <cstdlib> 33 33 #include <initializer_list> 34 #include <internal/memory/addressof.hpp> 34 35 #include <iosfwd> 35 #include <memory>36 36 #include <type_traits> 37 37 #include <utility> -
uspace/lib/cpp/include/impl/memory.hpp
rc866a83 r614b07e 31 31 32 32 #include <internal/aux.hpp> 33 #include <internal/memory/addressof.hpp> 34 #include <iterator> 33 35 #include <new> 34 36 #include <type_traits> … … 398 400 */ 399 401 400 // TODO: implement 402 template<class OutputIterator, class T> 403 class raw_storage_iterator: public iterator<output_iterator_tag, void, void, void, void> 404 { 405 public: 406 explicit raw_storage_iterator(OutputIterator it) 407 : it_{it} 408 { /* DUMMY BODY */ } 409 410 raw_storage_iterator& operator*() 411 { 412 return *this; 413 } 414 415 raw_storage_iterator& operator=(const T& element) 416 { 417 new(it_) T{element}; 418 419 return *this; 420 } 421 422 raw_storage_iterator& operator++() 423 { 424 ++it_; 425 426 return *this; 427 } 428 429 raw_storage_iterator operator++(int) 430 { 431 return raw_storage_iterator{it_++}; 432 } 433 434 private: 435 OutputIterator it_; 436 }; 401 437 402 438 /** … … 404 440 */ 405 441 406 // TODO: implement 442 template<class T> 443 pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept 444 { 445 T* res{}; 446 447 while (n > 0) 448 { 449 res = (T*)malloc(n * sizeof(T)); 450 451 if (res) 452 return make_pair(res, n); 453 454 --n; 455 } 456 457 return make_pair(nullptr, ptrdiff_t{}); 458 } 459 460 template<class T> 461 void return_temporary_buffer(T* ptr) 462 { 463 free(ptr); 464 } 407 465 408 466 /** 409 467 * 20.7.12, specialized algorithms: 410 468 */ 411 412 template<class T>413 T* addressof(T& x) noexcept414 {415 return reinterpret_cast<T*>(416 &const_cast<char&>(417 reinterpret_cast<const volatile char&>(x)418 ));419 }420 469 421 470 template<class Iterator> -
uspace/lib/cpp/include/memory
rc866a83 r614b07e 28 28 29 29 #include <impl/memory.hpp> 30 #include <internal/memory/addressof.hpp>
Note:
See TracChangeset
for help on using the changeset viewer.