c++

Boost Spirit: parse boolean expression and reduce to canonical normal form

狂风中的少年 提交于 2021-02-19 08:21:11
问题 I want to parse a common Boolean with just or , and and not operators, which I think I have done using Boost Spirit below. In phase 2 (or perhaps part of the parsing itself), I wish to transform the AST of the Boolean to disjunctive canonical normal form, which essentially "flattens" the expression and removes all grouping operators. In one of my attempts, I created the Boost static_visitor below, named Transformer . I started by trying to eliminate double not operators by just assigning a

Extend a template classe using the type definition in subclass

我们两清 提交于 2021-02-19 08:13:07
问题 I imitated the std::enable_shared_from_this to create a template class, but I made the class use the type definition in its subclass. Unfortunately! Although I used typename , after compiling, // // https://ideone.com/eYCBHW http://ideone.com/eYCBHW #include <iostream> #include <set> #include <map> using namespace std; template<class _S> struct A { }; template<class _Subclass> class Global { public: typedef typename _Subclass::connection_t connection_t; //std::map<std::string, _Subclass:

Possible reasons for symbol multiply defined other than 'extern'

自古美人都是妖i 提交于 2021-02-19 08:05:54
问题 Is there any reasons for 'symbol multiply defined' other than not having the declaration in .h, having it as 'extern', and have the implementation in .cpp? I'm pretty sure that all my files follow the rule, but I'm getting an error message like this: ld: lto: could not merge in /Users/zlw/Library/Developer/Xcode/DerivedData/Wireless - amjmgyrircjezdhegioctszbcypz/Build/Intermediates/Wireless.build/Debug/Wireless.build/Objects normal/x86_64/qam.o because 'Linking globals named '

Memory leak in jpeg compression. Bug or my mistake?

牧云@^-^@ 提交于 2021-02-19 08:04:28
问题 I wrote an npm module for capturing webcam input on linux. The captured frame in yuyv format is converted to rgb24 and after compressed to a jpeg image. In the jpeg compression there appears to be a memory leak. So the usage of memory increases continuously. Image* rgb24_to_jpeg(Image *img, Image *jpeg) { // img = RGB24 jpeg_compress_struct cinfo; jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jerr.trace_level = 10; jpeg_create_compress(&cinfo); unsigned char *imgd = new unsigned

Extra space at the beginning/end of .text section

做~自己de王妃 提交于 2021-02-19 08:04:08
问题 I'm looking for a way to reserve some extra space at the begining/end of the .text section from C/C++ using Visual Studio compiler. I've only found one solution on how to reserve some extra space in code section in Visual Studio: PE File .text Section Size #pragma optimize( "", off ) #define NOP __asm { NOP } ; #define NOP8 NOP NOP NOP NOP NOP NOP NOP NOP #define NOP64 NOP8 NOP8 NOP8 NOP8 NOP8 NOP8 NOP8 NOP8 #define NOP512 NOP64 NOP64 NOP64 NOP64 NOP64 NOP64 NOP64 NOP64 #define NOP4096 NOP512

SetCursor while dragging files into a window

时光毁灭记忆、已成空白 提交于 2021-02-19 08:01:28
问题 I'm using windows API to create an application with a window only, so everything inside this window is drawn using Direct2D. Now I want to drop some files in specific parts of my window's client area, and I'm handling the message WM_DROPFILES . No problem here, when the files are dropped in those specific areas, I can treat them correctly and everything is working properly. BTW, my window is DragAcceptFiles(hWnd, true) , it always accepts drag/drops. I want the mouse cursor to be different

std::unordered_map, can you access the elements in a bucket with its bucket number? [duplicate]

纵饮孤独 提交于 2021-02-19 08:01:10
问题 This question already has an answer here : C++11 get all items of one bucket in a unordered_map (1 answer) Closed 5 years ago . for std::unordered_map , can you access the elements in some bucket i if its bucket_size is not zero? 回答1: The answer is to use std::unordered_map::begin(bucket_num) or std::unordered_map::cbegin(bucket_num) to get the iterator pointing to the the first element to that bucket and iterate to the end of the bucket std::unordered_map::end(bucket_num) for ( auto it = u

std::unordered_map, can you access the elements in a bucket with its bucket number? [duplicate]

社会主义新天地 提交于 2021-02-19 08:01:09
问题 This question already has an answer here : C++11 get all items of one bucket in a unordered_map (1 answer) Closed 5 years ago . for std::unordered_map , can you access the elements in some bucket i if its bucket_size is not zero? 回答1: The answer is to use std::unordered_map::begin(bucket_num) or std::unordered_map::cbegin(bucket_num) to get the iterator pointing to the the first element to that bucket and iterate to the end of the bucket std::unordered_map::end(bucket_num) for ( auto it = u

Boost Serialization example Error: symbol(s) not found for architecture x86_64

别等时光非礼了梦想. 提交于 2021-02-19 07:46:12
问题 When I try to build/run a boost-Serialization example-code program, I'm getting errors, which I can't resolve and the code is from the boost serialization tutorial, so I don't think that it's wrong. I'm using the NetBeans 8.0.2 IDE and the Boost Library Version 1.58.0. The code: #include <fstream> // include headers that implement a archive in simple text format //#include <boost/archive/text_oarchive.hpp> //#include <boost/archive/text_iarchive.hpp> #include "../boost/archive/text_oarchive

shared library error about “undefined symbol” when using `dlopen`

江枫思渺然 提交于 2021-02-19 07:44:25
问题 First thing first, here's my minimum reproducible program: CMakeLists.txt: cmake_minimum_required(VERSION 3.17) project(untitled4) set(CMAKE_CXX_STANDARD 17) add_library(lib1 SHARED lib1.cpp) add_executable(untitled4 main.cpp) target_link_libraries(untitled4 PRIVATE dl) main.cpp: #include "iostream" #include <dlfcn.h> int Test() { return 123456; } int main() { auto* handler = dlopen("/home/liu/source/untitled4/cmake-build-debug/liblib1.so", RTLD_LAZY|RTLD_GLOBAL); if (!handler) { std::cerr <<