本文整理汇总了C++中std::array类的典型用法代码示例。如果您正苦于以下问题:C++ array类的具体用法?C++ array怎么用?C++ array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: begin
[[nodiscard]] std::array<char16, 2>::const_iterator begin() const noexcept
{
return m_buffer.begin();
}
示例2: GenerateFixedParameters
namespace NWM {
// 802.11 broadcast MAC address
constexpr MacAddress BroadcastMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
constexpr u64 DefaultNetworkUptime = 900000000; // 15 minutes in microseconds.
// Note: These values were taken from a packet capture of an o3DS XL
// broadcasting a Super Smash Bros. 4 lobby.
constexpr u16 DefaultExtraCapabilities = 0x0431;
// Size of the SSID broadcast by an UDS beacon frame.
constexpr u8 UDSBeaconSSIDSize = 8;
// The maximum size of the data stored in the EncryptedData0 tag (24).
constexpr u32 EncryptedDataSizeCutoff = 0xFA;
/**
* NWM Beacon data encryption key, taken from the NWM module code.
* We stub this with an all-zeros key as that is enough for Citra's purpose.
* The real key can be used here to generate beacons that will be accepted by
* a real 3ds.
*/
constexpr std::array<u8, CryptoPP::AES::BLOCKSIZE> nwm_beacon_key = {};
/**
* Generates a buffer with the fixed parameters of an 802.11 Beacon frame
* using dummy values.
* @returns A buffer with the fixed parameters of the beacon frame.
*/
std::vector<u8> GenerateFixedParameters() {
std::vector<u8> buffer(sizeof(BeaconFrameHeader));
BeaconFrameHeader header{};
// Use a fixed default time for now.
// TODO(Subv): Perhaps use the difference between now and the time the network was started?
header.timestamp = DefaultNetworkUptime;
header.beacon_interval = DefaultBeaconInterval;
header.capabilities = DefaultExtraCapabilities;
std::memcpy(buffer.data(), &header, sizeof(header));
return buffer;
}
/**
* Generates an SSID tag of an 802.11 Beacon frame with an 8-byte all-zero SSID value.
* @returns A buffer with the SSID tag.
*/
std::vector<u8> GenerateSSIDTag() {
std::vector<u8> buffer(sizeof(TagHeader) + UDSBeaconSSIDSize);
TagHeader tag_header{};
tag_header.tag_id = static_cast<u8>(TagId::SSID);
tag_header.length = UDSBeaconSSIDSize;
std::memcpy(buffer.data(), &tag_header, sizeof(TagHeader));
// The rest of the buffer is already filled with zeros.
return buffer;
}
/**
* Generates a buffer with the basic tagged parameters of an 802.11 Beacon frame
* such as SSID, Rate Information, Country Information, etc.
* @returns A buffer with the tagged parameters of the beacon frame.
*/
std::vector<u8> GenerateBasicTaggedParameters() {
// Append the SSID tag
std::vector<u8> buffer = GenerateSSIDTag();
// TODO(Subv): Add the SupportedRates tag.
// TODO(Subv): Add the DSParameterSet tag.
// TODO(Subv): Add the TrafficIndicationMap tag.
// TODO(Subv): Add the CountryInformation tag.
// TODO(Subv): Add the ERPInformation tag.
return buffer;
}
/**
* Generates a buffer with the Dummy Nintendo tag.
* It is currently unknown what this tag does.
* TODO(Subv): Figure out if this is needed and what it does.
* @returns A buffer with the Nintendo tagged parameters of the beacon frame.
*/
std::vector<u8> GenerateNintendoDummyTag() {
// Note: These values were taken from a packet capture of an o3DS XL
// broadcasting a Super Smash Bros. 4 lobby.
constexpr std::array<u8, 3> dummy_data = {0x0A, 0x00, 0x00};
DummyTag tag{};
tag.header.tag_id = static_cast<u8>(TagId::VendorSpecific);
tag.header.length = sizeof(DummyTag) - sizeof(TagHeader);
tag.oui_type = static_cast<u8>(NintendoTagId::Dummy);
tag.oui = NintendoOUI;
tag.data = dummy_data;
std::vector<u8> buffer(sizeof(DummyTag));
//.........这里部分代码省略.........
示例3: _T
LRESULT COption::ExtractProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
static CFolderDialog FolderDlg;
static SOption* pOption = &m_option_tmp;
// Extraction Settings
static constexpr std::array<LPCTSTR, 3> ExtractCheckText{{
_T("Extract each folder"),
_T("Fix the CRC of OGG files upon extraction"),
_T("Enable simple decoding")
}};
static const std::array<BOOL*, 4> ExtractCheckFlag{{
&pOption->bCreateFolder, &pOption->bFixOgg, &pOption->bEasyDecrypt, &pOption->bRenameScriptExt
}};
static std::array<CCheckBox, ExtractCheckText.size()> ExtractCheck;
static CCheckBox ExtractCheckAlpha;
static CLabel ExtractLabelPng, ExtractLabelAlpha, ExtractLabelBuf, ExtractLabelTmp;
static CRadioBtn ExtractRadioImage, ExtractRadioSave;
static CUpDown ExtractUpDownPng;
static CEditBox ExtractEditPng, ExtractEditAlpha, ExtractEditSave, ExtractEditBuf, ExtractEditTmp;
static CButton ExtractBtnSave, ExtractBtnTmp;
static CGroupBox ExtractGroupImage, ExtractGroupSave;
switch (msg)
{
case WM_INITDIALOG:
{
UINT ID = 10000;
const int x = 10;
const int xx = 15;
int y = 0;
// Extraction Settings
for (size_t i = 0; i < ExtractCheckText.size(); i++)
{
ExtractCheck[i].Create(hWnd, ExtractCheckText[i], ID++, x, y += 20, 230, 20);
ExtractCheck[i].SetCheck(*ExtractCheckFlag[i]);
}
//
int y_image = y;
ExtractGroupImage.Create(hWnd, _T("Output image format"), ID++, x, y_image += 34, 240, 110);
ExtractRadioImage.Close();
ExtractRadioImage.Create(hWnd, _T("BMP"), ID++, x + xx, y_image += 18, 50, 20);
ExtractRadioImage.Create(hWnd, _T("PNG"), ID++, x + xx, y_image += 20, 50, 20);
ExtractRadioImage.SetCheck(0, pOption->bDstBMP);
ExtractRadioImage.SetCheck(1, pOption->bDstPNG);
ExtractLabelPng.Create(hWnd, _T("Compression Level"), ID++, x + xx + 50, y_image + 3, 100, 20);
ExtractEditPng.Create(hWnd, _T(""), ID++, x + xx + 150, y_image, 40, 22);
ExtractEditPng.SetLimit(1);
ExtractUpDownPng.Create(hWnd, ExtractEditPng.GetCtrlHandle(), pOption->CmplvPng, ID++, 9, 0);
//
ExtractCheckAlpha.Create(hWnd, _T("Enable alpha blending"), ID++, x + xx, y_image += 22, 140, 20);
ExtractCheckAlpha.SetCheck(pOption->bAlphaBlend);
ExtractLabelAlpha.Create(hWnd, _T("Background color"), ID++, x + xx * 2 + 4, y_image += 24, 100, 20);
ExtractEditAlpha.Create(hWnd, pOption->szBgRGB, ID++, x + xx * 2 + 100, y_image - 4, 100, 22);
ExtractEditAlpha.SetLimit(6);
ExtractEditAlpha.Enable(pOption->bAlphaBlend);
//
const int x_save = x + 200;
int y_save = y;
ExtractGroupSave.Create(hWnd, _T("Destination"), ID++, x_save + 50, y_save += 34, 290, 110);
ExtractRadioSave.Close();
ExtractRadioSave.Create(hWnd, _T("Specify each time"), ID++, x_save + xx + 50, y_save += 18, 220, 20);
ExtractRadioSave.Create(hWnd, _T("Same folder as input source"), ID++, x_save + xx + 50, y_save += 20, 200, 20);
ExtractRadioSave.Create(hWnd, _T("The following folder"), ID++, x_save + xx + 50, y_save += 20, 200, 20);
ExtractRadioSave.SetCheck(0, pOption->bSaveSel);
ExtractRadioSave.SetCheck(1, pOption->bSaveSrc);
ExtractRadioSave.SetCheck(2, pOption->bSaveDir);
ExtractEditSave.Create(hWnd, pOption->SaveDir, ID++, x_save + xx * 2 + 40, y_save += 20, 200, 22);
ExtractEditSave.Enable(pOption->bSaveDir);
ExtractBtnSave.Create(hWnd, _T("Browse"), ID++, x_save + xx * 2 + 250, y_save + 1, 50, 20);
ExtractBtnSave.Enable(pOption->bSaveDir);
//
y = (y_image > y_save) ? y_image : y_save;
ExtractLabelBuf.Create(hWnd, _T("Buffer Size(KB)"), ID++, x, y += 44, 100, 20);
ExtractEditBuf.Create(hWnd, pOption->BufSize, ID++, x + 100, y - 4, 110, 22);
//
ExtractLabelTmp.Create(hWnd, _T("Temporary Folder"), ID++, x, y += 24, 100, 20);
ExtractEditTmp.Create(hWnd, pOption->TmpDir, ID++, x + 100, y - 4, 200, 22);
ExtractBtnTmp.Create(hWnd, _T("Browse"), ID++, x + 310, y - 3, 50, 20);
break;
}
case WM_COMMAND:
//.........这里部分代码省略.........
示例4: nbDims
int nbDims(std::array<T, N> const& p)
{
return p.size();
}
示例5: findHeapContainingBlock
namespace coreinit
{
be_wfunc_ptr<void*, uint32_t>*
pMEMAllocFromDefaultHeap;
be_wfunc_ptr<void*, uint32_t, int>*
pMEMAllocFromDefaultHeapEx;
be_wfunc_ptr<void, void*>*
pMEMFreeToDefaultHeap;
static std::array<CommonHeap *, MEMBaseHeapType::Max>
sMemArenas;
static ExpandedHeap *
sSystemHeap = nullptr;
static MemoryList *
sForegroundMemlist = nullptr;
static MemoryList *
sMEM1Memlist = nullptr;
static MemoryList *
sMEM2Memlist = nullptr;
static MemoryList *
findListContainingHeap(CommonHeap *heap)
{
be_val<uint32_t> start, size, end;
OSGetForegroundBucket(&start, &size);
end = start + size;
if (heap->dataStart >= start && heap->dataEnd <= end) {
return sForegroundMemlist;
} else {
OSGetMemBound(OSMemoryType::MEM1, &start, &size);
end = start + size;
if (heap->dataStart >= start && heap->dataEnd <= end) {
return sMEM1Memlist;
} else {
return sMEM2Memlist;
}
}
}
static MemoryList *
findListContainingBlock(void *block)
{
be_val<uint32_t> start, size, end;
uint32_t addr = memory_untranslate(block);
OSGetForegroundBucket(&start, &size);
end = start + size;
if (addr >= start && addr <= end) {
return sForegroundMemlist;
} else {
OSGetMemBound(OSMemoryType::MEM1, &start, &size);
end = start + size;
if (addr >= start && addr <= end) {
return sMEM1Memlist;
} else {
return sMEM2Memlist;
}
}
}
static CommonHeap *
findHeapContainingBlock(MemoryList *list, void *block)
{
CommonHeap *heap = nullptr;
uint32_t addr = memory_untranslate(block);
while ((heap = reinterpret_cast<CommonHeap*>(MEMGetNextListObject(list, heap)))) {
if (addr >= heap->dataStart && addr < heap->dataEnd) {
auto child = findHeapContainingBlock(&heap->list, block);
return child ? child : heap;
}
}
return nullptr;
}
void
MEMiInitHeapHead(CommonHeap *heap, MEMiHeapTag tag, uint32_t dataStart, uint32_t dataEnd)
{
heap->tag = tag;
MEMInitList(&heap->list, offsetof(CommonHeap, link));
heap->dataStart = dataStart;
heap->dataEnd = dataEnd;
OSInitSpinLock(&heap->lock);
heap->flags = 0;
if (auto list = findListContainingHeap(heap)) {
MEMAppendListObject(list, heap);
}
}
//.........这里部分代码省略.........
示例6: Serialize
static void Serialize(const std::array<T, N>& x, Archive& ar) {
for (typename std::array<T, N>::const_iterator it = x.begin();
it != x.end(); ++it)
Serialization<Archive, T>::Serialize(*it, ar);
}
示例7: IsNo31Month
static inline bool IsNo31Month(const int Month) {
static const std::array<int, 5> No31Month = { 2, 4, 6, 9, 11 };
return std::any_of(No31Month.begin(), No31Month.end(), [Month](const int i) { return Month == i; });
}
示例8: GetPixelWidth
bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
{
int BlockX = m_CenterX + static_cast<int>((a_X - m_Width / 2) * GetPixelWidth());
int BlockZ = m_CenterZ + static_cast<int>((a_Z - m_Height / 2) * GetPixelWidth());
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
int RelX = BlockX - (ChunkX * cChunkDef::Width);
int RelZ = BlockZ - (ChunkZ * cChunkDef::Width);
ASSERT(m_World != nullptr);
ColorID PixelData;
m_World->DoWithChunk(ChunkX, ChunkZ, [&](cChunk & a_Chunk)
{
if (!a_Chunk.IsValid())
{
return false;
}
if (GetDimension() == dimNether)
{
// TODO 2014-02-22 xdot: Nether maps
return false;
}
static const std::array<unsigned char, 4> BrightnessID = { { 3, 0, 1, 2 } }; // Darkest to lightest
BLOCKTYPE TargetBlock;
NIBBLETYPE TargetMeta;
auto Height = a_Chunk.GetHeight(RelX, RelZ);
auto ChunkHeight = cChunkDef::Height;
a_Chunk.GetBlockTypeMeta(RelX, Height, RelZ, TargetBlock, TargetMeta);
auto ColourID = BlockHandler(TargetBlock)->GetMapBaseColourID(TargetMeta);
if (IsBlockWater(TargetBlock))
{
ChunkHeight /= 4;
while (((--Height) != -1) && IsBlockWater(a_Chunk.GetBlock(RelX, Height, RelZ)))
{
continue;
}
}
else if (ColourID == 0)
{
while (((--Height) != -1) && ((ColourID = BlockHandler(a_Chunk.GetBlock(RelX, Height, RelZ))->GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
{
continue;
}
}
// Multiply base color ID by 4 and add brightness ID
const int BrightnessIDSize = static_cast<int>(BrightnessID.size());
PixelData = ColourID * 4 + BrightnessID[static_cast<size_t>(Clamp<int>((BrightnessIDSize * Height) / ChunkHeight, 0, BrightnessIDSize - 1))];
return false;
}
);
SetPixel(a_X, a_Z, PixelData);
return true;
}
示例9: SCENARIO
#include <Nazara/Core/Serialization.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/MemoryView.hpp>
#include <Nazara/Math/BoundingVolume.hpp>
#include <Nazara/Math/Frustum.hpp>
#include <Nazara/Math/Ray.hpp>
#include <array>
#include <Catch/catch.hpp>
SCENARIO("Serialization", "[CORE][SERIALIZATION]")
{
GIVEN("A context of serialization")
{
std::array<char, 256> datas; // The array must be bigger than any of the serializable classes
Nz::MemoryView stream(datas.data(), datas.size());
Nz::SerializationContext context;
context.stream = &stream;
WHEN("We serialize basic types")
{
THEN("Arithmetical types")
{
context.stream->SetCursorPos(0);
REQUIRE(Serialize(context, 3));
int value = 0;
context.stream->SetCursorPos(0);
REQUIRE(Unserialize(context, &value));
REQUIRE(value == 3);
示例10: warning
#include <kernel/session/win32_session.h>
#include <thread>
#include <future>
#pragma warning(disable:4996)
namespace kernel {
::std::shared_ptr<win32_session> win32_session::handshake(life_stream raw_stream, session_id_t sid) throw(...)
{
::std::array<unsigned char, 512> pipe_name;
pipe_name.fill(0);
sprintf((char*)(pipe_name.data()), "opennui_pipe_%d", sid);
auto stream_pair = _message_stream_connection(raw_stream, (char*)pipe_name.data());
win32_message_stream& cts_stream = stream_pair.first;
win32_message_stream& stc_stream = stream_pair.second;
::std::shared_ptr<win32_session> session = ::std::make_shared<win32_session>();
session->_life_stream = std::move(raw_stream);
session->_cts_stream = std::move(cts_stream);
session->_stc_stream = std::move(stc_stream);
session->_session_id = sid;
return session;
}
win32_session::session_id_t win32_session::get_id() const
{
return _session_id;
}
win32_session::life_stream win32_session::get_life_stream()
{
示例11:
void EUTelGeometryTelescopeGeoDescription::master2LocalVec( int sensorID, std::array<double,3> const & globalVec, std::array<double,3>& localVec) {
this->master2LocalVec(sensorID, globalVec.data(), localVec.data());
}
示例12: TEST_CASE
#include <Nazara/Audio/Algorithm.hpp>
#include <Catch/catch.hpp>
#include <array>
TEST_CASE("MixToMono", "[AUDIO][ALGORITHM]")
{
SECTION("Mix two channels together")
{
std::array<int, 4> input{ 1, 3, 5, 3 };
std::array<int, 2> output{ 0, 0 };
// Two channels and two frames !
Nz::MixToMono(input.data(), output.data(), 2, 2);
std::array<int, 2> theoric{ 2, 4 }; // It's the mean of the two channels
REQUIRE(output == theoric);
}
}
示例13: get
T get(std::array<T,N> const& p, int i)
{
return i < p.size() ? p[i] : 0;
}
示例14: vec
vector<T> vec(const std::array<T, n>& arr) {
return vector<T>(arr.begin(), arr.end());
}
示例15: PatchTypeAsString
const char* PatchTypeAsString(PatchType type)
{
return s_patch_type_strings.at(static_cast<int>(type));
}