const correctness
brucebob opened this issue · comments
Hello I like the idea of the library and it's pretty intuitive to use but i notices a few thing about it that doesn't seem right.
#include "CTML.h"
#include <iostream>
int main ()
{
const CTML::Document document;
std::cout << document.ToString(CTML::MULTILINE);
}
This will fail to compile due to ToString not being a const member function. Now unless ToString mutates Document it should be const function.
I also noticed this with your get functions have the same issue.
You're right, all of those functions should be const. I'll fix that really quick.
You put the const in the wrong position.
old
std::string ToString(const Readability& readability) {
how it should look so you can call ToString on a const object
std::string ToString(const Readability& readability) const {
What you had only make the std::string const not the member function
Oh, that makes sense. Sorry about that!