Вы используете устаревший браузер. Этот и другие сайты могут отображаться в нём некорректно. Вам необходимо обновить браузер или попробовать использовать другой.
fQuaternion Hello i need help i want to know how to get my vehicle(vehicledata) on raknet to turn to the xyz i set to it, and also the code i send speed to the xyz i set to it and also the speed setting
What is the best & safest way to clean std::string from memory ?
std::string example;
1. example.clear();
2. example.resize(0);
3. std::fill(example.begin(), example.end(), 0);
Hi there, such a cool question. Basically, have to distinguish what does "best & safest" mean in that context
By the rules of RTTI, standard definition of an object constructed in some arbitrary block (let's not include here some special cases like overloaded form of operator new()) will be destructed at the end of that block
C++:
{
std::string my_string { "String!" };
// ...
// std::basic_string::~basic_string will be called
}
So you ain't gotta do that by yourself, no such need for neither .resize, nor free(), delete(), std::fill and others
In case 'safest method' stands for making sure data you operate within act must be zeroed / cleared, especially in cases when std::string will be used for storing sensitive data (passwords and others), well, there's no portable and unambiguous answer.
Doing manual .clear call does not give any guarantee that this call won't be optimized
Proof: https://godbolt.org/z/rdCQyQ
Same goes for the std::basic_string::~basic_string, it might or mightn't clear used memory
Project moved to: https://github.com/llvm/llvm-project - llvm-mirror/libcxx
github.com
For a kick-off, there's has to be some function to do zeroing above some memory block with confidentially that this call/expression won't be optimized away by the compiler.
You might take a look at the following:
1) memset_s from C11. Even though it must be portable, there are some problems with C11 in, for instance, Visual Studio. Moreover, __STDC_WANT_LIB_EXT1__ and __STDC_WANT_LIB_EXT1__ must be used in any platform and there's another possible issue - MacOS might not work with those macroeses.
Код:
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
// available to use function
// errno_t memset_s(void * restrict s, rsize_t smax, int c, rsize_t n)
2) write memset_s by yourself, don't miss volatile modifier
Secondly, there's a need to know what is the way zeroing might be perfomed
1) direct data access
Before c++17, you could give a try to &str[0], but it has undefined behavior when pos == size()
Since c++17, std::basic_string::data will return non const pointer if target string was not const
2) might try std::allocator by calling std::string::get_allocator, but it's sort of deprecated
To implement this like it should be in modern c++, you can try usual class inheritance, but i'd like to recommend do this with std::unique_ptr, since it has support for the disposal function
Of course, this doesn't cover cases you're dealing with classical OOP model and can do cleaning at your class destructor
fQuaternion Hello i need help i want to know how to get my vehicle(vehicledata) on raknet to turn to the xyz i set to it, and also the code i send speed to the xyz i set to it and also the speed setting
Я задал другой вопрос, я понимаю, что можно извращаться как угодно.
Мой вопрос звучит так: можно ли имитировать ввод символа (даже если на твоей раскладке нету такого)? если да, то как это сделать.