Scilab: add bool type in STL vector example

This commit is contained in:
Simon Marchetto 2013-07-19 17:31:59 +02:00
commit ca282beae6
4 changed files with 28 additions and 0 deletions

View file

@ -63,6 +63,18 @@ std::vector<std::string> concat_string_vector(const std::vector<std::string> vec
return concat_vector<std::string>(vector, other_vector);
}
// bool vectors
std::vector<bool> create_bool_vector(const int size, const bool value)
{
return std::vector<bool>(size, value);
}
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector)
{
return concat_vector<bool>(vector, other_vector);
}
// pointer (on objects) vectors
std::vector<classA*> create_classA_vector(const int size, const int value)

View file

@ -18,6 +18,10 @@ std::vector<int> concat_integer_vector(const std::vector<int> vector, const std:
std::vector<std::string> create_string_vector(const int size, const char* value);
std::vector<std::string> concat_string_vector(const std::vector<std::string> vector, const std::vector<std::string> other_vector);
// bool vectors
std::vector<bool> create_bool_vector(const int size, const bool value);
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector);
// pointer (on objects) vectors
class classA
{

View file

@ -14,6 +14,7 @@ namespace std
%template(IntVector) vector<int>;
%template(DoubleVector) vector<double>;
%template(StringVector) vector<std::string>;
%template(BoolVector) vector<bool>;
%template(ClassAVector) vector<classA*>;
}

View file

@ -44,6 +44,17 @@ disp("concat this vector with the vector of string {''bb'', ''bb''} with concat_
sv3 = concat_string_vector(sv, sv2);
disp(sv3);
// bool vectors
disp("Example of passing matrices of bool as vector arguments of C++ functions.");
disp("get a vector of bool {true, true} with create_bool_vector():");
bv = create_bool_vector(2, %T);
disp(bv);
bv2 = create_bool_vector(3, %F);
disp("concat this vector with the vector of bool {false, false, false} with concat_bool_vector():");
bv3 = concat_bool_vector(bv, bv2);
disp(bv3);
// pointer (on object) vectors
disp("Example of passing list of objects as vector arguments of C++ functions.");