├── .vscode └── tasks.json ├── LICENSE ├── README.md ├── docs ├── btl │ ├── autoptr │ │ ├── common.html │ │ ├── common │ │ │ ├── ControlBlock.Shared.html │ │ │ ├── ControlBlock.Weak.html │ │ │ ├── ControlBlock.hasSharedCounter.html │ │ │ ├── ControlBlock.hasWeakCounter.html │ │ │ ├── ControlBlock.html │ │ │ ├── ControlBlock.opAssign.html │ │ │ ├── ControlBlock.this.html │ │ │ ├── ControlBlockDeduction.html │ │ │ ├── DefaultAllocator.html │ │ │ ├── DestructorAllocatorType.html │ │ │ ├── DestructorDeleterType.html │ │ │ ├── DestructorType.html │ │ │ ├── Evoid.html │ │ │ ├── Forward.html │ │ │ ├── IntrusiveControlBlock.html │ │ │ ├── SharedControlBlock.html │ │ │ ├── UniqueControlBlock.html │ │ │ ├── apply.apply.html │ │ │ ├── apply.html │ │ │ ├── isControlBlock.html │ │ │ ├── isDestructorType.html │ │ │ ├── isIntrusive.html │ │ │ └── isSmartPtr.html │ │ ├── global_ptr.html │ │ ├── global_ptr │ │ │ ├── GlobalPtr.ElementReferenceType.html │ │ │ ├── GlobalPtr.ElementType.html │ │ │ ├── GlobalPtr.element.html │ │ │ ├── GlobalPtr.get.html │ │ │ ├── GlobalPtr.html │ │ │ ├── GlobalPtr.opAssign.html │ │ │ ├── GlobalPtr.opCast.html │ │ │ ├── GlobalPtr.opCmp.html │ │ │ ├── GlobalPtr.opEquals.html │ │ │ ├── GlobalPtr.opUnary.html │ │ │ ├── GlobalPtr.proxySwap.html │ │ │ ├── GlobalPtr.ptr.html │ │ │ ├── GlobalPtr.this.html │ │ │ └── isGlobalPtr.html │ │ ├── intrusive_ptr.html │ │ ├── intrusive_ptr │ │ │ ├── IntrusivePtr.ControlType.html │ │ │ ├── IntrusivePtr.DestructorType.html │ │ │ ├── IntrusivePtr.ElementReferenceType.html │ │ │ ├── IntrusivePtr.ElementType.html │ │ │ ├── IntrusivePtr.SharedType.html │ │ │ ├── IntrusivePtr.WeakType.html │ │ │ ├── IntrusivePtr.alloc.html │ │ │ ├── IntrusivePtr.compareExchangeStrong.html │ │ │ ├── IntrusivePtr.compareExchangeWeak.html │ │ │ ├── IntrusivePtr.element.html │ │ │ ├── IntrusivePtr.exchange.html │ │ │ ├── IntrusivePtr.expired.html │ │ │ ├── IntrusivePtr.get.html │ │ │ ├── IntrusivePtr.html │ │ │ ├── IntrusivePtr.isLockFree.html │ │ │ ├── IntrusivePtr.isWeak.html │ │ │ ├── IntrusivePtr.load.html │ │ │ ├── IntrusivePtr.lock.html │ │ │ ├── IntrusivePtr.make.html │ │ │ ├── IntrusivePtr.opAssign.html │ │ │ ├── IntrusivePtr.opCast.html │ │ │ ├── IntrusivePtr.opCastImpl.html │ │ │ ├── IntrusivePtr.opCmp.html │ │ │ ├── IntrusivePtr.opEquals.html │ │ │ ├── IntrusivePtr.opUnary.html │ │ │ ├── IntrusivePtr.proxySwap.html │ │ │ ├── IntrusivePtr.ptr.html │ │ │ ├── IntrusivePtr.sharedControl.html │ │ │ ├── IntrusivePtr.store.html │ │ │ ├── IntrusivePtr.this.html │ │ │ ├── IntrusivePtr.toHash.html │ │ │ ├── IntrusivePtr.useCount.html │ │ │ ├── IntrusivePtr.weak.html │ │ │ ├── IntrusivePtr.weakCount.html │ │ │ ├── dynCast.html │ │ │ ├── dynCastMove.html │ │ │ ├── intrusivePtr.html │ │ │ ├── isIntrusivePtr.html │ │ │ └── share.html │ │ ├── rc_ptr.html │ │ ├── rc_ptr │ │ │ ├── RcPtr.ControlType.html │ │ │ ├── RcPtr.DestructorType.html │ │ │ ├── RcPtr.ElementReferenceType.html │ │ │ ├── RcPtr.ElementType.html │ │ │ ├── RcPtr.SharedType.html │ │ │ ├── RcPtr.WeakType.html │ │ │ ├── RcPtr.alloc.html │ │ │ ├── RcPtr.compareExchangeStrong.html │ │ │ ├── RcPtr.compareExchangeWeak.html │ │ │ ├── RcPtr.element.html │ │ │ ├── RcPtr.exchange.html │ │ │ ├── RcPtr.expired.html │ │ │ ├── RcPtr.get.html │ │ │ ├── RcPtr.html │ │ │ ├── RcPtr.isLockFree.html │ │ │ ├── RcPtr.isWeak.html │ │ │ ├── RcPtr.length.html │ │ │ ├── RcPtr.load.html │ │ │ ├── RcPtr.lock.html │ │ │ ├── RcPtr.make.html │ │ │ ├── RcPtr.opAssign.html │ │ │ ├── RcPtr.opCast.html │ │ │ ├── RcPtr.opCastImpl.html │ │ │ ├── RcPtr.opCmp.html │ │ │ ├── RcPtr.opEquals.html │ │ │ ├── RcPtr.opUnary.html │ │ │ ├── RcPtr.proxySwap.html │ │ │ ├── RcPtr.ptr.html │ │ │ ├── RcPtr.store.html │ │ │ ├── RcPtr.this.html │ │ │ ├── RcPtr.toHash.html │ │ │ ├── RcPtr.useCount.html │ │ │ ├── RcPtr.weak.html │ │ │ ├── RcPtr.weakCount.html │ │ │ ├── dynCast.html │ │ │ ├── dynCastMove.html │ │ │ ├── first.html │ │ │ ├── isRcPtr.html │ │ │ └── share.html │ │ ├── shared_ptr.html │ │ ├── shared_ptr │ │ │ ├── SharedPtr.ControlType.html │ │ │ ├── SharedPtr.DestructorType.html │ │ │ ├── SharedPtr.ElementReferenceType.html │ │ │ ├── SharedPtr.ElementType.html │ │ │ ├── SharedPtr.SharedType.html │ │ │ ├── SharedPtr.WeakType.html │ │ │ ├── SharedPtr.alloc.html │ │ │ ├── SharedPtr.compareExchange.html │ │ │ ├── SharedPtr.compareExchangeStrong.html │ │ │ ├── SharedPtr.compareExchangeWeak.html │ │ │ ├── SharedPtr.element.html │ │ │ ├── SharedPtr.exchange.html │ │ │ ├── SharedPtr.expired.html │ │ │ ├── SharedPtr.get.html │ │ │ ├── SharedPtr.html │ │ │ ├── SharedPtr.isLockFree.html │ │ │ ├── SharedPtr.isWeak.html │ │ │ ├── SharedPtr.length.html │ │ │ ├── SharedPtr.load.html │ │ │ ├── SharedPtr.lock.html │ │ │ ├── SharedPtr.make.html │ │ │ ├── SharedPtr.opAssign.html │ │ │ ├── SharedPtr.opCast.html │ │ │ ├── SharedPtr.opCastImpl.html │ │ │ ├── SharedPtr.opCmp.html │ │ │ ├── SharedPtr.opEquals.html │ │ │ ├── SharedPtr.opUnary.html │ │ │ ├── SharedPtr.proxySwap.html │ │ │ ├── SharedPtr.ptr.html │ │ │ ├── SharedPtr.store.html │ │ │ ├── SharedPtr.this.html │ │ │ ├── SharedPtr.toHash.html │ │ │ ├── SharedPtr.useCount.html │ │ │ ├── SharedPtr.weak.html │ │ │ ├── SharedPtr.weakCount.html │ │ │ ├── WeakPtr.html │ │ │ ├── dynCast.html │ │ │ ├── dynCastMove.html │ │ │ ├── first.html │ │ │ ├── isSharedPtr.html │ │ │ ├── share.html │ │ │ └── sharedPtr.html │ │ ├── unique_ptr.html │ │ └── unique_ptr │ │ │ ├── UniquePtr.html │ │ │ ├── dynCast.html │ │ │ ├── dynCastMove.html │ │ │ ├── first.html │ │ │ ├── isUniquePtr.html │ │ │ └── share.html │ ├── list.html │ ├── list │ │ ├── DefaultAllocator.html │ │ ├── Forward.html │ │ ├── ForwardList.html │ │ ├── List.AllocatorType.html │ │ ├── List.ConstIterator.html │ │ ├── List.ElementReferenceType.html │ │ ├── List.ElementType.html │ │ ├── List.Iterator.html │ │ ├── List.allocator.html │ │ ├── List.append.html │ │ ├── List.back.html │ │ ├── List.backCopy.html │ │ ├── List.begin.html │ │ ├── List.bidirectional.html │ │ ├── List.build.html │ │ ├── List.cbegin.html │ │ ├── List.clear.html │ │ ├── List.contains.html │ │ ├── List.emplaceBack.html │ │ ├── List.emplaceFront.html │ │ ├── List.empty.html │ │ ├── List.end.html │ │ ├── List.front.html │ │ ├── List.frontCopy.html │ │ ├── List.hasStatelessAllocator.html │ │ ├── List.html │ │ ├── List.length.html │ │ ├── List.moveBack.html │ │ ├── List.moveFront.html │ │ ├── List.opAssign.html │ │ ├── List.opBinaryRight.html │ │ ├── List.opCmp.html │ │ ├── List.opDollar.html │ │ ├── List.opEquals.html │ │ ├── List.opIndex.html │ │ ├── List.opOpAssign.html │ │ ├── List.popBack.html │ │ ├── List.popFront.html │ │ ├── List.prepend.html │ │ ├── List.proxySwap.html │ │ ├── List.pushBack.html │ │ ├── List.pushFront.html │ │ ├── List.put.html │ │ ├── List.release.html │ │ ├── List.supportGC.html │ │ ├── List.this.html │ │ └── isList.html │ ├── string.html │ ├── string │ │ ├── BasicString.AllocatorType.html │ │ ├── BasicString.CharType.html │ │ ├── BasicString.allocator.html │ │ ├── BasicString.allowHeap.html │ │ ├── BasicString.append.html │ │ ├── BasicString.back.html │ │ ├── BasicString.backCodePoint.html │ │ ├── BasicString.backCodeUnit.html │ │ ├── BasicString.build.html │ │ ├── BasicString.capacity.html │ │ ├── BasicString.clear.html │ │ ├── BasicString.contains.html │ │ ├── BasicString.downsize.html │ │ ├── BasicString.empty.html │ │ ├── BasicString.erase.html │ │ ├── BasicString.front.html │ │ ├── BasicString.frontCodePoint.html │ │ ├── BasicString.frontCodeUnit.html │ │ ├── BasicString.full.html │ │ ├── BasicString.hasStatelessAllocator.html │ │ ├── BasicString.html │ │ ├── BasicString.insert.html │ │ ├── BasicString.length.html │ │ ├── BasicString.maximalCapacity.html │ │ ├── BasicString.minimalCapacity.html │ │ ├── BasicString.opAssign.html │ │ ├── BasicString.opBinary.html │ │ ├── BasicString.opBinaryRight.html │ │ ├── BasicString.opCast.html │ │ ├── BasicString.opCmp.html │ │ ├── BasicString.opDollar.html │ │ ├── BasicString.opEquals.html │ │ ├── BasicString.opIndex.html │ │ ├── BasicString.opIndexAssign.html │ │ ├── BasicString.opOpAssign.html │ │ ├── BasicString.opSlice.html │ │ ├── BasicString.popBack.html │ │ ├── BasicString.popBackCodePoint.html │ │ ├── BasicString.popBackCodeUnit.html │ │ ├── BasicString.proxySwap.html │ │ ├── BasicString.ptr.html │ │ ├── BasicString.put.html │ │ ├── BasicString.release.html │ │ ├── BasicString.replace.html │ │ ├── BasicString.reserve.html │ │ ├── BasicString.resize.html │ │ ├── BasicString.shrinkToFit.html │ │ ├── BasicString.small.html │ │ ├── BasicString.this.html │ │ ├── BasicString.toHash.html │ │ ├── BasicString.upsize.html │ │ ├── BasicString.valid.html │ │ ├── DefaultAllocator.html │ │ ├── FixedString.html │ │ ├── Forward.html │ │ ├── LargeString.html │ │ ├── SmallString.html │ │ ├── String.html │ │ └── isBasicString.html │ ├── traits │ │ ├── assume.html │ │ ├── assume │ │ │ ├── assumeNoGC.html │ │ │ ├── assumePure.html │ │ │ ├── assumePureNoGc.html │ │ │ └── assumePureNoGcNothrow.html │ │ ├── common.html │ │ ├── common │ │ │ ├── Forward.html │ │ │ ├── Unshared.html │ │ │ ├── classHasIndirections.html │ │ │ ├── instanceSize.html │ │ │ ├── isClassOrInterface.html │ │ │ ├── isRef.html │ │ │ ├── platformSupportGC.html │ │ │ └── shouldAddGCRange.html │ │ ├── range.html │ │ └── range │ │ │ ├── isBtlBidirectionalRange.html │ │ │ ├── isBtlForwardRange.html │ │ │ ├── isBtlInputRange.html │ │ │ └── isBtlRandomAccessRange.html │ ├── vector.html │ └── vector │ │ ├── DefaultAllocator.html │ │ ├── FixedVector.html │ │ ├── Forward.html │ │ ├── SmallVector.html │ │ ├── Vector.AllocatorType.html │ │ ├── Vector.ElementReferenceType.html │ │ ├── Vector.ElementType.html │ │ ├── Vector.allocator.html │ │ ├── Vector.allowHeap.html │ │ ├── Vector.append.html │ │ ├── Vector.at.html │ │ ├── Vector.atCopy.html │ │ ├── Vector.back.html │ │ ├── Vector.backCopy.html │ │ ├── Vector.begin.html │ │ ├── Vector.build.html │ │ ├── Vector.capacity.html │ │ ├── Vector.cbegin.html │ │ ├── Vector.cend.html │ │ ├── Vector.clear.html │ │ ├── Vector.contains.html │ │ ├── Vector.downsize.html │ │ ├── Vector.elements.html │ │ ├── Vector.emplace.html │ │ ├── Vector.emplaceBack.html │ │ ├── Vector.empty.html │ │ ├── Vector.end.html │ │ ├── Vector.erase.html │ │ ├── Vector.front.html │ │ ├── Vector.frontCopy.html │ │ ├── Vector.full.html │ │ ├── Vector.hasStatelessAllocator.html │ │ ├── Vector.heapSwap.html │ │ ├── Vector.html │ │ ├── Vector.insert.html │ │ ├── Vector.length.html │ │ ├── Vector.maximalCapacity.html │ │ ├── Vector.minimalCapacity.html │ │ ├── Vector.moveBack.html │ │ ├── Vector.moveFront.html │ │ ├── Vector.opAssign.html │ │ ├── Vector.opBinaryRight.html │ │ ├── Vector.opCmp.html │ │ ├── Vector.opDollar.html │ │ ├── Vector.opEquals.html │ │ ├── Vector.opIndex.html │ │ ├── Vector.opIndexAssign.html │ │ ├── Vector.opIndexOpAssign.html │ │ ├── Vector.opOpAssign.html │ │ ├── Vector.opSlice.html │ │ ├── Vector.owns.html │ │ ├── Vector.ownsElement.html │ │ ├── Vector.pop.html │ │ ├── Vector.popBack.html │ │ ├── Vector.proxySwap.html │ │ ├── Vector.ptr.html │ │ ├── Vector.put.html │ │ ├── Vector.release.html │ │ ├── Vector.replace.html │ │ ├── Vector.reserve.html │ │ ├── Vector.resize.html │ │ ├── Vector.shrinkToFit.html │ │ ├── Vector.small.html │ │ ├── Vector.supportGC.html │ │ ├── Vector.this.html │ │ ├── Vector.upsize.html │ │ ├── flat_map.html │ │ ├── flat_map │ │ ├── DefaultAllocator.html │ │ ├── FlatMap.AllocatorType.html │ │ ├── FlatMap.ElementReferenceType.html │ │ ├── FlatMap.ElementType.html │ │ ├── FlatMap.KeyType.html │ │ ├── FlatMap.ValueType.html │ │ ├── FlatMap.VectorType.html │ │ ├── FlatMap.allocator.html │ │ ├── FlatMap.allowHeap.html │ │ ├── FlatMap.at.html │ │ ├── FlatMap.atCopy.html │ │ ├── FlatMap.capacity.html │ │ ├── FlatMap.clear.html │ │ ├── FlatMap.empty.html │ │ ├── FlatMap.hasStatelessAllocator.html │ │ ├── FlatMap.heapSwap.html │ │ ├── FlatMap.html │ │ ├── FlatMap.length.html │ │ ├── FlatMap.maximalCapacity.html │ │ ├── FlatMap.minimalCapacity.html │ │ ├── FlatMap.opAssign.html │ │ ├── FlatMap.opBinaryRight.html │ │ ├── FlatMap.opCmp.html │ │ ├── FlatMap.opDollar.html │ │ ├── FlatMap.opEquals.html │ │ ├── FlatMap.opIndex.html │ │ ├── FlatMap.opIndexAssign.html │ │ ├── FlatMap.proxySwap.html │ │ ├── FlatMap.release.html │ │ ├── FlatMap.remove.html │ │ ├── FlatMap.reserve.html │ │ ├── FlatMap.shrinkToFit.html │ │ ├── FlatMap.supportGC.html │ │ ├── FlatMap.this.html │ │ ├── Forward.html │ │ └── isFlatMap.html │ │ └── isVector.html ├── file_hashes.json ├── images │ └── ddox │ │ ├── alias.png │ │ ├── class.png │ │ ├── enum.png │ │ ├── enummember.png │ │ ├── function.png │ │ ├── inherited.png │ │ ├── interface.png │ │ ├── module.png │ │ ├── package.png │ │ ├── private.png │ │ ├── property.png │ │ ├── protected.png │ │ ├── struct.png │ │ ├── template.png │ │ └── variable.png ├── index.html ├── prettify │ └── prettify.css ├── scripts │ ├── ddox.js │ └── jquery.js ├── sitemap.xml ├── styles │ └── ddox.css └── symbols.js ├── dub.json └── source └── btl ├── autoptr ├── common.d ├── generational_ptr.d ├── global_ptr.d ├── intrusive_ptr.d ├── package.d ├── rc_ptr.d ├── shared_ptr.d └── unique_ptr.d ├── internal ├── allocator.d ├── gc.d ├── mutex.d ├── test_allocator.d └── traits.d ├── lifetime └── package.d ├── list └── package.d ├── package.d ├── string ├── encoding.d ├── package.d └── storage.d ├── traits ├── assume.d ├── common.d └── range.d └── vector ├── flat_map.d ├── package.d └── storage.d /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "dub", 6 | "run": false, 7 | "cwd": "${workspaceFolder}", 8 | "compiler": "$current", 9 | "archType": "$current", 10 | "buildType": "release", 11 | "configuration": "$current", 12 | "problemMatcher": [ 13 | "$dmd" 14 | ], 15 | "group": "build", 16 | "label": "dub: Release(Build)", 17 | "detail": "release build" 18 | }, 19 | { 20 | "type": "dub", 21 | "run": true, 22 | "cwd": "${workspaceFolder}", 23 | "compiler": "$current", 24 | "archType": "$current", 25 | "buildType": "release", 26 | "configuration": "$current", 27 | "problemMatcher": [ 28 | "$dmd" 29 | ], 30 | "group": "build", 31 | "label": "dub: Release(Run)", 32 | "detail": "release run" 33 | }, 34 | 35 | { 36 | "type": "dub", 37 | "run": false, 38 | "cwd": "${workspaceFolder}", 39 | "compiler": "$current", 40 | "archType": "$current", 41 | "buildType": "debug", 42 | "configuration": "$current", 43 | "problemMatcher": [ 44 | "$dmd" 45 | ], 46 | "group": "build", 47 | "label": "dub: Debug(Build)", 48 | "detail": "debug build" 49 | }, 50 | { 51 | "type": "dub", 52 | "run": true, 53 | "cwd": "${workspaceFolder}", 54 | "compiler": "$current", 55 | "archType": "$current", 56 | "buildType": "debug", 57 | "configuration": "$current", 58 | "problemMatcher": [ 59 | "$dmd" 60 | ], 61 | "group": "build", 62 | "label": "dub: Debug(Run)", 63 | "detail": "debug run" 64 | }, 65 | 66 | { 67 | "type": "dub", 68 | "run": false, 69 | "cwd": "${workspaceFolder}", 70 | "compiler": "$current", 71 | "archType": "$current", 72 | "buildType": "unittest", 73 | "configuration": "$current", 74 | "problemMatcher": [ 75 | "$dmd" 76 | ], 77 | "group": "build", 78 | "label": "dub: Unittest(Build)", 79 | "detail": "unittest build" 80 | }, 81 | { 82 | "type": "dub", 83 | "run": true, 84 | "cwd": "${workspaceFolder}", 85 | "compiler": "$current", 86 | "archType": "$current", 87 | "buildType": "unittest", 88 | "configuration": "$current", 89 | "problemMatcher": [ 90 | "$dmd" 91 | ], 92 | "group": "build", 93 | "label": "dub: Unittest(Run)", 94 | "detail": "unittest run" 95 | } 96 | ] 97 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Basic Template Library 2 | 3 | ## About 4 | This is colection of packages: 5 | 6 | - **btl:autoptr**: smart pointers like c++ `std::shared_ptr`, `std::weak_ptr`, `std::enable_shared_from_this` and more. 7 | - [SharedPtr](https://submada.github.io/btl/btl/autoptr/shared_ptr/SharedPtr.html) reference counted pointer with support for aliasing and optional weak pointer support. 8 | - [RcPtr](https://submada.github.io/btl/btl/autoptr/rc_ptr/RcPtr.html) reference counted pointer with limited support for aliasing (but small size and lock free manipulation of pointer) and optional weak pointer support. 9 | - [IntrusivePtr](https://submada.github.io/btl/btl/autoptr/intrusive_ptr/IntrusivePtr.html) reference counted pointer with reference counting inside of managed object with limited support for aliasing (but small size and lock free manipulation of pointer) and optional weak pointer support. 10 | - [UniquePtr](https://submada.github.io/btl/btl/autoptr/unique_ptr/UniquePtr.html) non copyable owning pointer that owns and manages object through a pointer and disposes of that object when goes out of scope. 11 | - [GlobalPtr (beta)](https://submada.github.io/btl/btl/autoptr/global_ptr/GlobalPtr.html) non-owning pointer `GlobalPtr` to global data (static, gc, ...). 12 | - **btl:string** mutable string with small string optimization like c++ `std::basic_string` and `std::string` 13 | - [BasicString](https://submada.github.io/btl/btl/string/BasicString.html) Generalization of struct string with optional small string optimization for min `N` characters of type char, wchar and dchar. 14 | - [SmallString](https://submada.github.io/btl/btl/string/SmallString.html) Generalization of struct string with small string optimization for min `N` characters of type char, wchar and dchar. 15 | - [LargeString](https://submada.github.io/btl/btl/string/LargeString.html) Generalization of struct string without small string optimization for characters of type char, wchar and dchar. 16 | - [FixedString](https://submada.github.io/btl/btl/string/FixedString.html) Generalization of struct string with max `N` characters of type char, wchar and dchar. 17 | - [String](https://submada.github.io/btl/btl/string/String.html) alias to `BasicString!char`. 18 | - **btl:vector** dynamic array like c++ `std::vector` and `folly::small_vector` 19 | - [Vector](https://submada.github.io/btl/btl/vector/Vector.html) sequence container with growable capacity. 20 | - [SmallVector](https://submada.github.io/btl/btl/vector/SmallVector.html) sequence container with growable capacity that implements small buffer optimization for `N` elements. 21 | - [FixedVector](https://submada.github.io/btl/btl/vector/FixedVector.html) sequence container with max `N` elements. 22 | - **btl:list (beta)** linked list like c++ `std::list` and `std::forward_list` 23 | - [List](https://submada.github.io/btl/btl/list/List.html) sequence container - bidirectional linked list. 24 | - [ForwardList](https://submada.github.io/btl/btl/list/ForwardList.html) sequence container - single linked list. 25 | 26 | ## Documentation 27 | - https://submada.github.io/btl 28 | 29 | ## Code 30 | - https://github.com/submada/btl 31 | - https://gitlab.com/submada/btl 32 | 33 | ## Package 34 | - https://code.dlang.org/packages/btl 35 | 36 | ## History 37 | This repository was in past divided into 3 repositories: **`autoptr`**, **`small-vector`** and **`basic-string`** but they shared many internal parts so I unite them under one. 38 | -------------------------------------------------------------------------------- /docs/btl/autoptr/common/Evoid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Evoid 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Evoid

Type used as parameter for function pointer returned from DestructorType. 112 |

113 |
114 | 115 |
116 | alias Evoid 117 | = btl.lifetime.Evoid; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/autoptr/common/Forward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Forward 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Forward

Type used in forward constructors. 112 |

113 |
114 | 115 |
116 | alias Forward 117 | = Forward; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/autoptr/common/UniqueControlBlock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias UniqueControlBlock 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias UniqueControlBlock

Default ControlBlock for UniquePtr. 112 |

113 |
114 | 115 |
116 | alias UniqueControlBlock 117 | = ControlBlock!(void,void); 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/autoptr/global_ptr/isGlobalPtr.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Enum member isGlobalPtr 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Enum member isGlobalPtr

Check if type T is isGlobalPtr. 112 |

113 |
114 | 115 |
116 | enum isGlobalPtr(T) 117 | = isInstanceOf!(GlobalPtr, T); 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/autoptr/unique_ptr/first.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias first 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias first

Alias to first. 112 |

113 |
114 | 115 |
116 | alias first 117 | = btl.autoptr.rc_ptr.first; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/autoptr/unique_ptr/share.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias share 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias share

Alias to share. 112 |

113 |
114 | 115 |
116 | alias share 117 | = btl.autoptr.rc_ptr.share; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/list/Forward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Forward 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Forward

Type used in forward constructors. 112 |

113 |
114 | 115 |
116 | alias Forward 117 | = Forward; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/list/List.allocator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function List.allocator 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function List.allocator

Returns copy of allocator. 112 |

113 |
114 | 115 |
116 | CopyTypeQualifiers!(This,AllocatorType) allocator(This)() @property scope; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/list/List.begin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function List.begin 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function List.begin

112 |
113 | 114 |
115 | auto begin(This)() pure nothrow @nogc @property scope @system; 116 |
117 |
118 |
119 | 120 | 121 | 148 |
149 | 150 | -------------------------------------------------------------------------------- /docs/btl/list/List.cbegin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function List.cbegin 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function List.cbegin

112 |
113 | 114 |
115 | List.ConstIterator cbegin() const pure nothrow @nogc @property scope @system; 116 |
117 |
118 |
119 | 120 | 121 | 148 |
149 | 150 | -------------------------------------------------------------------------------- /docs/btl/list/List.opDollar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function List.opDollar 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function List.opDollar

Returns the length of the list, in terms of number of elements. 112 |

113 |
114 | 115 |
116 | size_t opDollar() const pure nothrow @nogc scope @safe; 117 |
118 |
119 |
120 |

Same as length(). 121 |

122 |
123 | 124 | 125 | 152 |
153 | 154 | -------------------------------------------------------------------------------- /docs/btl/string/BasicString.opDollar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function BasicString.opDollar 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function BasicString.opDollar

Returns the length of the string, in terms of number of characters. 112 |

113 |
114 | 115 |
116 | size_t opDollar() const pure nothrow @nogc scope @safe; 117 |
118 |
119 |
120 |

Same as length(). 121 |

122 |
123 | 124 | 125 | 152 |
153 | 154 | -------------------------------------------------------------------------------- /docs/btl/string/BasicString.small.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function BasicString.small 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function BasicString.small

Return true if string is small (Small String Optimization) 112 |

113 |
114 | 115 |
116 | bool small() const pure nothrow @nogc @property scope @safe; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/string/BasicString.toHash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function BasicString.toHash 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function BasicString.toHash

Calculates the hash value of string. 112 |

113 |
114 | 115 |
116 | size_t toHash() const pure nothrow @nogc @safe; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/string/BasicString.valid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function BasicString.valid 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function BasicString.valid

Return true if string is valid utf string. 112 |

113 |
114 | 115 |
116 | bool valid() const pure nothrow @nogc @property scope @safe; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/string/Forward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Forward 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Forward

Type used in forward constructors. 112 |

113 |
114 | 115 |
116 | alias Forward 117 | = Forward; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/string/LargeString.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias LargeString 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias LargeString

Alias to BasicString without small string optimization (N == 0). 112 |

113 |
114 | 115 |
116 | alias LargeString(Char, _Allocator) 117 | = BasicString!(Char,0,_Allocator); 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/string/SmallString.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias SmallString 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias SmallString

Alias to BasicString with forced small string optimization fot min N characters. 112 |

113 |
114 | 115 |
116 | alias SmallString(Char, ulong N, _Allocator) 117 | = BasicString!(Char,max(N,1),_Allocator); 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/string/String.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias String 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias String

Standard string type (alias to BasicString!char). 112 |

113 |
114 | 115 |
116 | alias String 117 | = BasicString!(char,1L,std.experimental.allocator.mallocator.Mallocator); 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/traits/assume/assumeNoGC.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function assumeNoGC 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function assumeNoGC

TODO 112 |

113 |
114 | 115 |
116 | auto assumeNoGC(T) 117 | ( 118 |
119 |   T fn 120 |
121 | ) @trusted; 122 |
123 |
124 |
125 | 126 | 127 | 154 |
155 | 156 | -------------------------------------------------------------------------------- /docs/btl/traits/assume/assumePure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function assumePure 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function assumePure

TODO 112 |

113 |
114 | 115 |
116 | auto assumePure(T) 117 | ( 118 |
119 |   T fn 120 |
121 | ) @trusted; 122 |
123 |
124 |
125 | 126 | 127 | 154 |
155 | 156 | -------------------------------------------------------------------------------- /docs/btl/traits/assume/assumePureNoGc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function assumePureNoGc 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function assumePureNoGc

TODO 112 |

113 |
114 | 115 |
116 | auto assumePureNoGc(T) 117 | ( 118 |
119 |   T fn 120 |
121 | ) @trusted; 122 |
123 |
124 |
125 | 126 | 127 | 154 |
155 | 156 | -------------------------------------------------------------------------------- /docs/btl/traits/assume/assumePureNoGcNothrow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function assumePureNoGcNothrow 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function assumePureNoGcNothrow

TODO 112 |

113 |
114 | 115 |
116 | auto assumePureNoGcNothrow(T) 117 | ( 118 |
119 |   T fn 120 |
121 | ) @trusted; 122 |
123 |
124 |
125 | 126 | 127 | 154 |
155 | 156 | -------------------------------------------------------------------------------- /docs/btl/traits/common/Forward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Struct Forward 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Struct Forward

Type used in forward constructors. 112 |

113 |
114 | 115 |
116 | struct Forward 117 | ; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/traits/common/Unshared.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Unshared 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Unshared

remove shared from type T. 112 |

113 |
114 | 115 |
116 | alias Unshared(T) 117 | = T; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/traits/common/platformSupportGC.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Enum member platformSupportGC 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Enum member platformSupportGC

TODO 112 |

113 |
114 | 115 |
116 | enum platformSupportGC 117 | = true; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/traits/common/shouldAddGCRange.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Enum member shouldAddGCRange 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Enum member shouldAddGCRange

TODO 112 |

113 |
114 | 115 |
116 | enum shouldAddGCRange(T) 117 | = true && platformSupportGC && hasIndirections!T; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/traits/range/isBtlInputRange.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Enum member isBtlInputRange 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Enum member isBtlInputRange

Same as std.range.isInputRange but support non copyable elements. 112 |

113 |
114 | 115 |
116 | enum isBtlInputRange(R) 117 | = impl; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/vector/Forward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Forward 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Forward

Type used in forward constructors. 112 |

113 |
114 | 115 |
116 | alias Forward 117 | = Forward; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.allocator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.allocator 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.allocator

Returns copy of allocator. 112 |

113 |
114 | 115 |
116 | CopyTypeQualifiers!(This,AllocatorType) allocator(This)() @property scope; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.begin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.begin 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.begin

112 |
113 | 114 |
115 | inout inout(Vector.ElementType)* begin() pure nothrow @nogc @property @system; 116 |
117 |
118 |
119 | 120 | 121 | 148 |
149 | 150 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.cbegin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.cbegin 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.cbegin

112 |
113 | 114 |
115 | const(Vector.ElementType)* cbegin() const pure nothrow @nogc @property @system; 116 |
117 |
118 |
119 | 120 | 121 | 148 |
149 | 150 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.cend.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.cend 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.cend

112 |
113 | 114 |
115 | const(Vector.ElementType)* cend() const pure nothrow @nogc @property @system; 116 |
117 |
118 |
119 | 120 | 121 | 148 |
149 | 150 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.end.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.end 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.end

112 |
113 | 114 |
115 | inout inout(Vector.ElementType)* end() pure nothrow @nogc @property @system; 116 |
117 |
118 |
119 | 120 | 121 | 148 |
149 | 150 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.opDollar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.opDollar 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.opDollar

Returns the length of the vector, in terms of number of elements. 112 |

113 |
114 | 115 |
116 | size_t opDollar() const pure nothrow @nogc scope @safe; 117 |
118 |
119 |
120 |

Same as length(). 121 |

122 |
123 | 124 | 125 | 152 |
153 | 154 | -------------------------------------------------------------------------------- /docs/btl/vector/Vector.small.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Vector.small 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function Vector.small

Return true if vector is small (capacity == minimalCapacity) 112 |

113 |
114 | 115 |
116 | bool small() const pure nothrow @nogc @property scope @safe; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/vector/flat_map/FlatMap.allocator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function FlatMap.allocator 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Function FlatMap.allocator

Returns copy of allocator. 112 |

113 |
114 | 115 |
116 | auto allocator(This)() @property scope; 117 |
118 |
119 |
120 | 121 | 122 | 149 |
150 | 151 | -------------------------------------------------------------------------------- /docs/btl/vector/flat_map/Forward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias Forward 6 | 7 | 8 | 9 | 10 | 11 | 110 |
111 |

Alias Forward

Type used in forward constructors. 112 |

113 |
114 | 115 |
116 | alias Forward 117 | = Forward; 118 |
119 |
120 |
121 | 122 | 123 | 150 |
151 | 152 | -------------------------------------------------------------------------------- /docs/images/ddox/alias.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/alias.png -------------------------------------------------------------------------------- /docs/images/ddox/class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/class.png -------------------------------------------------------------------------------- /docs/images/ddox/enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/enum.png -------------------------------------------------------------------------------- /docs/images/ddox/enummember.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/enummember.png -------------------------------------------------------------------------------- /docs/images/ddox/function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/function.png -------------------------------------------------------------------------------- /docs/images/ddox/inherited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/inherited.png -------------------------------------------------------------------------------- /docs/images/ddox/interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/interface.png -------------------------------------------------------------------------------- /docs/images/ddox/module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/module.png -------------------------------------------------------------------------------- /docs/images/ddox/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/package.png -------------------------------------------------------------------------------- /docs/images/ddox/private.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/private.png -------------------------------------------------------------------------------- /docs/images/ddox/property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/property.png -------------------------------------------------------------------------------- /docs/images/ddox/protected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/protected.png -------------------------------------------------------------------------------- /docs/images/ddox/struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/struct.png -------------------------------------------------------------------------------- /docs/images/ddox/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/template.png -------------------------------------------------------------------------------- /docs/images/ddox/variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/submada/btl/9cc599fd8495215d346ccd62d6e9f1f7ac140937/docs/images/ddox/variable.png -------------------------------------------------------------------------------- /docs/prettify/prettify.css: -------------------------------------------------------------------------------- 1 | /* Pretty printing styles. Used with prettify.js. */ 2 | 3 | /* SPAN elements with the classes below are added by prettyprint. */ 4 | .pln { color: #222 } /* plain text */ 5 | pre .pln, div.prototype .pln { color: #fff } /* plain text */ 6 | 7 | @media screen { 8 | pre .str { color: #ffe7b6 } /* string content */ 9 | pre .typ { color: #9ad452 } /* a type name */ 10 | pre .lit { color: #ffe7b6 } /* a literal value */ 11 | pre .pun, div.prototype .pun { color: #fff } 12 | 13 | .spc { color: #a0a } /* special token sequence */ 14 | .str { color: #842 } /* string content */ 15 | .kwd { color: #ffaa00 } /* a keyword */ 16 | .com { color: #888 } /* a comment */ 17 | .typ { color: #693 } /* a type name */ 18 | .lit { color: #875 } /* a literal value */ 19 | /* punctuation, lisp open bracket, lisp close bracket */ 20 | .pun, .opn, .clo { color: #222 } 21 | .tag { color: #ffaa00 } /* a markup tag name */ 22 | .atn { color: #9ad452 } /* a markup attribute name */ 23 | .atv { color: #ffe7b6 } /* a markup attribute value */ 24 | .dec, .var { color: #aaa } /* a declaration; a variable name */ 25 | .fun { color: red } /* a function name */ 26 | } 27 | 28 | /* Use higher contrast and text-weight for printable form. */ 29 | @media print, projection { 30 | .spc { color: #606 } /* special token sequence */ 31 | .str { color: #060 } 32 | .kwd { color: #006; font-weight: bold } 33 | .com { color: #600; font-style: italic } 34 | .typ { color: #404; font-weight: bold } 35 | .lit { color: #044 } 36 | .pun, .opn, .clo { color: #440 } 37 | .tag { color: #006; font-weight: bold } 38 | .atn { color: #404 } 39 | .atv { color: #060 } 40 | } 41 | 42 | /* Put a border around prettyprinted code snippets. */ 43 | pre.prettyprint, pre.code, div.prototype { 44 | padding: 1em 0.5em; 45 | background-color: #282822; 46 | border: 1px solid black; 47 | color: white; 48 | max-width: 100em; 49 | overflow: auto; 50 | } 51 | 52 | /* Specify class=linenums on a pre to get line numbering */ 53 | ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ 54 | li.L0, 55 | li.L1, 56 | li.L2, 57 | li.L3, 58 | li.L5, 59 | li.L6, 60 | li.L7, 61 | li.L8 { list-style-type: none } 62 | /* Alternate shading for lines */ 63 | li.L1, 64 | li.L3, 65 | li.L5, 66 | li.L7, 67 | li.L9 { background: #222222 } 68 | -------------------------------------------------------------------------------- /docs/scripts/ddox.js: -------------------------------------------------------------------------------- 1 | function setupDdox() 2 | { 3 | $(".tree-view .package").click(toggleTree); 4 | $(".tree-view .package a").click(dummy); 5 | //$(".tree-view.collapsed").children("ul").hide(); 6 | $("#symbolSearch").attr("tabindex", "1000"); 7 | } 8 | 9 | function dummy() { window.location = $(this).attr("href"); } 10 | 11 | function toggleTree() 12 | { 13 | node = $(this).parent(); 14 | node.toggleClass("collapsed"); 15 | if( node.hasClass("collapsed") ){ 16 | node.children("ul").hide(); 17 | } else { 18 | node.children("ul").show(); 19 | } 20 | return false; 21 | } 22 | 23 | var searchCounter = 0; 24 | var lastSearchString = ""; 25 | 26 | function performSymbolSearch(maxlen, maxresults) 27 | { 28 | if (maxlen === 'undefined') maxlen = 26; 29 | if (maxresults === undefined) maxresults = 40; 30 | 31 | var searchstring = $("#symbolSearch").val().toLowerCase(); 32 | 33 | if (searchstring == lastSearchString) return; 34 | lastSearchString = searchstring; 35 | 36 | var scnt = ++searchCounter; 37 | $('#symbolSearchResults').hide(); 38 | $('#symbolSearchResults').empty(); 39 | 40 | var terms = $.trim(searchstring).split(/\s+/); 41 | if (terms.length == 0 || (terms.length == 1 && terms[0].length < 2)) return; 42 | 43 | var results = []; 44 | for (i in symbols) { 45 | var sym = symbols[i]; 46 | var all_match = true; 47 | for (j in terms) 48 | if (sym.name.toLowerCase().indexOf(terms[j]) < 0) { 49 | all_match = false; 50 | break; 51 | } 52 | if (!all_match) continue; 53 | 54 | results.push(sym); 55 | } 56 | 57 | function getPrefixIndex(parts) 58 | { 59 | for (var i = parts.length-1; i >= 0; i--) 60 | for (j in terms) 61 | if (parts[i].length >= terms[j].length && parts[i].substr(0, terms[j].length) == terms[j]) 62 | return parts.length - 1 - i; 63 | return parts.length; 64 | } 65 | 66 | function compare(a, b) { 67 | // prefer non-deprecated matches 68 | var adep = a.attributes.indexOf("deprecated") >= 0; 69 | var bdep = b.attributes.indexOf("deprecated") >= 0; 70 | if (adep != bdep) return adep - bdep; 71 | 72 | // normalize the names 73 | var aname = a.name.toLowerCase(); 74 | var bname = b.name.toLowerCase(); 75 | 76 | var anameparts = aname.split("."); 77 | var bnameparts = bname.split("."); 78 | 79 | var asname = anameparts[anameparts.length-1]; 80 | var bsname = bnameparts[bnameparts.length-1]; 81 | 82 | // prefer exact matches 83 | var aexact = terms.indexOf(asname) >= 0; 84 | var bexact = terms.indexOf(bsname) >= 0; 85 | if (aexact != bexact) return bexact - aexact; 86 | 87 | // prefer prefix matches 88 | var apidx = getPrefixIndex(anameparts); 89 | var bpidx = getPrefixIndex(bnameparts); 90 | if (apidx != bpidx) return apidx - bpidx; 91 | 92 | // prefer elements with less nesting 93 | if (anameparts.length < bnameparts.length) return -1; 94 | if (anameparts.length > bnameparts.length) return 1; 95 | 96 | // prefer matches with a shorter name 97 | if (asname.length < bsname.length) return -1; 98 | if (asname.length > bsname.length) return 1; 99 | 100 | // sort the rest alphabetically 101 | if (aname < bname) return -1; 102 | if (aname > bname) return 1; 103 | return 0; 104 | } 105 | 106 | results.sort(compare); 107 | 108 | for (i = 0; i < results.length && i < maxresults; i++) { 109 | var sym = results[i]; 110 | 111 | var el = $(document.createElement("li")); 112 | el.addClass(sym.kind); 113 | for (j in sym.attributes) 114 | el.addClass(sym.attributes[j]); 115 | 116 | var name = sym.name; 117 | 118 | // compute a length limited representation of the full name 119 | var nameparts = name.split("."); 120 | var np = nameparts.length-1; 121 | var shortname = "." + nameparts[np]; 122 | while (np > 0 && nameparts[np-1].length + shortname.length <= maxlen) { 123 | np--; 124 | shortname = "." + nameparts[np] + shortname; 125 | } 126 | if (np > 0) shortname = ".." + shortname; 127 | else shortname = shortname.substr(1); 128 | 129 | el.append(''+shortname+''); 130 | $('#symbolSearchResults').append(el); 131 | } 132 | 133 | if (results.length > maxresults) { 134 | $('#symbolSearchResults').append("
  • …"+(results.length-100)+" additional results
  • "); 135 | } 136 | 137 | $('#symbolSearchResults').show(); 138 | } 139 | -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "btl", 3 | "description" : "Basic Template Library", 4 | "copyright" : "Copyright © 2022, Adam Búš", 5 | "license" : "Boost Software License - Version 1.0", 6 | "authors" : [ 7 | "Adam Búš" 8 | ], 9 | "dependencies" : { 10 | "btl:autoptr" : "*", 11 | "btl:string" : "*", 12 | "btl:vector" : "*", 13 | "btl:list" : "*", 14 | "btl:traits" : "*", 15 | "btl:lifetime" : "*" 16 | }, 17 | "sourceFiles" : [ 18 | "source/btl/package.d" 19 | ], 20 | "subPackages" : [ 21 | { 22 | "name" : "traits", 23 | "description" : "traits", 24 | "targetType" : "sourceLibrary", 25 | "importPaths" : [ 26 | "source/" 27 | ], 28 | "sourcePaths" : [ 29 | "source/btl/traits" 30 | ] 31 | }, 32 | { 33 | "name" : "lifetime", 34 | "description" : "lifetime", 35 | "targetType" : "sourceLibrary", 36 | "importPaths" : [ 37 | "source/" 38 | ], 39 | "sourcePaths" : [ 40 | "source/btl/lifetime" 41 | ] 42 | }, 43 | { 44 | "name" : "autoptr", 45 | "description" : "Smart pointers.", 46 | "targetType" : "library", 47 | "importPaths" : [ 48 | "source/" 49 | ], 50 | "sourcePaths" : [ 51 | "source/btl/autoptr", 52 | "source/btl/internal" 53 | ], 54 | "dependencies" : { 55 | "btl:traits" : "*", 56 | "btl:lifetime" : "*" 57 | }, 58 | "configurations" : [ 59 | { 60 | "name" : "default" 61 | }, 62 | { 63 | "name" : "unittest", 64 | "versions" : [ 65 | "BTL_GC_RANGE_COUNT", 66 | "BTL_GC_RANGE_TRACK", 67 | "BTL_AUTOPTR_COUNT_CONSTRUCTIONS", 68 | "BTL_AUTOPTR_COUNT_ALLOCATIONS" 69 | ] 70 | } 71 | ] 72 | }, 73 | { 74 | "name" : "string", 75 | "description" : "Mutable @nogc string struct using `std.experimental.allocator` for allocations.", 76 | "targetType" : "library", 77 | "importPaths" : [ 78 | "source/" 79 | ], 80 | "sourcePaths" : [ 81 | "source/btl/string", 82 | "source/btl/internal" 83 | ], 84 | "dependencies" : { 85 | "btl:traits" : "*" 86 | }, 87 | "configurations" : [ 88 | { 89 | "name" : "default" 90 | }, 91 | { 92 | "name" : "unittest", 93 | "versions" : [ 94 | "__BTL_BASIC_STRING_TESTS", 95 | "BTL_STRING_BOUNDS_CHECK" 96 | ] 97 | } 98 | ] 99 | }, 100 | { 101 | "name" : "vector", 102 | "description" : "Dynamic array supporting custom allcoators.", 103 | "targetType" : "sourceLibrary", 104 | "importPaths" : [ 105 | "source/" 106 | ], 107 | "sourcePaths" : [ 108 | "source/btl/vector", 109 | "source/btl/internal" 110 | ], 111 | "dependencies" : { 112 | "btl:traits" : "*", 113 | "btl:lifetime" : "*" 114 | }, 115 | "configurations" : [ 116 | { 117 | "name" : "default" 118 | }, 119 | { 120 | "name" : "unittest", 121 | "versions" : [ 122 | "BTL_GC_RANGE_COUNT", 123 | "BTL_GC_RANGE_TRACK", 124 | "BTL_VECTOR_BOUNDS_CHECK" 125 | ] 126 | } 127 | ] 128 | }, 129 | { 130 | "name" : "list", 131 | "description" : "List supporting custom allcoators.", 132 | "targetType" : "library", 133 | "importPaths" : [ 134 | "source/" 135 | ], 136 | "sourcePaths" : [ 137 | "source/btl/list", 138 | "source/btl/internal" 139 | ], 140 | "dependencies" : { 141 | "btl:traits" : "*", 142 | "btl:lifetime" : "*" 143 | }, 144 | "configurations" : [ 145 | { 146 | "name" : "default" 147 | }, 148 | { 149 | "name" : "unittest", 150 | "versions" : [ 151 | "BTL_GC_RANGE_COUNT", 152 | "BTL_GC_RANGE_TRACK" 153 | ] 154 | } 155 | ] 156 | } 157 | ], 158 | "dflags" : [ 159 | "", 160 | "" 161 | ] 162 | } 163 | -------------------------------------------------------------------------------- /source/btl/autoptr/package.d: -------------------------------------------------------------------------------- 1 | module btl.autoptr; 2 | 3 | public{ 4 | import btl.autoptr.common; 5 | import btl.autoptr.shared_ptr; 6 | import btl.autoptr.intrusive_ptr; 7 | import btl.autoptr.rc_ptr; 8 | import btl.autoptr.unique_ptr; 9 | import btl.autoptr.global_ptr; 10 | } 11 | -------------------------------------------------------------------------------- /source/btl/internal/allocator.d: -------------------------------------------------------------------------------- 1 | /* 2 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 3 | Authors: Adam Búš 4 | */ 5 | module btl.internal.allocator; 6 | 7 | 8 | public template isStatelessAllocator(T){ 9 | import std.experimental.allocator.common : stateSize; 10 | 11 | enum isStatelessAllocator = (stateSize!T == 0); 12 | } 13 | 14 | //alias to stateless allocator instance 15 | public template statelessAllcoator(T){ 16 | import std.experimental.allocator.common : stateSize; 17 | import std.traits : hasStaticMember; 18 | 19 | static assert(isStatelessAllocator!T); 20 | 21 | static if(hasStaticMember!(T, "instance")) 22 | alias statelessAllcoator = T.instance; 23 | else 24 | enum T statelessAllcoator = T.init; 25 | } 26 | 27 | 28 | //NullAllocator: 29 | version(D_BetterC){ 30 | public struct NullAllocator{ 31 | import std.experimental.allocator.common : platformAlignment; 32 | 33 | enum uint alignment = platformAlignment; 34 | 35 | static void[] allocate(size_t bytes)@trusted @nogc nothrow pure{ 36 | return null; 37 | } 38 | 39 | static bool deallocate(void[] b)@system @nogc nothrow pure{ 40 | return false; 41 | } 42 | 43 | static bool reallocate(ref void[] b, size_t s)@system @nogc nothrow pure{ 44 | return false; 45 | } 46 | 47 | static NullAllocator instance; 48 | } 49 | } 50 | else{ 51 | public import std.experimental.allocator.building_blocks.null_allocator : NullAllocator; 52 | } 53 | 54 | //Mallocator: 55 | version(D_BetterC){ 56 | public struct Mallocator{ 57 | import std.experimental.allocator.common : platformAlignment; 58 | 59 | enum uint alignment = platformAlignment; 60 | 61 | static void[] allocate(size_t bytes)@trusted @nogc nothrow pure{ 62 | import core.memory : pureMalloc; 63 | if (!bytes) return null; 64 | auto p = pureMalloc(bytes); 65 | return p ? p[0 .. bytes] : null; 66 | } 67 | 68 | static bool deallocate(void[] b)@system @nogc nothrow pure{ 69 | import core.memory : pureFree; 70 | pureFree(b.ptr); 71 | return true; 72 | } 73 | 74 | static bool reallocate(ref void[] b, size_t s)@system @nogc nothrow pure{ 75 | import core.memory : pureRealloc; 76 | if (!s){ 77 | // fuzzy area in the C standard, see http://goo.gl/ZpWeSE 78 | // so just deallocate and nullify the pointer 79 | deallocate(b); 80 | b = null; 81 | return true; 82 | } 83 | 84 | auto p = cast(ubyte*) pureRealloc(b.ptr, s); 85 | if (!p) return false; 86 | b = p[0 .. s]; 87 | return true; 88 | } 89 | 90 | static Mallocator instance; 91 | } 92 | } 93 | else{ 94 | public import std.experimental.allocator.mallocator : Mallocator; 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /source/btl/internal/gc.d: -------------------------------------------------------------------------------- 1 | /* 2 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 3 | Authors: Adam Búš 4 | */ 5 | module btl.internal.gc; 6 | 7 | 8 | 9 | 10 | version(D_BetterC){ 11 | } 12 | else{ 13 | version(BTL_GC_RANGE_COUNT) 14 | public __gshared int _conter_gc_ranges = 0; 15 | 16 | 17 | version(BTL_GC_RANGE_TRACK) 18 | package __gshared const(void)[][] _gc_ranges = null; 19 | 20 | 21 | shared static ~this(){ 22 | version(BTL_GC_RANGE_COUNT){ 23 | import std.conv; 24 | if(_conter_gc_ranges != 0) 25 | assert(0, "BTL_GC_RANGE_COUNT: " ~ _conter_gc_ranges.to!string ~ " != 0"); 26 | } 27 | 28 | 29 | version(BTL_GC_RANGE_TRACK){ 30 | foreach(const(void)[] gcr; _gc_ranges) 31 | assert(gcr.length == 0); 32 | } 33 | } 34 | } 35 | 36 | //same as GC.addRange but `pure nothrow @trusted @nogc` and with debug testing 37 | public void gcAddRange(T)(const T[] data)pure nothrow @trusted @nogc{ 38 | gcAddRange(data.ptr, data.length * T.sizeof); 39 | } 40 | public void gcAddRange(const void* data, const size_t length)pure nothrow @trusted @nogc{ 41 | version(D_BetterC){ 42 | } 43 | else{ 44 | import btl.traits.assume; 45 | 46 | assumePure(function void(const void* ptr, const size_t len){ 47 | import core.memory: GC; 48 | GC.addRange(ptr, len); 49 | })(data, length); 50 | 51 | 52 | assert(data !is null); 53 | assert(length > 0); 54 | 55 | assumePureNoGc(function void(const void* data, const size_t length)@trusted{ 56 | version(BTL_GC_RANGE_COUNT){ 57 | import core.atomic; 58 | atomicFetchAdd!(MemoryOrder.raw)(_conter_gc_ranges, 1); 59 | } 60 | 61 | 62 | 63 | version(BTL_GC_RANGE_TRACK){ 64 | foreach(const void[] gcr; _gc_ranges){ 65 | if(gcr.length == 0) 66 | continue; 67 | 68 | const void* gcr_end = (gcr.ptr + gcr.length); 69 | assert(!(data <= gcr.ptr && gcr.ptr < (data + length))); 70 | assert(!(data < gcr_end && gcr_end <= (data + length))); 71 | assert(!(gcr.ptr <= data && (data + length) <= gcr_end)); 72 | } 73 | 74 | foreach(ref const(void)[] gcr; _gc_ranges){ 75 | if(gcr.length == 0){ 76 | gcr = data[0 .. length]; 77 | return; 78 | } 79 | } 80 | 81 | _gc_ranges ~= data[0 .. length]; 82 | 83 | } 84 | 85 | })(data, length); 86 | } 87 | } 88 | 89 | //same as GC.removeRange but `pure nothrow @trusted @nogc` and with debug testing 90 | public void gcRemoveRange(T)(const T[] data)pure nothrow @trusted @nogc{ 91 | gcRemoveRange(data.ptr); 92 | } 93 | 94 | public void gcRemoveRange(const void* data)pure nothrow @trusted @nogc{ 95 | version(D_BetterC){ 96 | } 97 | else{ 98 | import btl.traits.assume; 99 | 100 | assumePure(function void(const void* ptr){ 101 | import core.memory: GC; 102 | GC.removeRange(ptr); 103 | })(data); 104 | 105 | assert(data !is null); 106 | 107 | assumePure(function void(const void* data)@trusted{ 108 | version(BTL_GC_RANGE_COUNT){ 109 | import core.atomic; 110 | atomicFetchSub!(MemoryOrder.raw)(_conter_gc_ranges, 1); 111 | } 112 | 113 | version(BTL_GC_RANGE_TRACK){ 114 | foreach(ref const(void)[] gcr; _gc_ranges){ 115 | if(gcr.ptr is data){ 116 | gcr = null; 117 | return; 118 | } 119 | const void* gcr_end = (gcr.ptr + gcr.length); 120 | assert(!(gcr.ptr <= data && data < gcr_end)); 121 | } 122 | 123 | assert(0, "BTL_GC_RANGE_TRACK: missing gc range"); 124 | } 125 | })(data); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /source/btl/internal/test_allocator.d: -------------------------------------------------------------------------------- 1 | /* 2 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 3 | Authors: Adam Búš 4 | */ 5 | module btl.internal.test_allocator; 6 | 7 | import std.experimental.allocator.common : platformAlignment, stateSize; 8 | 9 | import btl.traits.assume; 10 | struct TestAllocator{ 11 | static assert(stateSize!TestAllocator > 0); 12 | 13 | public enum uint alignment = platformAlignment; 14 | 15 | private static long static_count = 0; 16 | private long count = 0; 17 | 18 | private void increment()pure @safe @nogc nothrow{ 19 | 20 | assumePure(function void(){ 21 | static_count += 1; 22 | })(); 23 | 24 | count += 1; 25 | } 26 | 27 | private void decrement()pure @safe @nogc nothrow{ 28 | assumePure(function void(){ 29 | static_count -= 1; 30 | })(); 31 | count -= 1; 32 | } 33 | 34 | 35 | public long get_static_count()scope const nothrow @safe @nogc{ 36 | return static_count; 37 | } 38 | public long get_count()scope const pure nothrow @safe @nogc{ 39 | return count; 40 | } 41 | 42 | public void[] allocate(size_t bytes)pure @trusted @nogc nothrow{ 43 | import core.memory : pureMalloc; 44 | if (!bytes) return null; 45 | auto p = pureMalloc(bytes); 46 | 47 | if(p){ 48 | this.increment(); 49 | return p[0 .. bytes]; 50 | } 51 | return null; 52 | } 53 | 54 | public bool deallocate(void[] b)pure @system @nogc nothrow{ 55 | import core.memory : pureFree; 56 | pureFree(b.ptr); 57 | this.decrement(); 58 | return true; 59 | } 60 | 61 | public bool reallocate(ref void[] b, size_t s)pure @system @nogc nothrow{ 62 | import core.memory : pureRealloc; 63 | if (!s){ 64 | // fuzzy area in the C standard, see http://goo.gl/ZpWeSE 65 | // so just deallocate and nullify the pointer 66 | deallocate(b); 67 | b = null; 68 | return true; 69 | } 70 | 71 | auto p = cast(ubyte*) pureRealloc(b.ptr, s); 72 | if (!p) return false; 73 | b = p[0 .. s]; 74 | return true; 75 | } 76 | 77 | //static TestAllocator instance; 78 | 79 | } 80 | -------------------------------------------------------------------------------- /source/btl/internal/traits.d: -------------------------------------------------------------------------------- 1 | /* 2 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 3 | Authors: Adam Búš 4 | */ 5 | module btl.internal.traits; 6 | 7 | import std.traits : isSomeChar, isArray; 8 | import std.range : ElementEncodingType, isInputRange; 9 | 10 | 11 | 12 | public enum isCharArray(T) = true 13 | && is(T : C[N], C, size_t N) 14 | && isSomeChar!C; 15 | 16 | public template isInputCharRange(T){ 17 | 18 | enum bool isInputCharRange = true 19 | && isSomeChar!(ElementEncodingType!T) 20 | && (isInputRange!T || isArray!T); 21 | } 22 | 23 | 24 | //min/max: 25 | version(D_BetterC){ 26 | 27 | public auto min(A, B)(auto ref A a, auto ref B b){ 28 | return (a < b) 29 | ? a 30 | : b; 31 | } 32 | public auto max(A, B)(auto ref A a, auto ref B b){ 33 | return (a > b) 34 | ? a 35 | : b; 36 | } 37 | } 38 | else{ 39 | public import std.algorithm.comparison : min, max; 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /source/btl/package.d: -------------------------------------------------------------------------------- 1 | module btl; 2 | -------------------------------------------------------------------------------- /source/btl/traits/assume.d: -------------------------------------------------------------------------------- 1 | /** 2 | TODO 3 | 4 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 5 | Authors: Adam Búš 6 | */ 7 | module btl.traits.assume; 8 | 9 | import std.traits : isFunctionPointer, isDelegate; 10 | 11 | 12 | 13 | /** 14 | TODO 15 | */ 16 | public auto assumeNoGC(T)(T fn)@trusted 17 | in(isFunctionPointer!T || isDelegate!T){ 18 | import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage; 19 | 20 | enum attrs = functionAttributes!T | FunctionAttribute.nogc; 21 | return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn; 22 | } 23 | 24 | 25 | 26 | /** 27 | TODO 28 | */ 29 | public auto assumePure(T)(T fn)@trusted 30 | in(isFunctionPointer!T || isDelegate!T){ 31 | import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage; 32 | 33 | enum attrs = functionAttributes!T | FunctionAttribute.pure_; 34 | return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn; 35 | } 36 | 37 | 38 | 39 | /** 40 | TODO 41 | */ 42 | public auto assumePureNoGc(T)(T fn)@trusted 43 | in(isFunctionPointer!T || isDelegate!T){ 44 | import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage; 45 | 46 | enum attrs = functionAttributes!T | FunctionAttribute.pure_ | FunctionAttribute.nogc; 47 | return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn; 48 | } 49 | 50 | 51 | 52 | /** 53 | TODO 54 | */ 55 | public auto assumePureNoGcNothrow(T)(T fn)@trusted 56 | in(isFunctionPointer!T || isDelegate!T){ 57 | import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage; 58 | 59 | enum attrs = functionAttributes!T | FunctionAttribute.pure_ | FunctionAttribute.nogc | FunctionAttribute.nothrow_; 60 | return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /source/btl/traits/common.d: -------------------------------------------------------------------------------- 1 | /** 2 | TODO 3 | 4 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 5 | Authors: Adam Búš 6 | */ 7 | module btl.traits.common; 8 | 9 | import std.traits : isSomeChar, isArray; 10 | 11 | 12 | 13 | /** 14 | Type used in forward constructors. 15 | */ 16 | public struct Forward{} 17 | 18 | 19 | 20 | /** 21 | same as `__traits(isRef, var)`. 22 | */ 23 | public enum bool isRef(alias var) = __traits(isRef, var); 24 | 25 | 26 | 27 | /** 28 | TODO 29 | */ 30 | version(D_BetterC){ 31 | public enum bool platformSupportGC = false; 32 | } 33 | else{ 34 | public enum bool platformSupportGC = true; 35 | } 36 | 37 | 38 | 39 | /** 40 | TODO 41 | */ 42 | template shouldAddGCRange(T){ 43 | import std.traits; 44 | 45 | enum shouldAddGCRange = true 46 | && platformSupportGC 47 | && hasIndirections!T; 48 | } 49 | 50 | 51 | 52 | /** 53 | remove `shared` from type `T`. 54 | */ 55 | public alias Unshared(T) = T; 56 | public alias Unshared(T: shared U, U) = U; 57 | 58 | 59 | 60 | /** 61 | Same as `std.traits.hasIndirections` but for classes. 62 | */ 63 | public template classHasIndirections(T){ 64 | import std.traits : hasIndirections; 65 | 66 | static if(is(T == class)){ 67 | enum bool classHasIndirections = (){ 68 | 69 | import std.traits : BaseClassesTuple; 70 | import std.meta : AliasSeq; 71 | 72 | bool has_indirection = false; 73 | 74 | static foreach (alias B; AliasSeq!(T, BaseClassesTuple!T)) { 75 | static foreach(alias Var; typeof(B.init.tupleof)){ 76 | static if(hasIndirections!Var) 77 | has_indirection = true; 78 | } 79 | } 80 | 81 | return has_indirection; 82 | }(); 83 | } 84 | else{ 85 | enum bool classHasIndirections = false; 86 | } 87 | } 88 | 89 | 90 | //alias to `T` if `T` is class or interface, otherwise `T*`. 91 | /+public template PtrOrRef(T){ 92 | static if(is(T == class) || is(T == interface)) 93 | alias PtrOrRef = T; 94 | else 95 | alias PtrOrRef = T*; 96 | }+/ 97 | 98 | 99 | /** 100 | `true` if `T` is class or interface. 101 | */ 102 | public enum bool isClassOrInterface(T) = is(T == class) || is(T == interface); 103 | 104 | 105 | 106 | /** 107 | Size of instance, if `T` is class then `__traits(classInstanceSize, T)`, otherwise `T.sizeof` 108 | */ 109 | public template instanceSize(T){ 110 | static if(is(T == class)) 111 | enum size_t instanceSize = __traits(classInstanceSize, T); 112 | else 113 | enum size_t instanceSize = T.sizeof; 114 | } 115 | 116 | 117 | /* 118 | [Copy, Move] ConstructableElement: 119 | */ 120 | template isCopyConstructableElement(From, To = From){ 121 | enum isCopyConstructableElement = true 122 | && is(typeof((ref From from){ 123 | To tmp = from; 124 | })); 125 | } 126 | 127 | // ditto 128 | template isMoveConstructableElement(From, To = From){ 129 | import core.lifetime : move; 130 | enum isMoveConstructableElement = true 131 | && is(typeof((From from){ 132 | To tmp = move(from); 133 | })); 134 | } 135 | 136 | 137 | 138 | /* 139 | [Copy, Move] AssignableElement: 140 | */ 141 | template isCopyAssignableElement(From, To = From){ 142 | enum isCopyAssignableElement = true 143 | && is(typeof((ref From from, ref To to){ 144 | to = from; 145 | })); 146 | } 147 | 148 | // ditto 149 | template isMoveAssignableElement(From, To = From){ 150 | import core.lifetime : move; 151 | enum isMoveAssignableElement = true 152 | && is(typeof((From from, ref To to){ 153 | to = move(from); 154 | })); 155 | } 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /source/btl/traits/range.d: -------------------------------------------------------------------------------- 1 | /** 2 | Ranges with non copyable elements. 3 | 4 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 5 | Authors: Adam Búš 6 | */ 7 | module btl.traits.range; 8 | 9 | import std.traits : ReturnType, isAutodecodableString, isAggregateType, lvalueOf; 10 | import std.range : empty, popFront, front, popBack, back, save, 11 | isInputRange, ElementType, hasLength, isInfinite; 12 | 13 | 14 | 15 | 16 | /** 17 | Same as std.range.isInputRange but support non copyable elements. 18 | */ 19 | public template isBtlInputRange(R){ 20 | static if(isInputRange!R) 21 | enum bool impl = true; 22 | else{ 23 | static ref front_check(R)(R r){ 24 | return r.front; 25 | } 26 | enum bool impl = true 27 | && is(typeof(R.init) == R) 28 | && is(ReturnType!((R r) => r.empty) == bool) 29 | && is(typeof(*(return ref R r)@trusted => &r.front)) 30 | && !is(ReturnType!(front_check!R) == void) 31 | && is(typeof((R r) => r.popFront)); 32 | } 33 | 34 | enum bool isBtlInputRange = impl; 35 | }; 36 | 37 | 38 | 39 | /** 40 | Same as std.range.isForwardRange but support non copyable elements. 41 | */ 42 | public enum bool isBtlForwardRange(R) = isBtlInputRange!R 43 | && is(ReturnType!((R r) => r.save) == R); 44 | 45 | 46 | 47 | /** 48 | Same as std.range.isBidirectionalRange but support non copyable elements. 49 | */ 50 | public enum bool isBtlBidirectionalRange(R) = isBtlForwardRange!R 51 | && is(typeof((R r) => r.popBack)) 52 | && is(ReturnType!((R r) => r.back) == ElementType!R); 53 | 54 | 55 | 56 | /** 57 | Same as std.range.isRandomAccessRange but support non copyable elements. 58 | */ 59 | public enum bool isBtlRandomAccessRange(R) = 60 | is(typeof(lvalueOf!R[1]) == ElementType!R) 61 | && !(isAutodecodableString!R && !isAggregateType!R) 62 | && isBtlForwardRange!R 63 | && (isBtlBidirectionalRange!R || isInfinite!R) 64 | && (hasLength!R || isInfinite!R) 65 | && (isInfinite!R || !is(typeof(lvalueOf!R[$ - 1])) 66 | || is(typeof(lvalueOf!R[$ - 1]) == ElementType!R)); 67 | 68 | --------------------------------------------------------------------------------