本文整理汇总了C++中std::array::data方法的典型用法代码示例。如果您正苦于以下问题:C++ array::data方法的具体用法?C++ array::data怎么用?C++ array::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::array
的用法示例。
在下文中一共展示了array::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_handler
// Read Handler, wird asynchron aufgerufen, wenn das OS signalisiert,
// dass Daten von STDIN gelesen werden koennen
void read_handler(const boost::system::error_code &ec, std::size_t bytes_transferred)
{
if (!ec)
{
std::cout.write(bytes.data(), bytes_transferred);
// weiter asynchron von STDIN lesen
in.async_read_some(boost::asio::buffer(bytes), read_handler);
}
}
示例2: put_string
void put_string(entry& e, std::array<char, 64>& sig
, std::uint64_t& seq
, std::string const& salt
, std::array<char, 32> const& pk
, std::array<char, 64> const& sk
, char const* str)
{
using libtorrent::dht::sign_mutable_item;
e = std::string(str);
std::vector<char> buf;
bencode(std::back_inserter(buf), e);
dht::signature sign;
++seq;
sign_mutable_item(buf, salt, dht::sequence_number(seq)
, dht::public_key(pk.data())
, dht::secret_key(sk.data()), sign);
sig = sign.bytes;
}
示例3: now
std::chrono::nanoseconds Encryption::DirectEncryptECB(void) {
rijndael_context rk;
rijndaelKeySetup(&rk, sc_key.data(), 256);
auto start = high_resolution_clock::now();
for (size_t i = 0; i < buffer.size(); i += 16) {
rijndaelEncrypt(&rk, &buffer[i], &buffer[i]);
}
return high_resolution_clock::now() - start;
}
示例4: UpdateConfigNANDSavegame
ResultCode UpdateConfigNANDSavegame() {
FileSys::Mode mode = {};
mode.write_flag = 1;
mode.create_flag = 1;
FileSys::Path path("config");
auto file = cfg_system_save_data->OpenFile(path, mode);
_assert_msg_(Service_CFG, file != nullptr, "could not open file");
file->Write(0, CONFIG_SAVEFILE_SIZE, 1, cfg_config_file_buffer.data());
return RESULT_SUCCESS;
}
示例5: FormatConfig
ResultCode FormatConfig() {
ResultCode res = DeleteConfigNANDSaveFile();
if (!res.IsSuccess())
return res;
// Delete the old data
cfg_config_file_buffer.fill(0);
// Create the header
SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data());
// This value is hardcoded, taken from 3dbrew, verified by hardware, it's always the same value
config->data_entries_offset = 0x455C;
// Insert the default blocks
res = CreateConfigInfoBlk(0x00050005, sizeof(STEREO_CAMERA_SETTINGS), 0xE,
reinterpret_cast<const u8*>(STEREO_CAMERA_SETTINGS.data()));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x00090001, sizeof(CONSOLE_UNIQUE_ID), 0xE,
reinterpret_cast<const u8*>(&CONSOLE_UNIQUE_ID));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000F0004, sizeof(CONSOLE_MODEL), 0x8,
reinterpret_cast<const u8*>(&CONSOLE_MODEL));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000A0002, sizeof(CONSOLE_LANGUAGE), 0xA, &CONSOLE_LANGUAGE);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x00070001, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE);
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000B0000, sizeof(COUNTRY_INFO), 0xE,
reinterpret_cast<const u8*>(&COUNTRY_INFO));
if (!res.IsSuccess())
return res;
res = CreateConfigInfoBlk(0x000A0000, sizeof(CONSOLE_USERNAME_BLOCK), 0xE,
reinterpret_cast<const u8*>(&CONSOLE_USERNAME_BLOCK));
if (!res.IsSuccess())
return res;
// Save the buffer to the file
res = UpdateConfigNANDSavegame();
if (!res.IsSuccess())
return res;
return RESULT_SUCCESS;
}
示例6: move
void
move(C<I>, const_iterator&& other)
{
if(n_ == I)
{
new(buf_.data()) iter_t<I>{
std::move(other.iter<I>())};
return;
}
move(C<I+1>{}, std::move(other));
}
示例7: copy
void
copy(C<I>, const_iterator const& other)
{
if(n_ == I)
{
new(buf_.data()) iter_t<I>{
other.iter<I>()};
return;
}
copy(C<I+1>{}, other);
}
示例8: decrement
void
decrement(C<sizeof...(Bs)>)
{
auto constexpr I = sizeof...(Bs);
if(n_ == I)
{
--n_;
new(buf_.data()) iter_t<I-1>{
std::get<I-1>(*bs_).end()};
}
decrement(C<I-1>{});
}
示例9: value
virtual Real value(std::array<Real, Dimension + 1> coordinates)
const {
assert(interpolant);
// Pack and call
NaryMethodConst<Real, Interpolant<Dimension>,
Dimension, Real> tmp =
&Interpolant<Dimension>::operator();
return packAndCall<Dimension>(interpolant, tmp,
coordinates.data() + 1);
}
示例10: run_traced
void sc_synth::run_traced(void)
{
trace = 0;
#ifndef thread_local
spin_lock::scoped_lock lock (log_guard);
#endif
scratchpad_printer printer(trace_scratchpad.data());
printer.printf("\nTRACE %d %s #units: %d\n", id(), this->definition_name(), calc_unit_count);
for (size_t calc_unit_index = 0; calc_unit_index != calc_unit_count; ++calc_unit_index) {
Unit * unit = calc_units[calc_unit_index];
sc_ugen_def * def = reinterpret_cast<sc_ugen_def*>(unit->mUnitDef);
printer.printf(" unit %zd %s\n in ", calc_unit_index, def->name());
for (uint16_t j=0; j!=unit->mNumInputs; ++j) {
printer.printf(" %g", unit->mInBuf[j][0]);
if (printer.shouldFlush()) {
#ifdef thread_local
spin_lock::scoped_lock lock (log_guard);
#endif
log(printer.data());
printer.clear();
}
}
printer.printf("\n");
(unit->mCalcFunc)(unit, unit->mBufLength);
printer.printf(" out");
for (int j=0; j<unit->mNumOutputs; ++j) {
printer.printf(" %g", unit->mOutBuf[j][0]);
if (printer.shouldFlush()) {
#ifdef thread_local
spin_lock::scoped_lock lock (log_guard);
#endif
log(printer.data());
printer.clear();
}
}
printer.printf("\n");
}
printer.printf("\n");
#ifdef thread_local
spin_lock::scoped_lock lock (log_guard);
#endif
log(printer.data());
}
示例11: draw
//private
void StatsReporter::draw()
{
if (!visible) return;
nim::SetNextWindowSizeConstraints({ 300.f, 200.f }, { 400.f, 1000.f });
nim::Begin("Stats:", &visible, ImGuiWindowFlags_ShowBorders);
static std::array<float, 90> timeValues = { 0.f };
static std::array<float, 90> frameValues = { 0.f };
static std::size_t valuesIndex = 0;
const float elapsed = frameTimer.restart().asSeconds();
const float frameTime = elapsed * 1000.f;
const float frameRate = 1.f / elapsed;
static float avgTime = 0.f;
avgTime -= avgTime / timeValues.size();
avgTime += frameTime / timeValues.size();
std::string avgTStr = "Avg: " + std::to_string(avgTime) + " (ms)";
static float avgFrame = 0.f;
avgFrame -= avgFrame / frameValues.size();
avgFrame += frameRate / frameValues.size();
std::string avgFStr = "Avg: " + std::to_string(avgFrame);
timeValues[valuesIndex] = frameTime;
frameValues[valuesIndex] = frameRate;
valuesIndex = (valuesIndex + 1) % timeValues.size();
nim::PlotLines("Frame Time", timeValues.data(), timeValues.size(), valuesIndex, avgTStr.c_str(), 0.f, std::max(33.f, frameTime), ImVec2(0, 40));
nim::PlotLines("Frame Rate", frameValues.data(), frameValues.size(), valuesIndex, avgFStr.c_str(), 0.f, std::max(950.f, frameRate), ImVec2(0, 40));
nim::BeginChild("ScrollingRegion", ImVec2(0, -nim::GetItemsLineHeightWithSpacing()), false, ImGuiWindowFlags_HorizontalScrollbar);
nim::TextUnformatted(Stats::getString().c_str(), Stats::getString().c_str() + Stats::getString().size());
nim::SetScrollHere();
nim::EndChild();
nim::End();
//nim::ShowTestWindow(&visible);
}
示例12: construct
void
construct(C<I>)
{
if(std::get<I>(*bs_).begin() !=
std::get<I>(*bs_).end())
{
n_ = I;
new(buf_.data()) iter_t<I>{
std::get<I>(*bs_).begin()};
return;
}
construct(C<I+1>{});
}
示例13: encrypt
static std::vector<uint8_t> encrypt(
const std::vector<uint8_t> header,
const std::vector<uint8_t> plain,
const std::vector<uint8_t> footer,
const std::array<uint8_t, 16>& nonce,
const std::array<uint8_t, 16>& key) {
std::vector<uint8_t> cipher;
cipher.resize(plain.size() + 128);
unsigned char* c = cipher.data();
size_t cLen = cipher.size();
const unsigned char* h = header.empty() ? 0 : header.data();
size_t hLen = header.size();
const unsigned char* p = plain.data();
size_t pLen = plain.size();
const unsigned char* t = footer.empty() ? 0 : footer.data();
size_t tLen = footer.size();
norx_aead_encrypt(c, &cLen, h, hLen, p, pLen, t, tLen, nonce.data(), key.data());
cipher.resize(cLen);
return cipher;
}
示例14: encryptSend
// ----------------------------------------------------------------------------
ENetPacket* Crypto::encryptSend(BareNetworkString& ns, bool reliable)
{
// 4 bytes counter and 4 bytes tag
ENetPacket* p = enet_packet_create(NULL, ns.m_buffer.size() + 8,
(reliable ? ENET_PACKET_FLAG_RELIABLE :
(ENET_PACKET_FLAG_UNSEQUENCED | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT))
);
if (p == NULL)
return NULL;
std::array<uint8_t, 12> iv = {};
std::unique_lock<std::mutex> ul(m_crypto_mutex);
uint32_t val = ++m_packet_counter;
if (NetworkConfig::get()->isClient())
memcpy(iv.data(), &val, 4);
else
memcpy(iv.data() + 4, &val, 4);
uint8_t* packet_start = p->data + 8;
if (EVP_EncryptInit_ex(m_encrypt, NULL, NULL, NULL, iv.data()) != 1)
{
enet_packet_destroy(p);
return NULL;
}
int elen;
if (EVP_EncryptUpdate(m_encrypt, packet_start, &elen, ns.m_buffer.data(),
(int)ns.m_buffer.size()) != 1)
{
enet_packet_destroy(p);
return NULL;
}
if (EVP_EncryptFinal_ex(m_encrypt, unused_16_blocks.data(), &elen) != 1)
{
enet_packet_destroy(p);
return NULL;
}
if (EVP_CIPHER_CTX_ctrl(m_encrypt, EVP_CTRL_GCM_GET_TAG, 4, p->data + 4)
!= 1)
{
enet_packet_destroy(p);
return NULL;
}
ul.unlock();
memcpy(p->data, &val, 4);
return p;
} // encryptSend
示例15: receive
void Server::receive() {
Peer peer;
boost::system::error_code error;
auto bytes_transferred =
socket_.receive_from(boost::asio::buffer(recv_buffer_), peer, 0, error);
std::cout << "Server received " << bytes_transferred << " bytes"
" from " << peer
<< " with " << error.message() << std::endl;
if (!error) {
std::cout << " >> ";
std::cout.write(recv_buffer_.data(), bytes_transferred);
std::cout << std::endl;
}
receive();
}