Evo C++ Library v0.5.1
STL Compatibility

Evo STL compatibility info.

Initializer Lists (C++11)

Evo containers support C++11 initializer lists.

Example:

#include <evo/list.h>
#include <evo/maplist.h>
using namespace evo;
int main() {
List<int> list = {1, 2, 3};
MapList<int,int> map = {{1, 100}, {2, 200}};
return 0;
}
Range-Based For Loops (C++11)

Evo containers support C++11 range-based for loops.

Example:

#include <evo/list.h>
#include <evo/io.h>
using namespace evo;
int main() {
Console& c = con();
// Make a list and a copy (uses Copy-On-Write)
List<int> list = {1, 2, 3};
List<int> list2(list);
// Const iteration allows list2 to use Copy-On-Write for best performance
for (auto& item : list.asconst())
c.out << item << NL;
// Mutable iteration forces list2 to make a copy so items can be modified
for (auto& item : list) {
item *= 10;
c.out << item << NL;
}
return 0;
}
STL String

Evo supports implicitly converting STL strings (const std::string& and const std::string*) to StringBase so STL strings can be passed to functions that accept Evo string types. Simply include STL string header first and Evo will try to auto-detect and enable std::string support. C++17 std::string_view is also supported as well, when supported by the compiler.

If you want to be explicit about passing an STL string to a function using Evo strings, wrap it like this: evo::StringBase(stdstring) – see example below. Note that StringBase is a common base class for all Evo strings and works as a primitive form of SubString

See String Passing

Note that in some cases you may run into problems with "too many implicit conversions." Here's an example:

#include <string>
#include <evo/string.h>
int main() {
std::string stdstring = "test"; // constructs via temporary, ok here
evo::String string = stdstring; // constructs via temporary, possible compiler error: too many implicit conversions
evo::String string(stdstring); // ok, explicit constructor (no temporary) -- preferred
evo::String string = evo::StringBase(stdstring); // ok, explicit temporary
evo::String string(( evo::StringBase(stdstring) )); // ok, explicit temporary -- extra parenthesis prevent the C++ "Most Vexing Parse" issue
return 0;
}

You may also enable STL string compatibility directly with a preprocessor define, before including any Evo headers:

#define EVO_STD_STRING 1
#define EVO_STD_STRING_VIEW 1
#include <evo/string.h>

For more info on enabling STL string compatibility see: EVO_STD_STRING and EVO_STD_STRING_VIEW

STL Map

Evo provides some helpers for std::map container lookups.