# nlohmann::byte_container_with_subtype::has_subtype

```
constexpr bool has_subtype() const noexcept;
```

Returns whether the value has a subtype.

## Return value

whether the value has a subtype

## Exception safety

No-throw guarantee: this function never throws exceptions.

## Complexity

Constant.

## Examples

Example

The example below demonstrates how `has_subtype` can check whether a subtype was set.

```
#include <iostream>
#include <nlohmann/json.hpp>

// define a byte container based on std::vector
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;

int main()
{
    std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};

    // create container
    auto c1 = byte_container_with_subtype(bytes);

    // create container with subtype
    auto c2 = byte_container_with_subtype(bytes, 42);

    std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype()
              << "\nc2.has_subtype() = " << c2.has_subtype() << '\n';
}
```

Output:

```
c1.has_subtype() = false
c2.has_subtype() = true
```

## See also

- [Binary values](https://json.nlohmann.me/features/binary_values/index.md) - how binary values and subtypes are handled
- [`set_subtype`](https://json.nlohmann.me/api/byte_container_with_subtype/set_subtype/index.md) - sets the binary subtype
- [`clear_subtype`](https://json.nlohmann.me/api/byte_container_with_subtype/clear_subtype/index.md) - clears the binary subtype
- [`subtype`](https://json.nlohmann.me/api/byte_container_with_subtype/subtype/index.md) - return the binary subtype

## Version history

Added in version 3.8.0.
