View source code
							
							
						
								Display the source code in std/bitmanip.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Function std.bitmanip.write
Takes an integral value, converts it to the given endianness, and writes it
    to the given range of ubytes as a sequence of T ubytes
    starting at index. hasSlicing!R must be true.
						
				void write(T, Endian endianness = Endian
				  R range,
				
				  const T value,
				
				  size_t index
				
				)
				
				if (canSwapEndianness!T && isForwardRange!R && hasSlicing!R && is(ElementType!R : ubyte));
				
				
				void write(T, Endian endianness = Endian
				  R range,
				
				  const T value,
				
				  size_t* index
				
				)
				
				if (canSwapEndianness!T && isForwardRange!R && hasSlicing!R && is(ElementType!R : ubyte));
						
					
				Parameters
| Name | Description | 
|---|---|
| T | The integral type to convert the first Tbytes to. | 
| endianness | The endianness to write the bytes in. | 
| range | The range to write to. | 
| value | The value to write. | 
| index | The index to start writing to. If index is a pointer, then it is updated to the index after the bytes read. | 
Example
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0];
bufferExample
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0, 0];
bufferExample
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0];
size_t index = 0;
bufferExample
bool
ubyte[] buffer = [0, 0];
bufferExample
char(8-bit)
ubyte[] buffer = [0, 0, 0];
bufferExample
wchar (16bit - 2x ubyte)
ubyte[] buffer = [0, 0, 0, 0];
bufferExample
dchar (32bit - 4x ubyte)
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0];
bufferExample
float (32bit - 4x ubyte)
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0];
bufferExample
double (64bit - 8x ubyte)
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
bufferExample
enum
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
enum Foo
{
    one = 10,
    two = 20,
    three = 30
}
bufferExample
enum - float
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0];
enum Float: float
{
    one = 32.0f,
    two = 25.0f
}
bufferExample
enum - double
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
enum Double: double
{
    one = 32.0,
    two = 25.0
}
bufferExample
enum - real
ubyte[] buffer = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
enum Real: real
{
    one = 32.0,
    two = 25.0
}
static assert(!__traits(compiles, bufferAuthors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, Alex Rønne Petersen, Damian Ziemba, Amaury SECHET
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.