<commit_before># ThreadLocal
Portable, implementation configurable and `c++11` thread_local compatible. The same code using macro `THREADL_LOCA(T)` supports different implementations controlled by macro `USE_STD_THREAD_LOCAL`.

The default implementation of macro `THREAD_LOCAL(...)` is c++11 `thread_local` keyword if supported. Otherwise, pthread and FLS implementation is used.

## WHY
`c++11` **thread_local** is not available for vs2013, apple clang for iOS (and macOS if xcode < 8), libc++ in android ndk < r14.

## Tested Compilers
VS>=2013, gcc>=4.7, clang >=3.2, Apple clang, zpacc++1.0, icc>=16

## Build

- `g++/clang++` `c++11` thread_local: `(clan)g++ -std=c++11 test.cpp`
- `g++/clang++` pthread implementation: `(clan)g++ -std=c++11 test.cpp -DUSE_STD_THREAD_LOCAL=0`
- apple clang (pthread implementation): `clang++ -std=c++11 test.cpp`
- vs>=2015 `c++11` thread_local: `cl /EHsc test.cpp`
- vs>=2015 FLS implementation: `cl /EHsc test.cpp -DUSE_STD_THREAD_LOCAL=0`
- vs2013 (FLS implementation): `cl /EHsc test.cpp`
- mingw `c++11` thread_local: `g++ -std=c++11 test.cpp`
- mingw FLS implementation: `g++ -std=c++11 test.cpp -D_WIN32_WINNT=0x0600 -DUSE_STD_THREAD_LOCAL=0`
- mingw pthread implementation: `g++ -std=c++11 test.cpp -DUSE_STD_THREAD_LOCAL=0`<commit_msg>example code in README<commit_after># ThreadLocal
Portable, implementation configurable and `c++11` thread_local compatible. The same code using macro `THREADL_LOCA(T)` supports different implementations controlled by macro `USE_STD_THREAD_LOCAL`.

The default implementation of macro `THREAD_LOCAL(...)` is c++11 `thread_local` keyword if supported. Otherwise, pthread and FLS implementation is used.

## WHY
`c++11` **thread_local** is not available for vs2013, apple clang for iOS (and macOS if xcode < 8), libc++ in android ndk < r14.

## Examples

```
    // declare and initialize. use THREAD_LOCAL macro to switch between c++11 thread_local keyword and ThreadLocal<T> implementation at build time using -DUSE_STD_THREAD_LOCAL=1/0
    static THREAD_LOCAL(int) a;
    static THREAD_LOCAL(int) b(1);
    static THREAD_LOCAL(int) c = 2;
    // assignment
    a = 3;
    // get address of stored thread data
    int* pa = &a;
    *pa = 4;
    // type convert
    printf("a=%d\n", (int&)a);
```

## Tested Compilers
VS>=2013, gcc>=4.7, clang >=3.2, Apple clang, zpacc++1.0, icc>=16

## Build

- `g++/clang++` `c++11` thread_local: `(clan)g++ -std=c++11 test.cpp`
- `g++/clang++` pthread implementation: `(clan)g++ -std=c++11 test.cpp -DUSE_STD_THREAD_LOCAL=0`
- apple clang (pthread implementation): `clang++ -std=c++11 test.cpp`
- vs>=2015 `c++11` thread_local: `cl /EHsc test.cpp`
- vs>=2015 FLS implementation: `cl /EHsc test.cpp -DUSE_STD_THREAD_LOCAL=0`
- vs2013 (FLS implementation): `cl /EHsc test.cpp`
- mingw `c++11` thread_local: `g++ -std=c++11 test.cpp`
- mingw FLS implementation: `g++ -std=c++11 test.cpp -D_WIN32_WINNT=0x0600 -DUSE_STD_THREAD_LOCAL=0`
- mingw pthread implementation: `g++ -std=c++11 test.cpp -DUSE_STD_THREAD_LOCAL=0`
{'fraction_non_alphanumeric': 0.15326301911667764, 'fraction_numerical': 0.04614370468029005, 'mean_word_length': 4.881782945736434, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2691318', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1088, 'n_words': 319}