-
Notifications
You must be signed in to change notification settings - Fork 8
Implement STL List #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
[Bugfix] Static string substring
wlib linking issue fixed by modifying cmake
Fix typos in MEMORY_OVERLOAD
automake-cmake-make
new-line-wmake
|
Implements #7 |
Add vscode to gitignore
|
How do you define template functions outside the header file? It does not seem to work for me |
|
It's pretty verbose. Are you redeclaring the template? template<class A, class B>
class Foo {
A& get(const B& b);
};
template<class A, class B>
A& Foo<A, B>::get(const B& b) { ... }And yeah you've gotta do this for every function |
|
@Mogball What about for templates where you don't give it a type but rather give it a value? Example: template<int k>
class{
public:
String<k> getString();
}
|
dhillondeep
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add protection against all the nullptr scenarios. We don't want mistakes to be made by client-side
tests/stl/list_test.cpp
Outdated
| @@ -0,0 +1,54 @@ | |||
| #include "gtest/gtest.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically for each template specialization you use, declare that class at the top of the file like
namespace wlp {
template class List<int>;
template class List<char*>;
template class List<StaticString<8>>;
...
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK so I just added this to the top of the file:
namespace wlp {
template class List<uint16_t>;
}And it seems to break the test for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting 100% code coverage (just for List.h) even without that, so why do we need to do this? Btw wmake coverage is broken since lcov isn't removing a lot of files. I tried playing around with lcov --remove but it won't listen to me. I did manage to make it forget about '/usr/*', so I guess it needs absolute paths? I'm pushing my changes, have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are getting 100% coverage because the coverage check doesn't see all the functions. You need to declare the class so that the coverage check can find all functions. Well, even if you do have 100% coverage you should add it so that future features won't go under the radar in coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do you know why adding it broke the tests? I get an issue with List.at(), even though it passed the assertion earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I have no idea. You'd have to debug a bit.
|
It should be the same, whether it's |
|
Well it only fails when doing list.front() and list.back() when the list is empty, and when you try accessing an index that's out of bounds. @dhillondeep like you said I think it's better if the client side checks for validity, when they know it can be invalid, before trying to access it rather than relying on the class to handle it for them every single time |
|
And @Mogball when I had the methods in a separate cpp file, I did the verbose template declaration for every function, but for some reason, it never picked up the implementations and gave me errors that the functions were undefined. But are you sure I need to move big functions out of the class declaration, since I don't think the compiler will inline if it can't; it does it at its own discretion, like, it can even ignore the |
|
There are some weird issues with defining templates in You should move larger functions outside the class definition. Different compilers will do different things, and not all perform their own inline optimizations. It's also a standard practice. |
|
OK, so I'll move the big definitions outside the class |
|
I'm having some issues testing the const iterator. Doing |
|
@ambyjkl You have to make your Iterator constant for it to use the constant version of begin. Your |
Changes looking good so far. Will do another pass once your test cases are done
|
Fixed some stuff, and added copy and move constructors to List |
|
@ambyjkl can you make sure you update your |
Mogball
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ay
|
👍 |
* Implement STL List * Implement tests for list * Implement iterators
Still needs tests, working on that