您的示例不是最好说明施放 void*
的实际问题,可能是 const
,以相同的constness,因为您可以简单地用 type x = t;
替换该行以获取所需的输出。
但是,您可以使用一种类型特征:
#include <iostream>
#include <type_traits>
template <typename From,typename To>
struct preserve_const {
using type = std::remove_const<To>::type;
};
template <typename From,typename To>
struct preserve_const<const From,To> {
using type = const To;
};
template <typename From,typename To>
using preserve_const_t = typename preserve_const<From,To>::type;
template<typename type>
void test(type t) {
std::cout << "t const? = " << std::is_const<decltype(t)>() << std::endl;
preserve_const_t<type,int> x = t;
std::cout << "x const? = " << std::is_const<decltype(x)>() << std::endl;
};
int main() {
const int x = 0;
int y = 0;
test<const int>(x);
test<int>(y);
}
或如评论中提到的,也许更简单:
template <typename type,typename T>
using the_type = std::conditional_t< std::is_const_v<type>,const T,T>;
我的实施,非常自我解释
function replaceAll(string, token, newtoken) {
if(token!=newtoken)
while(string.indexOf(token) > -1) {
string = string.replace(token, newtoken);
}
return string;
}
[i]在git bash或powershell中工作正常,但它在WSL/ZSH中不起作用。
这可能表明核心问题。听起来您将项目在Windows驱动器上,例如 c:
。这将在WSL下以/mnt/c/path/to/project
的形式引用。
如果是这样,那么您将面临两个问题(这两个问题):
-
文件访问将非常慢 - 有关详细信息,请参见我的相关答案关于缓慢的NPM/纱线性能。
-
热重加载功能无法正常工作,因为WSL2中没有针对Windows驱动器的Inotify支持。有关详细信息,请参见我的另一个相关答案关于
nodemon
的热重新加载。它也出现在堆栈溢出上的React,Tailwind和其他情况下。
如其他答案中所述,通常有两个选项。但是,由于您正在运行Ubuntu 22.04,因此其中一个不太可能起作用:
-
首先,始终建议使用WSL2下的本机文件系统。将项目文件放入
〜/src
或〜/projects
之类的东西中。这将大大提高性能,并允许iNotify(重新加载)功能工作。 -
第二,在大多数发行版中,假设您不需要WSL2内核的任何特定功能,则可以使用WSL1。 WSL1与Linux具有相当高的兼容性(对于许多开发人员工具和框架,在99%+范围内的某个位置),但在Windows驱动器中的性能也更好,并且在此处具有Inotify支持。
但是,,WSL1开始显示出年龄的年龄,Ubuntu 22.04的某些变化在WSL1上打破了很多东西。
gzip
的更改(其他分布可能很快就会捡起),这意味着它不会在WSL1上运行。这导致依赖于gzip
的其他应用程序中的级联故障。
因此,除非并且在WSL中修复之前,否则我将坚持使用Ubuntu 22.04的WSL2,并使用第一个将文件放在您的WSL2文件系统中的选项。
获取此信息的方法有很多 - 这取决于您要访问的方式。 Django文档是一个很好的来源
,这里是一个示例,使用 queryset。 prefetch_releated()(通常是最简单的),
clients = Client.objects.filter(status_id=3).prefetch_related(
"addresses",
"phones",
"emails",
) # will run all queries at once here
print(clients[0].emails[0].email_address) # will not run additional query here
这是一个示例,使用 queryset.values()
clients = Client.objects.filter(status_id=3).values(
"id",
"first",
"last",
"addressess__zip_code",
"phones__phone_number",
"emails__email_address"
)
print(clients[0]['emails__email_address'])
这是一个示例,使用 queryset.annotate() and
clients = Client.objects.filter(status_id=3).annotate(
zip_code=F("addressess__zip_code"),
phone_number=F("phones__phone_number"),
email_address=F("emails__email_address"),
)
print(clients[0].email_address)
(注意 - 我不确定骗子在这里如何工作 - 可以使用Postgres -extific
如果其他所有失败,您可以随时写 RAW SQL :
clients = Client.objects.raw_sql("SELECT my_field FROM clients JOIN ...")
print(clients[0]["my_field"])
如果内容被Flash阻塞,即使使用正确的z索引,则将 wmode =“透明”
添加到Flash Emped脚本。
给出位置:绝对;
to .logo
。
中心徽标通过添加顶部:50%;变换:translatey(-50%);
属性到 .logo
。
其余代码从一开始就组织了。
@font-face {
font-family: 'leander';
src: url(/Fonts/LEANDER.TTF);
}
body {
margin: 0;
background-color: #262626;
}
.topnav {
position: relative;
background-color: #141414;
overflow: hidden;
text-align: right;
padding: 14px 20px;
box-shadow: 0px 5px 10px black;
}
.topnav a {
position: relative;
color: white;
text-align: center;
padding: 30px 16px;
text-decoration: none;
font-size: 17px;
}
.logo {
position: absolute;
top: 50%; /*Important for vertical centered element*/
transform: translateY(-50%); /*vertically centered*/
color: white;
font-family: 'leander', sans-serif;
text-align: left;
float: left;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arclight Web Development</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=">
<link rel="stylesheet" href="app.css">
</head>
<body>
<div class="topnav">
<div class="logo">
<span id="A">A</span>
<span id="R">R</span>
<span id="C">C</span>
<span id="L">L</span>
<span id="I">I</span>
<span id="G">G</span>
<span id="H">H</span>
<span id="T">T</span>
</div>
<a class="active" href="#home">Home</a>
<a href="#projects">Projects</a>
<a href="#about">Meet the Dev</a>
<a href="#contact">Contact</a>
</div>
<script src="app.js"></script>
</body>
</html>
为了避免统一的任何类型的抖动(例如,摄像机在摇晃时添加到
时)使用各种 SmoothDamp
功能,例如 https://docs.unity3d.com/scriptreference/scriptreference/vector3.smoothdamp.html :
public float smoothTime = 0.3f; // adjust this to taste
private float distance;
private Vector3 velocity = Vector3.zero;
private Vector3 targetPos
void Update()
{
distance = cam.transform.position.x * parallax;
targetPos = new Vector3(startpos + distance, transform.position.y, transform.position.z)
transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref velocity, smoothTime);
}
复制范围的值
Option Explicit
Sub ImportData()
' Source (open, read from & close)
Const sFilePath As String = "C:\Users\Temp\Desktop\MyExcelSheet.xlsm"
Const sName As String = "Summary"
Const sFirstRowAddress As String = "O6:R6"
' Destination (write to & save)
Const dName As String = "Data"
Const dFirstCellAddress As String = "A1"
' Source
Dim swb As Workbook: Set swb = Workbooks.Open(sFilePath)
Dim sws As Worksheet: Set sws = swb.Worksheets(sName)
Dim srg As Range
With sws.Range(sFirstRowAddress)
Dim lCell As Range: Set lCell = .Resize(sws.Rows.Count - .Row + 1) _
.Find("*", , xlFormulas, , xlByRows, xlPrevious)
If lCell Is Nothing Then
MsgBox "No data found.", vbCritical
Exit Sub
End If
Set srg = .Resize(lCell.Row - .Row + 1)
End With
' Destination
Dim dwb As Workbook: Set dwb = ThisWorkbook ' workbook containing this code
Dim dws As Worksheet: Set dws = dwb.Worksheets(dName)
' Clear & copy.
With dws.Range(dFirstCellAddress).Resize(, srg.Columns.Count)
' Clear previous data.
.Resize(dws.Rows.Count - .Row + 1).Clear
' Copy values by assignment.
.Resize(srg.Rows.Count).Value = srg.Value
End With
' Save & close.
swb.Close SaveChanges:=False
'dwb.Save
' Inform.
MsgBox "Values copied.", vbInformation
End Sub
仅使用POSIX mmap
标志,杰斯特建议的是“乐观”策略,使用 mmap
没有 map_fixed
尝试尝试将新页面分配给您已经拥有的页面。 (第一个arg是您希望它分配的“提示”)。
它没有失败,而是将其分配在其他地方(除非虚拟地址空间已满,但这不太可能在64位)。因此,您需要检测到 mmap
的返回值!=您的提示。可能只是那个未触及的空间,然后再次询问您需要的全尺寸,然后复制。您可以尝试将剩余的空间mmap到您刚刚获得的新页面的末尾,但这可能会失败,然后您正在拨打更多的系统调用。
在Linux上,您将使用 mmap(map_fixed_noreplace)< / code>如果无法分配所需的位置(而不重叠 /替换现有映射),则返回错误。
当然,Linux MREMAP
更好,避免复制数据,如果允许使用相同的物理页面到新的虚拟地址(使用 MREMAP_MAYMOVE
)。 (
mremap
lets lets
REALLOC
REALLOC
be 更有效地生长大数组。 ,您根本无法获得该功能。
我发现C ++ std :: vector
的设计真的很愚蠢,因此它无法轻易利用 realloc
,因此 MREMAP
即使它存在,可更换新
是一种潜在的可见副作用。而新的/删除分配器API完全缺乏即使在不可忽视的类型的类型中也可以使用的try-realloc。但是,这种过分保守的设计中的某些高级语言意味着即使存在,低级功能也可能不会得到太多使用,因此,如果Macos缺乏它,我不会感到惊讶。
OTOH,C realloc
当然可以使用 MREMAP
如果原始分配具有其本身的页面,并且很多内容是用C编写的,而不是由C ++的分配器API丢掉。因此,MacOS可能会以某种方式支持类似的内容,但我不知道MacOS特定的系统呼叫详细信息。
我确实查看了darwin XNU内核中的BSD系统调用表“ nofollow noreferrer”> https:href =“ https://stackoverflow.com/ macOS-64-Bit-system-call-table“> MacOS 64位系统呼叫表
问题/48845697 / 使用 0x2000000
class lit中的BSD呼叫家族。
有一个 int MemoryStatus_control(Uint32_t命令,INT32_T PID,UINT32_T标志,user_addr_t buffer,size_t buffersize);
,但这返回 int
int ,所以我假设这不是我们''''重新寻找。
我没有看到任何其他有希望的系统呼叫。
我没有检查Macos Man页面上的MMAP;如果它具有任何MacOS特定的标志,例如 map_fixed_noreplace
,希望它们会在那里。
您需要设置 to not-cors 使其允许交叉原始资源共享。
尝试这样做。
希望它有帮助。
You need to set the request mode to no-cors for it to allow cross-origin resource sharing.
Try doing this.
Hope it helps.
尝试使用X-Auth-Toke访问JSON端点会导致错误