Skip to content

Difference between std::ifstream(std::basic_ifstream<char>) and std::basic_ifstream<uint8_t> #520

@knorrfix

Description

@knorrfix

Channel

Probably "C++Weekly" in my opinion this is not really intuitive and may surprise others as well.

Topics

I have found some behavior of std::basic_ifstream that surprised me, std::basic_ifstream returned in the following case the expected values, but std::basic_ifstream<uint8_t> did return only zeros: https://godbolt.org/z/9Tasccf96, what is happening here? As a user that doesn't use streams regularly this is very surprising to me.

What is the difference between std::ifstream aka. std::basic_ifstream and the other possible template instantiations, when can and should you use std::ifstream and when do you need to use one of the other template instantiations like (u)int8_t, (u)int16_t, ...

Length

I think the episode should be between 5 and 10 Minutes, depending on if there are some other interesting things to know in

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions