std::fill

cppreference.com

Example

print_seq: (seq) = {
    for seq do (e) {
        std::cout << "(e)$ ";
    }
    std::cout << '\n';
}

main: () = {
    v: std::vector<int> = (0, 1, 2, 3, 4, 5, 6, 7, 8);
    print_seq(v);

    // set all of the elements to 8
    std::fill(v.begin(), v.end(), 8);
    print_seq(v);

    nums: std::vector = (
        :std::complex<double>=(1, 3),
        :std::complex<double>=(2, 2),
        :std::complex<double>=(4, 8));
    print_seq(nums);
    std::fill(nums.begin(), nums.end(), std::complex<double>(4, 2));
    print_seq(nums);
}

Output

0 1 2 3 4 5 6 7 8 
8 8 8 8 8 8 8 8 8 
(1,3) (2,2) (4,8) 
(4,2) (4,2) (4,2) 

Back to top

cpp2reference.com licensed under CC-BY-SA and GFDL.