Commit graph

347 commits

Author SHA1 Message Date
Matt Kline
f6994ea02f Improve std.typecons.Unique
Whenever D is brought up to the general programming public,
the garbage collector is quickly raised as a point of contention.
Regardless of how legitimate or well-informed these concerns are,
it would be a massive public relations boon --- and great for the language,
to boot --- if we could trot out a solid said of RAII-based smart pointers
for those who prefer to use them. We have a solid start in
std.typecons.Unique and std.typecons.RefCounted.
Unfortunately, these classes seem to be victims of bit rot and
compiler bugs of days long gone.

An overview of the changes in this commit is as follows:

- Unique's underlying data now uses malloc and free
  instead of the garbage collector. Given that many people use RAII
  smart pointers to escape the GC, it seems to make more sense to
  avoid it here. On a related note, isn't delete deprecated?
  The current destructor uses it.

- std.algorithm.move is used instead of a special release
  member function. Whether by design or by happy accident,
  move transfers ownership between Unique pointers in a very
  similar manner to C++'s std::move with std::unique_ptr.
  Along with being a familiar paradigm to C++ users,
  using move to transfer ownership makes more intuitive sense
  and builds consistency with the rest of Phobos.

- With std.algorithm.move transferring ownership, release now just
  frees the underlying pointer and nulls the Unique.

- Unique.create is no longer compiled out using version(None).
  Regardless of whether or not there is language support for
  checking uniqueness, a utility function that creates a Unique,
  taking the same arguments as the underlying type's constructor,
  is extremely useful, as demonstrated by the addition of
  make_unique to C++14.

- Because Unique.create is now in place and Unique is backed with
  malloc, constructors taking a pointer have been removed.
  This encourages the use of create as the idiomatic,
  consistent method to, well, create Unique objects.
  If one can only get a Unique by calling create or moving another
  into it, we also ensures uniqueness in one fell swoop.

- A new method, get, returns the underlying pointer, for use in
  functions and code that do not play a role in the life cycle
  of the object. Smart pointers are as much about ownership
  semantics as they are about allocating and freeing memory,
  and non-owning code should continue to refer to data using a raw
  pointer or a reference.
2015-04-02 01:17:40 -07:00
H. S. Teoh
20e62954d3 Merge pull request #3100 from MetaLang/proxy-doc-fixes
Improve documentation for std.typecons.Proxy
2015-03-27 10:09:43 -07:00
Robert Schadek
9e4dcb0a01 Merge pull request #3101 from MetaLang/tuple-doc-more-fixes
Further improvements for Tuple's documentation
2015-03-26 21:17:28 +01:00
MetaLang
749cc5ca51 Further improvements for Tuple's documentation 2015-03-26 15:54:05 -03:00
H. S. Teoh
bcf0fcecac Merge pull request #3102 from MetaLang/rebindable-add-params
Improve Rebindable documentation
2015-03-25 17:29:19 -07:00
H. S. Teoh
ccccf0f8cf Merge pull request #3104 from MetaLang/alignforsize-doc-fixes
Improve alignForSize Documentation
2015-03-25 16:30:36 -07:00
MetaLang
71a074d5cb Add Params section to UnqualRef documentation 2015-03-24 21:18:05 -03:00
MetaLang
c67867360d Improve documentation for std.typecons.Proxy 2015-03-24 21:06:42 -03:00
MetaLang
a75afe241d Improve alignForSize Documentation 2015-03-24 06:49:02 -03:00
MetaLang
65921b7739 Improve Rebindable documentation 2015-03-24 06:36:34 -03:00
MetaLang
82797e7a15 Improved std.typecons.Tuple documentation.
- Fix various typos
	- Add examples
    - Move old examples to documented unit tests
	- Document certain behaviours (such as how tuples are compared)
2015-03-20 19:08:44 -03:00
k-hara
6a8345bbc6 fix Issue 14213 - Strange deprecated message in std.typecons.Proxy with using method 2015-03-07 11:20:25 +09:00
H. S. Teoh
32ca6fb720 forward() has moved to std.functional. 2015-02-16 12:12:45 -08:00
Jakob Ovrum
96f682aba2 Reject instantiating RefCounted with interface types 2015-02-11 12:46:35 +09:00
Martin Nowak
06fd47ffec fix Issue 14106 - sort is unsafe in debug mode
- need attribute inference to toString delegate
2015-02-02 22:39:13 +01:00
Andrei Alexandrescu
71e3ecf680 Merge pull request #2934 from WalterBright/dip25
DIP25: make phobos work with it
2015-01-30 13:59:37 -08:00
Walter Bright
dc302d26a4 DIP25: make phobos work with it 2015-01-30 12:02:48 -08:00
Robert burner Schadek
5f633b7e82 typecons documentation update
* moved examples into unittests
2015-01-29 22:38:59 +01:00
Peter Alexander
052c50d3cb Fix Issue 13781 - Tuple assign should be @nogc 2014-12-31 19:23:35 +00:00
ZombineDev
1e803e65f6 Fix typo in BitFlags unit test. 2014-12-18 16:39:18 +02:00
Peter Alexander
d1ffb938b5 Fix Issue 10104 - Group of array of const/immutable 2014-12-15 20:22:07 +00:00
H. S. Teoh
ecd25fdd26 Merge pull request #2058 from lultimouomo/flags
Add Flags template
2014-12-13 13:05:39 -08:00
Luca Niccoli
ec9965d656 Add BitFlags template
BitFlags is a typecons template for storing OR combinaton of enum
values in a type safe fashion.
2014-12-10 10:13:26 +01:00
Peter Alexander
3d8838060f Issue 13837 - Allow names for tuple 2014-12-09 22:42:39 +00:00
Igor Stepanov
74e8a95c2c allow casting Typedef to another Typedef 2014-12-02 19:01:19 +03:00
Hara Kenji
06ac5031b1 Merge pull request #2740 from garlic-flavor/master
std.typecons.Proxy inside classes
2014-11-25 00:01:08 +09:00
garlic-flavor
e5269c8533 specialization of std.typecons.Proxy for classes
using selective import

remove nonsense code

integration of static this.

add a comment

avoiding some warnings

remove InvalidTypeException

improve readability
2014-11-24 03:26:08 +09:00
Ilya Yaroshenko
2c744b54e1 std.range: constraints => primitives
See discussion and voting in #2661
2014-11-23 20:05:20 +03:00
k-hara
8248c6b1e8 fix property enforcement 2014-11-22 01:50:41 +09:00
David Nadlinger
7e80e67630 Merge pull request #2728 from 9il/typecons
std.typecons: remake toString to template, clean module imports
2014-11-20 22:11:54 +01:00
Ilya Yaroshenko
af02101ab9 std.typecons: remake toString to template, clean module imports
update datetime unittests
2014-11-20 23:08:33 +03:00
Lars T. Kyllingstad
96583fe46b isNaN() is not a property
...so it shouldn't be used as one.
2014-11-20 20:22:00 +01:00
k-hara
b80083f198 fix property enforcement 2014-11-20 22:37:57 +09:00
H. S. Teoh
512b0ab382 Document new idiom for using Flag. 2014-11-19 07:59:54 -08:00
Ilya Yaroshenko
efb880f651 move format to std.format
The reason is to do not import `std.uni` tables, `std.string` and
probably `std.algorithm`. Note that format is used in CTFE code and
`Exception` handing.

 And it is more comfortable to import `format` from `std.format`.

std.format: clean imports (2)

remove import std.math : pow from std.uni

update scope imports in std.algorithm

update scope imports in std.exception

doFormat -> template

update scope imports in std.typecons

update scope imports in std.functional

update scope imports in std.range

update std.conv scope import

std.format: clean imports (2)

remove import std.math : pow from std.uni

update scope imports in std.algorithm

update scope imports in std.exception

doFormat -> template

update scope imports in std.typecons

update scope imports in std.functional

update scope imports in std.range

move sfromat

add public import of sformat

use std.uni
2014-11-18 22:14:28 +03:00
garlic-flavor
31f39c0158 a bug was removed. 2014-11-16 00:40:10 +09:00
garlic-flavor
67571fccde Merge https://github.com/D-Programming-Language/phobos 2014-11-15 23:44:49 +09:00
Geod24
10d59acfed Remove private staticFilter from AutoImplement and use std.typetuple.Filter instead 2014-11-09 21:47:15 +01:00
garlic-flavor
7cd3f18573 some update 2014-11-04 03:38:47 +09:00
Dmitry Olshansky
2e58214d1d Merge pull request #2587 from MetaLang/nullable-tostring
Fix Issue 10915 - std.typecons.Nullable throws in writeln() if it's null
2014-10-31 22:03:05 +03:00
MetaLang
2c8fdeb0b0 Fix Issue 10915 - std.typecons.Nullable throws in writeln() if it's null 2014-10-11 21:06:15 -03:00
Robert burner Schadek
4c83493a21 typecons had some trailing whitespace 2014-10-10 14:12:40 +02:00
garlic-flavor
6a3827c042 add unittest for Typedef.toHash 2014-10-10 03:03:10 +09:00
garlic-flavor
172442e374 add unittest for Typedef.toHash 2014-10-10 03:00:41 +09:00
garlic-flavor
1ac1c5f547 add toHash() to Typedef 2014-10-05 00:17:36 +09:00
k-hara
6e54969188 Move prefix member function attributes to postfix 2014-10-04 22:27:14 +09:00
Ferdinand Majerech
886c536cdc (trivial) (ddoc) more descriptive Typedef doc.
Based on Andrei Alexandrescu's post: http://forum.dlang.org/post/lvj17a$78k$1@digitalmars.com

`MoneyEuros` makes use of the cookie more obvious than `TypeFloat1`.
2014-09-20 12:12:12 +02:00
Andrej Mitrovic
f9048c94ef Fix Issue 11706 - Add a TypedefType trait to extract the underlying type
of a std.typecons.Typedef.
2014-09-08 11:47:45 +02:00
H. S. Teoh
3dda37428f Merge pull request #2342 from Dicebot/ref-unqual
Fix issue 10165 (rework of PR #1302)
2014-09-04 11:46:57 -07:00
monarch dodra
6ef6dbef22 Merge pull request #2463 from schuetzm/fix-proxy-traits-isarray
std.typecons.Proxy needs to import std.traits.isArray
2014-08-28 17:37:33 +02:00