tinfoilboy / CTML

A C++ HTML document constructor only depending on the standard library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

const correctness

brucebob opened this issue · comments

commented

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.

Just fixed this in d59d087. Closed.

commented

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!

Okay, now the issue should be fixed in fb8599f.