@@ -12,7 +12,7 @@ namespace msgpackcpp
1212// ----------------------------------------------------------------------------------------------------------------
1313
1414 template <class Byte , class Alloc >
15- struct sink_vector : sink_base
15+ struct sink_vector final : sink_base
1616 {
1717 static_assert (is_byte<Byte>, " Byte needs to be a byte" );
1818 std::vector<Byte,Alloc>& buf;
@@ -26,77 +26,77 @@ namespace msgpackcpp
2626 };
2727
2828 template <class Byte , class Alloc >
29- struct source_vector : source_base
29+ struct source_vector final : source_base
3030 {
3131 static_assert (is_byte<Byte>, " Byte needs to be a byte" );
3232 const std::vector<Byte,Alloc>& data;
3333 size_t offset{0 };
3434
3535 source_vector (const std::vector<Byte,Alloc>& data_) : data{data_} {}
3636
37- void read (char * buf, size_t nbytes) override
37+ void read (char * buf, size_t nbytes) override final
3838 {
3939 if ((data.size () - offset) < nbytes)
4040 throw std::system_error (OUT_OF_DATA);
4141 std::memcpy (buf, data.data () + offset, nbytes);
4242 offset += nbytes;
4343 }
4444
45- uint8_t peak () override
45+ uint8_t peak () override final
4646 {
4747 return static_cast <uint8_t >(data[offset]);
4848 }
4949
50- size_t remaining () const override
50+ size_t remaining () const override final
5151 {
5252 return data.size () - offset;
5353 }
5454 };
5555
56- template <class Byte , class Alloc , std:: enable_if_t <is_byte< Byte>, bool > = true >
56+ template <class Byte , class Alloc , check_byte< Byte> = true >
5757 auto sink (std::vector<Byte, Alloc>& buf)
5858 {
5959 return sink_vector<Byte,Alloc>{buf};
6060 }
6161
62- template <class Byte , class Alloc , std:: enable_if_t <is_byte< Byte>, bool > = true >
62+ template <class Byte , class Alloc , check_byte< Byte> = true >
6363 auto source (const std::vector<Byte, Alloc>& buf)
6464 {
6565 return source_vector<Byte,Alloc>{buf};
6666 }
6767
6868// ----------------------------------------------------------------------------------------------------------------
6969
70- struct ostream_sink : sink_base
70+ struct ostream_sink final : sink_base
7171 {
7272 std::ostream& out;
7373
7474 ostream_sink (std::ostream& out_) : out{out_}{}
75- void write (const char * data, size_t nbytes) override {out.write (data, nbytes);}
75+ void write (const char * data, size_t nbytes) override final {out.write (data, nbytes);}
7676 };
7777
78- struct istream_source : source_base
78+ struct istream_source final : source_base
7979 {
8080 std::istream& in;
8181
8282 istream_source (std::istream& in_) : in{in_}{}
8383
84- void read (char * buf, size_t nbytes) override
84+ void read (char * buf, size_t nbytes) override final
8585 {
8686 in.read (buf, nbytes);
8787 if (in.gcount () != (long )nbytes)
8888 throw std::system_error (OUT_OF_DATA);
8989 }
9090
91- uint8_t peak () override
91+ uint8_t peak () override final
9292 {
9393 uint8_t b = static_cast <uint8_t >(in.peek ());
9494 if (!in || !in.good () || in.eof ())
9595 throw std::system_error (OUT_OF_DATA);
9696 return b;
9797 }
9898
99- size_t remaining () const override
99+ size_t remaining () const override final
100100 {
101101 const auto pos = in.tellg ();
102102 in.seekg (0 , std::ios::end );
0 commit comments