Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
#include <string>
using namespace std::string_literals;
#include <vector>
#include <memory>
struct t {
std::string s;
std::vector<int> n;
};
auto v = std::make_unique<t>(
"Hello, world!"s,
decltype(t::n){1, 4, 9, 16, 25}
);
v.reset();
// Automatically:
void fn(){
auto v = std::make_unique<t>(
"Hello, world!"s,
decltype(t::n){1, 4, 9, 16, 25}
);
}
type t
character(len=:), allocatable :: c
integer, dimension(:), allocatable :: n
end type t
type(t), allocatable :: v
allocate (v)
v%s = 'Hello, world!'
v%n = [1,4,9,16,25]
deallocate (v)
type t struct {
s string
n []int
}
v := t{
s: "Hello, world!",
n: []int{1, 4, 9, 16, 25},
}
type
TDynIntArray = array of integer;
TT = record
s: string;
n: TDynIntArray;
end;
PTT = ^TT;
var
v: PTT;
begin
v := New(PTT);
v^.s := 'Hello world';
v^.n := TDynIntArray.Create(1,4,9,16,25);
Dispose(v);
end.
class T:
def __init__(self, s, n):
self.s = s
self.n = n
return
v = T('hello world', [1, 4, 9, 16, 25])
del v
T = Struct.new(:s, :n)
v = T.new("Hello, world", [1, 4, 9, 16, 25])
v = nil
struct T {
s: String,
n: Vec<usize>,
}
fn main() {
let v = T {
s: "Hello, world!".into(),
n: vec![1,4,9,16,25]
};
}