Post

Replies

Boosts

Views

Activity

Reply to Deleted Function
The following program compiles:#include <thread> void sampler() { } struct Sampler { void operator()() { } }; struct NotASampler { }; int main(int argc, const char* argv[]) { auto lsampler = []() { }; std::thread t1(sampler); std::thread t2((Sampler())); std::thread t3(lsampler); //std::thread t4((NotASampler())); return 0; }Note that trying to create a thread with the "NotASampler" gives the same error you mentioned in your post. You can't create a thread with a non-functional struct/class. Note also the need for an extra pair of parentheses around the call to the functional "Sampler," which is needed because you are not passing a function pointer.Compiled with --std=c++17
Dec ’19
Reply to How to create an alternative toolchain
This works for me:1 - Create a directory, say, MyToolchain (don't add a file extension, yet)2 - cd to the directory, and create an Info.plist file. I use an application called PListEditor, you can use Xcode, or you can manually edit the XML in a text file. It needs to have, as a minimum, a key called CFBundleIdentifier, as a String, with something that will identify the bundle to Xcode. Typically it's something like a reversed domain name, like, person.jprescott.MyToolchain, or, just MyToolchain, if you want.3 - Put in a usr directory that has all your tools, library, etc, include. It should have all your tools you might need with Xcode (compilers, linkers/loaders, archivers, ) header files to be searched as part of the system header search paths (doesn't have to be all of /usr/include), libraries to be linked, etc.. This is a standard usr layout you would find on any Unix/Linux, but only has the tools necessary to compile, analyze, link your programs.4 - Put in other directories that you might need. Apple, for example, puts in a Developer directory that holds various frameworks that are relevant. If you open Xcode.app with "Show Contents" and go to Developer>Toolchains, and open the default toolchain using "Show Contents," you'll see an example of the organization beyond just usr.5 - When you're done, change the directory filename to "MyToolchain.xctoolchain". You'll be asked to verify that you want to change the name. When you answer yes, the icon for the directory will change to the Xcode toolchain icon, and the directory looks like a single file. If you want to get to the directory contents, you open the toolchain with "Show Contents"6 - Move the new toolchain to either /Library/Developer/Toolchains, for system use, or ~/Library/Developer/Toolchains. It will then be visible in Xcode Preferences as a toolchain option.Each toolchain should address a single version of whatever compiler(s) you are using. You could put clang and gcc in the same toolchain, but, only one version of clang/gcc unless you give the compilers different names. I have LLVM toolchains org.llvm.8.0.0svn, org.llvm.9.0.0svn, org.llvm.10.0.0.git that have only the version of clang/llvm in them. However, Xcode includes a version of gcc along with clang (gcc points to clang, but, it is a separate executable) in the default toolchain.If you are asking for use with Linux, or other IDEs, you'll have to ask elsewhere.Hope this helps.
Dec ’19
Reply to Multi-line mathematical expressions
I tried out your multiline expression in an Xcode playground (Swift 5.1.2). You separate at addition (probably also subtraction), but not at multiplication (probably also for division). Didn't try the comments, but, like C/C++, inline comments should be treated like whitespace during the lexical analysis, so, it should work.
Nov ’19