我做了一个提交并推动我的git repo.
然后我需要回滚我这样做的提交:
git reset --hard b1b5768c9687455f01bab242ff177a5ee403104f
Run Code Online (Sandbox Code Playgroud)
是否有可能找到第一次提交的SHA?然后再回到它?
我正在尝试在用户输入的字符串中查找空间.我想用find()from std::string来返回空间的位置.
如果输入是"Seattle,WA USA",我想要find(" ", 0)返回8,我该怎么做?第8个是","之后的空格
string inputString = " ";
cout << "Enter String to modify" << endl;
cin >> inputString;
int spac = inputString.find(" " , 0);
Run Code Online (Sandbox Code Playgroud)
但是find()继续回来0.我不知道为什么.
新标准的功能是否会对C++ 11中的boost库实现产生重大影响?
鉴于存在可变参数模板,特别感兴趣的是boost::variant(BOOST_VARIANT_LIMIT_TYPES)和boost::spirit部分库.
有关于此的好文章吗?
我正试图从boost :: spirit规则定义的动作中引用(尚未)未知实例的成员,因此在伪代码中,
而不是double_ [ref(rN)= _1]我正在寻找类似X**ppx的东西; double_ [ref(&X :: rN,ppx)= _1]
它的解决方法可能是一个简单的"语义操作",其中一个参数可以知道实例并且可以写入它,就像
qi::rule<Iterator, Skipper> start;
my_grammar(DataContext*& dataContext) : my_grammar::base_type(start) , execContext(execContext) {
start = qi::double_[ boost::bind(&my_grammar::newValueForXY, dataContext, ::_1) ];
Run Code Online (Sandbox Code Playgroud)
但是,我想知道是否有可能直接"绑定"到成员变量,就像可以通过使用"phoenix :: ref(...)= value"绑定到"本地"变量一样.
我尝试了以下语法:
start = qi::int_[ boost::bind<int&>(&DataContext::newValueForXY, boost::ref(dataContext))() = ::_1] ];
Run Code Online (Sandbox Code Playgroud)
但是VS2010SP1和错误消息失败了
错误C2440:'=':'boost :: arg'无法转换为...
我在损坏的存储库中丢失了提交对象,但是仍然有一些文件和树对象:
$ git fsck
Checking object directories: 100% (256/256), done.
dangling blob 031be26142ed97da216fb7d79d16a0b0efdf0d71
dangling blob 4b2be7dfef082c2e247be52e6d78600af7b6dd40
dangling tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
dangling blob ccbb1056cb4e744f9a4b44a439fa036f6a3d7cbe
dangling blob 10bfbc3c1fa10e08cd6a783565f00e7324f61fe5
dangling blob 9b529957be714fef304c4e8161fe6cd138510e98
dangling blob dd5b54882d0b74db99c8a7fbba703d528dc559b9
Run Code Online (Sandbox Code Playgroud)
有没有办法检查出那个树对象?
我猜可能有一种方法可以用伪提交字符串重建提交对象并检查出来。
git cat-file -p tree-sha1
Run Code Online (Sandbox Code Playgroud) 我有两种类型的表达式,我想解析并计算结果.
拟合表达式:+, - ,*,/和sqrt()函数; 例如:"2 + 3*sqrt(100*25)" - >应计算为152
功能:GetSubString()和ConcatenateStrings()如: "GetSubString( '100str1',0,3)" - >应被计算为100
我有2个单独的语法来解析这些表达式类型.现在我想结合这两个语法,并可以将这些表达式一起定义.
例如:
我试图通过使用置换运算符组合下面的2个语法.但它没有编译.
expr_ =
( *( (function_call_ ^ arithmeticexpression_)| string_ ));
Run Code Online (Sandbox Code Playgroud)
那么这是一个合并我的function_call_和arithmeticexpression_规则的正确方法,或者我该怎么做?
typedef boost::variant<int, float, double, std::wstring> RetValue;
RetValue CTranslationFunctions::GetSubString(RetValue const& str, RetValue position, RetValue len)
{
std::wstring strToCut;
size_t posInt = 0;
size_t lenInt = 0;
try
{
strToCut = boost::get<std::wstring>(str);
posInt = boost::get<int>(position);
lenInt = boost::get<int>(len); …Run Code Online (Sandbox Code Playgroud) 我正在使用带有默认优化设置(/ O2)的VS2012,此问题仅存在于发布模式中.
我有一些代码使用michael_deque(使用标准GC)和指向(抽象)类型的指针T.
当我尝试将指针推回到派生自的类型时,T应用程序在退出push_back()函数时崩溃michael_deque.
问题似乎完全取决于这种特定类型T,因为编写一个虚拟类foo,在类中派生它bar(并在构造函数中打印一些东西以避免它被优化掉),然后再推回到new bar()michael_deque不会导致崩溃.
T有问题的课程是这样的:
class Task
{
public:
Task() : started(false), unfinishedTasks(1), taskID(++taskIDCounter) {};
Task(unsigned int parentID_) : started(false), unfinishedTasks(1), taskID(++taskIDCounter), parentID(parentID_)/*, taken(0)*/ {};
virtual ~Task() = 0 {};
virtual void execute() final
{
this->doActualWork();
unfinishedTasks--;
}
virtual void doActualWork() = 0;
public:
unsigned int taskID; //ID of this task
unsigned int parentID; //ID of the parent of …Run Code Online (Sandbox Code Playgroud) 我正在尝试向基于libevent的库反向移植以使用ASIO后端(从而在单个应用程序中避免多个事件循环).还有其他方法可以解决"问题",但我对此感兴趣
我没有event在Boost :: ASIO文档中看到对象的直接等价物(或者更确切地说,是一个句柄 - 因为libevent是用纯C编写的); boost :: asio :: strand看起来很熟悉,但它似乎没有遵循libevent的模式:创建,期望,接收,做工作{,重复}.
我需要的是拥有一组对象/事件/事件回调,除非回调(通过套接字事件)发生,否则可以创建和忘记回调,运行在io_service循环之上; Boost中有类似的东西吗?
我在嵌入式 MCU 中有一个 C 结构,大约有 1000 个元素,其中包含许多固定大小的数组和其他结构,现在我想使用 C# 将数据传送到 PC
这是我在 C 中的结构元素的简单预览
struct _registers
{
char name[32];
float calibrate[4][16];
float DMTI;
float DMTII;
float DMTIII;
float DMTIE;
float DMTIIE;
....
};
Run Code Online (Sandbox Code Playgroud)
现在我想使用 GCHandle 类将 Struct 转换为 C#,
像这样的东西
//The C struct is in this byte array named buffer
byte[] buffer = new byte[4096];
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
_registers stuff = (protection_registers)Marshal.PtrToStructure(handle.AddrOfPinnedObject(),typeof(_registers));
handle.Free();
Run Code Online (Sandbox Code Playgroud)
问题是 Visual Studio 抱怨“指针和固定大小的缓冲区只能在不安全的上下文中使用”
有没有办法在没有不安全代码的情况下正常使用它?我发现做这样的事情
[StructLayout(LayoutKind.Explicit, Size = 56, Pack = 1)]
public struct NewStuff
{ …Run Code Online (Sandbox Code Playgroud) 我读到 protobuf 有一种叫做“字节”的类型,它可以存储任意数量的字节,相当于“C++字符串”。我不喜欢使用“字节”的原因是它期望输入为 C++ 字符串,即,boost IP 需要转换为字符串。现在我关心的是:我想执行序列化并通过 TCP 套接字发送编码的 protobuf 消息。我想确保编码的消息大小尽可能小。
目前,我正在使用以下 .proto 文件:
syntax = "proto2";
message profile
{
repeated **uint32** localEndpoint = 1;
repeated **uint32** remoteEndpoint = 2;
}
Run Code Online (Sandbox Code Playgroud)
为了在 protobuf 消息中保存 boost IP,我首先使用“boost::asio::ip::address_v4::to_bytes()”将 boost IP 转换为字节格式数组。因此,对于 v4 IP,结果数组大小为 4。然后我将结果字节数组中的第 1 个 4 字节转换为一个 uint32_t 数字,然后存储在 protobuf 消息的“localEndpoint”字段中。同样,我重复接下来的 4 个字节(对于 v6)。我一次取 4 个字节,以便利用 uint32 的全部 32 位。
因此,对于 v4 地址,使用了 1 次“localEndpoint”字段。类似地,对于 v6 地址,使用了 4 次“localEndpoint”字段。
请允许我强调,如果我在这里使用了“字节”,对于像 111.111.111.111 这样的 v4 ip,我的输入字符串本身的大小将是 15 个字节
使用 …
c++ ×6
boost-spirit ×3
boost ×2
boost-asio ×2
c++11 ×2
git ×2
arrays ×1
boost-bind ×1
c# ×1
libcds ×1
parsing ×1
reference ×1
string ×1
struct ×1