How to use ctre.hpp

  c++, header-files

I saw a code that is similar to the snippet below.

The following code snippet gives this error –

$ g++ hellothere.cpp 
hellothere.cpp:3:10: fatal error: ctre.hpp: No such file or directory
    3 | #include <ctre.hpp>
      |          ^~~~~~~~~~

A quick google search didn’t help much.

Is it a boost library? Do I need to download this file and then include it?

I am on ubuntu and using this g++ compiler – "g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"

#include <iostream>
#include <boost/algorithm/string.hpp>
#include <ctre.hpp>
//#include "single_header/ctre.hpp"

bool isValidKeyName(std::string_view name) {
    return !name.empty() &&
        ctre::match<"^[a-zA-Z0-9]">(name);
}

int main(int argc, char **argv)
{
    std::string_view valid1 = "abcd";
    std::cout << valid1 << "is valid : " << isValidKeyName(valid1);
    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT